### Define Billing Cycle Start Info Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Defines the start parameters for a billing cycle, including specific days or months. ```graphql type BillingCycleStartInfoGQLType { startDay: SpecificDayGQLType startDayInMonth: Int startMonth: Int } input BillingCycleStartInfoGQLInputType { startDay: SpecificDayGQLType startDayInMonth: Int startMonth: Int } ``` -------------------------------- ### Create Plan Variables Source: https://docs.subsbase.com/api-and-webhooks/plans-api Example JSON variables object for the CreatePlan mutation. ```json // Variables Sample: { "plan": { "siteId": "test-site", "name": "test17281q", "planCode": "test17281q", "billingModel": "PrePaid", "description": "", "data": "{}", "pricingModel": "Fixed", "fixedPricing": { "price": 144, "displayCurrencyConversion": null, "taxes": null, "extraFees": null }, "variablePricing": null, "perUnitPricing": null, "setupFee": 12, "status": "Active", "displaySettings": "{\"description\":{},\"image\":{}}", "discountedFrom": null, "defaultCurrencyCode": "egp", "displayCurrencyCode": null, "trialPeriod": { "duration": 0, "unit": "Day" }, "billingType": "Recurring", "planPausingDurations": [], "planFutureStarts": [], "billingCycle": { "unit": "Month", "duration": 1, "Model" : "StartImmediately", "ChangeMode" : "ShiftBillingCycle", "CycleStart" : "", "termLimit": { "cycles": 0, "actionOnEnd": "renew" }, "earlyInvoiceCreationSettings": { "duration": 0, "unit": "Day" }, "dueInvoiceDueSettings": { "duration": 3, "unit": "Day", "action": "DoNothing" }, "usageQuery": null }, "infoFields": [], "planRules": { "maxTotalAddonsQuantity": null }, "addOns": [] }, "siteId": "test-site" } ``` -------------------------------- ### GQL Queries - Get Site Manual Payment Methods Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Retrieves the manual payment methods configured for a given site. ```APIDOC ## GET /graphql ### Description Retrieves the manual payment methods configured for a given site. ### Method GET ### Endpoint /graphql ### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Response #### Success Response (200) - **getSiteManualPaymentMethods** ([SitePaymentMethodGQLType]) - A list of manual payment methods. ``` -------------------------------- ### Postpaid Usage Payload Example Source: https://docs.subsbase.com/admin-portal-guide/plans This JSON payload details usage for postpaid plans or addons. It includes site, customer, and subscription identifiers, along with a list of plan and addon codes relevant to the usage period. ```json { "siteId":"test-site", "customerId":"12345", "subscriptionId":"67890", "startDate":"2022-01-01T00:00:00.000Z", "endDate":"2022-01-31T00:00:00.000Z", "codes": [ "plan-01", "addon-1", "addon-2" ] } ``` -------------------------------- ### GQL Queries - Get Site Payment Methods Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Retrieves the payment methods configured for a given site. ```APIDOC ## GET /graphql ### Description Retrieves the payment methods configured for a given site. ### Method GET ### Endpoint /graphql ### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Response #### Success Response (200) - **getSitePaymentMethods** ([SitePaymentMethodGQLType]) - A list of payment methods. ``` -------------------------------- ### Plan Future Start GraphQL Types Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Defines the PlanFutureStart GraphQL Type for future plan changes and the PlanFutureStart GraphQL Input Type for configuring them. ```APIDOC ## Plan Future Start GraphQL Type ### Description Represents a scheduled future change to a plan. ### Fields - **displayText** (String!) - **id** (ID) - **interval** (IntervalGQLType) - **planId** (ID) - **rule** (RuleGQLType) - **siteId** (String!) ## Plan Future Start GraphQL Input Type ### Description Input for scheduling future plan changes. ### Fields - **displayText** (String!) - **interval** (IntervalGQLInputType) - **planId** (ID) - **rule** (RuleGQLInput) ``` -------------------------------- ### Billing Cycle Start Info Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Defines the structure for billing cycle start information. ```APIDOC ## Billing Cycle Start Info ### Type Definition ```graphql type BillingCycleStartInfoGQLType { startDay: SpecificDayGQLType startDayInMonth: Int startMonth: Int } ``` ### Input Definition ```graphql input BillingCycleStartInfoGQLInputType { startDay: SpecificDayGQLType startDayInMonth: Int startMonth: Int } ``` ``` -------------------------------- ### GraphQL Query Variables Sample Source: https://docs.subsbase.com/api-and-webhooks/plans-api Sample variables to use with the GetPlan GraphQL query. Ensure 'planCode' and 'siteId' are provided. ```json // Variables Sample: { "planCode": "semi-annual-plan", "siteId": "test-site" } ``` -------------------------------- ### Get Invoice HTML Source: https://docs.subsbase.com/api-and-webhooks/exporter-api Request an invoice download in HTML format. ```json { id: {invoiceId}, extraFees: (optional), } ``` -------------------------------- ### Campaign Data Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Provides usage and billing cycle start data for campaigns. ```APIDOC ## Campaign Data ### Type Definition ```graphql type CampaignDataGQLType { billingCycleStartIndex: int usageCount: int } ``` ``` -------------------------------- ### Initialize Subsbase via JavaScript Source: https://docs.subsbase.com/integration-guide/embedding-checkout Use these snippets if you are loading the Subsbase configuration directly via JavaScript execution on page load. ```javascript // Ensure that the below script executes on page load (function (d, o, s, a, m) { a = d.createElement(o); m = d.getElementsByTagName(o)[0]; a.async = 1; a.src = s; m.parentNode.insertBefore(a, m); })(document, "script", "https://embed.subsbase.com/sb.min.js"); window.sb = window.sb || function () { (sb.s = sb.s || []).push(arguments); }; sb("siteId", "{your_siteId}"); // Required. sb("theme", "{hex-code}"); // Optional. example: sb('theme', '#20407d') sb("callback", (e) => console.log("signup result:", { e })); // Optional. sb( "attachPlan", "{planCode}", "{clickableElementReference}", ["class|id"], ["{attachEvent}"] ); // At least one is required. can be repeated. sb("queryParam", "redirects[success]", "{url}"); // Optional. sb("queryParam", "redirects[invoicePaid]", "{url}"); // Optional. sb("queryParam", "{param}", "{value}"); // Optional. can be repeated. sb("queryParam", "disableInfoFields", true); // Optional. ``` ```javascript // Ensure that the below script executes on page load (function (d, o, s, a, m) { a = d.createElement(o); m = d.getElementsByTagName(o)[0]; a.async = 1; a.src = s; m.parentNode.insertBefore(a, m); })(document, "script", "https://embed.subsbase.com/sb.min.js"); window.sb = window.sb || function () { (sb.s = sb.s || []).push(arguments); }; sb("siteId", "{your_siteId}"); // Required. sb("theme", "{hex-code}"); // Optional. example: sb('theme', '#20407d') sb("callback", (e) => console.log("signup result:", { e })); // Optional. sb("checkoutVersion", "v2"); // Optional. sb( "attachPlan", "{planCode}", "{clickableElementReference}", ["class|id"], ["{attachEvent}"] ); // At least one is required. can be repeated sb("queryParam", "redirects[success]", "{url}"); // Optional. sb("queryParam", "redirects[invoicePaid]", "{url}"); // Optional. sb("queryParam", "{param}", "{value}"); // Optional. can be repeated. sb("queryParam", "disableInfoFields", true); // Optional. ``` -------------------------------- ### POST /graphql (CreateCustomer) Source: https://docs.subsbase.com/api-and-webhooks/customers-api Creates a new customer record using a mutation. ```APIDOC ## POST /graphql ### Description Creates a new customer in the system. ### Method POST ### Endpoint /graphql ### Request Body - **siteId** (String) - Required - The site identifier. - **customer** (CustomerGQLInputType) - Required - Object containing emailAddress, firstName, lastName, and optional customerId. ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the creation was successful. - **value** (Object) - Returns the created customer details. ``` -------------------------------- ### Get Draft Invoice Source: https://docs.subsbase.com/api-and-webhooks/invoices-api Query to retrieve a specific draft invoice by its ID. ```APIDOC ## Get Draft Invoice ### Description Returns the specific draft invoice. You can specify any of the fields detailed in the Draft Invoice Type Definition. ### Method Query ### Endpoint N/A (GraphQL Query) ### Parameters #### Query Parameters - **siteId** (String!) - Required - The ID of the site. - **draftInvoiceId** (String!) - Required - The ID of the draft invoice. ### Request Example ```json { "siteId": "test-site", "draftInvoiceId": "c9817d51-ade1-4e39-a294-988f4d9c88cb" } ``` ### Response #### Success Response (200) - **siteId** (String) - The ID of the site. - **id** (String) - The ID of the draft invoice. #### Response Example ```json { "siteId": "test-site", "id": "c9817d51-ade1-4e39-a294-988f4d9c88cb" // ... other properties from DraftInvoiceGQLType } ``` ``` -------------------------------- ### GQL Queries - Available Actions Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Retrieves a list of available actions for a given site. ```APIDOC ## GET /graphql ### Description Retrieves a list of available actions for a given site. ### Method GET ### Endpoint /graphql ### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Response #### Success Response (200) - **availableActions** ([String]) - A list of available actions. ``` -------------------------------- ### Download File Headers Source: https://docs.subsbase.com/api-and-webhooks/attachments-api Required headers for the GET request to download an attachment. ```http Authorization: Bearer X-SITE-ID: {your site id} ``` -------------------------------- ### Initialize Site ID Source: https://docs.subsbase.com/integration-guide/embedding-checkout Required operation to specify the site ID containing your plans. ```javascript sb("siteId", "{your_siteId})"); ``` -------------------------------- ### POST /plans (GraphQL Mutation) Source: https://docs.subsbase.com/api-and-webhooks/plans-api Creates a new plan for a specific site using the CreatePlan mutation. ```APIDOC ## POST /plans (GraphQL Mutation) ### Description Creates a new plan for a specific site. It is recommended to use variables for the input types due to their complexity. ### Method POST ### Endpoint /plans ### Request Body - **siteId** (String) - Required - The ID of the site. - **plan** (PlanGQLInputType) - Required - The plan object containing details like name, planCode, billingModel, pricingModel, and billingCycle. ### Request Example { "plan": { "siteId": "test-site", "name": "test17281q", "planCode": "test17281q", "billingModel": "PrePaid", "pricingModel": "Fixed", "fixedPricing": { "price": 144 }, "setupFee": 12, "status": "Active", "defaultCurrencyCode": "egp", "billingType": "Recurring", "billingCycle": { "unit": "Month", "duration": 1 } }, "siteId": "test-site" } ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the operation was successful. - **message** (String) - Status message. - **value** (Object) - The created plan object containing the ID. #### Response Example { "data": { "plans": { "create": { "isSuccess": true, "message": "Plan created successfully", "value": { "id": "plan_12345" } } } } } ``` -------------------------------- ### GQL Queries - Get API Secret Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Retrieves the API secret for a given site. ```APIDOC ## GET /graphql ### Description Retrieves the API secret for a given site. ### Method GET ### Endpoint /graphql ### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Response #### Success Response (200) - **getApiSecret** (ResultGQLType_String) - The API secret. ``` -------------------------------- ### Get Dunning Profile Source: https://docs.subsbase.com/api-and-webhooks/payment-schedules-apis Retrieves a specific dunning profile by its ID for a given site. ```APIDOC ## GET /websites/subsbase/dunningProfiles/{dunningProfileId} ### Description Retrieves a specific dunning profile by its ID for a given site. ### Method GET ### Endpoint /websites/subsbase/dunningProfiles/{dunningProfileId} ### Parameters #### Path Parameters - **dunningProfileId** (String!) - Required - The ID of the dunning profile to retrieve. #### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Request Example ```graphql query GetDunningProfile($siteId: String!, $dunningProfileId: String!) { dunningProfile(siteId: $siteId, dunningProfileId: $dunningProfileId) { id siteId name dunningFailAction trials { index trialDelayInDays trialPercentage template } } } ``` ### Request Variables Sample ```json { "siteId": "test-site", "dunningProfileId": "619951bd-74ce-46d6-827d-853e982fab99" } ``` ### Response #### Success Response (200) - **id** (String) - The unique identifier for the dunning profile. - **siteId** (String) - The ID of the site associated with the profile. - **name** (String) - The name of the dunning profile. - **dunningFailAction** (String) - The action to take when dunning fails. - **trials** (Array) - Details of dunning trials. - **index** (Int) - The index of the trial. - **trialDelayInDays** (Int) - The delay in days before the trial. - **trialPercentage** (Float) - The percentage applied during the trial. - **template** (String) - The template used for the trial notification. #### Response Example ```json { "id": "619951bd-74ce-46d6-827d-853e982fab99", "siteId": "test-site", "name": "Aggressive Dunning", "dunningFailAction": "Immediately Cancel", "trials": [ { "index": 1, "trialDelayInDays": 1, "trialPercentage": 100.0, "template": "dunning_email_urgent" }, { "index": 2, "trialDelayInDays": 2, "trialPercentage": 100.0, "template": "dunning_email_final" } ] } ``` ``` -------------------------------- ### Define TrialPeriodSettings Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Defines the configuration for trial periods using both type and input definitions. ```graphql type TrialPeriodSettingsGQLType { duration: Int! requiresCreditCard: Boolean! unit: IntervalUnitGQLType } input TrialPeriodSettingsGQLInputType { duration: Int! requiresCreditCard: Boolean unit: IntervalUnitGQLType } ``` -------------------------------- ### Get Site Payment Methods Source: https://docs.subsbase.com/api-and-webhooks/payment-schedules-apis Retrieves the saved payment methods for recurring payments on a site. ```APIDOC ## GET /websites/subsbase/sitePaymentMethods ### Description Retrieves the saved payment methods for recurring payments on a site, such as wallets and cards, which are automatically collected. ### Method GET ### Endpoint /websites/subsbase/sitePaymentMethods ### Parameters #### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Request Example ```graphql query GetSitePaymentMethods($siteId: String!) { getSitePaymentMethods(siteId: $siteId) { id siteId paymentProviderCode } } ``` ### Request Variables Sample ```json { "siteId": "test-site" } ``` ### Response #### Success Response (200) - **id** (String) - The unique identifier for the payment method. - **siteId** (String) - The ID of the site associated with the payment method. - **paymentProviderCode** (String) - The code of the payment provider. #### Response Example ```json [ { "id": "pm_12345", "siteId": "test-site", "paymentProviderCode": "STRIPE" } ] ``` ``` -------------------------------- ### Update Plan Variables Sample Source: https://docs.subsbase.com/api-and-webhooks/plans-api A sample JSON object representing the variables required for the UpdatePlan mutation. ```json // Variables Sample: { "plan": { "siteId": "test-site", "name": "12121", "planCode": "12121", "invoiceName": null, "imageUrl": null, "accountingCode": "accounting code", "billingModel": "PrePaid", "description": "", "data": "{\"taxInvoicing\":{\"sku\":\"12365\",\"item-type\":\"213132\",\"unit-type\":\"432423\",\"integrationId\":\"685EFEA0-165F-42DC-ADB9-D325C51C216A\"},\"canBeChanged\":true,\"calculateCreditNote\":true,\"usageCalculationMode\":\"Both\"}", "pricingModel": "Fixed", "fixedPricing": { "price": 12, "displayCurrencyConversion": null, "taxes": [ { "type": "Percentage", "name": "1212", "value": 0.2 } ], "extraFees": [] }, "variablePricing": null, "perUnitPricing": null, "setupFee": 12, "status": "Active", "displaySettings": "{\"image\":{},\"description\":{}}", "discountedFrom": null, "defaultCurrencyCode": "egp", "displayCurrencyCode": null, "trialPeriod": { "duration": 0, "unit": "Day", "requiresCreditCard": false }, "billingType": "Recurring", "planPausingDurations": [], "planFutureStarts": [], "billingCycle": { "unit": "Month", "duration": 1, "Model" : "StartImmediately", "ChangeMode" : "ShiftBillingCycle", "CycleStart" : "", "termLimit": { "cycles": 12, "actionOnEnd": "Renew" }, "earlyInvoiceCreationSettings": { "duration": 0, "unit": "Day" }, "dueInvoiceDueSettings": { "duration": 3, "unit": "Day", "action": "DoNothing" }, "usageQuery": null }, "infoFields": [ { "name": "name", "label": "Full Name", "type": "Full Name", "validation": ".*\\s+.+", "required": true, "editable": false, "disabled": false }, { "name": "email", "label": "Email", "type": "Email", "validation": "^(([^<>()[\]\\\\.,;:\\s@\"]+(\\.[^<>()[\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$", "required": true, "editable": false, "disabled": false }, { "name": "registration", "label": "Registration Number/National ID", "type": "Text", "validation": "", "required": true, "editable": false, "disabled": true }, { "name": "tax-number", "label": "Tax number", "type": "Text", "validation": "", "required": true, "editable": false, "disabled": true }, { "name": "is-individual", "label": "Is Person", "type": "Checkbox", "validation": "", "required": false, "editable": false, "disabled": true }, { "name": "country-iso-code", "label": "Country ISO code", "type": "Text", "validation": "", "required": true, "editable": false, "disabled": true } ], "planRules": { "maxTotalAddonsQuantity": null, "exactTotalAddonsQuantity": null }, "addOns": [ { "id": "37dfd8b5-b534-464e-98db-77542319c8ef", "name": "sssdsadasdasdasd", "data": "{\"taxInvoicing\":{\"sku\":\"ssss\",\"item-type\":\"ssss\",\"unit-type\":\"ssss\"}}", "code": "sssdsadasdasdasd", "description": null, "imageUrl": null, "status": "Active", "billingModel": "PrePaid", "billingType": "Recurring", "displaySettings": "{\"image\":{},\"description\":{}}", "billingCycle": { "unit": "Month", "duration": 1, "termLimit": { "cycles": 12, "actionOnEnd": "Renew" } }, "pricingModel": "Fixed", "fixedPricing": { "price": 22, "required": false, "displayCurrencyConversion": null }, "variablePricing": null, "perUnitPricing": null }, { "id": "3d703b6b-e499-4c28-95c6-5021c48d5088", "name": "addon 1", "data": "{\"taxInvoicing\":{\"sku\":\"sssss\",\"item-type\":\"ssss\",\"unit-type\":\"sssss\"}}", "code": "addon-1", "description": null, "imageUrl": null, "status": "Active", "billingModel": "PrePaid" ``` -------------------------------- ### POST /graphql - createCustomer Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v1 Creates a new customer record. ```APIDOC ## POST /graphql ### Description Creates a new customer in the specified site. ### Method POST ### Parameters #### Request Body - **customer** (CustomerGQLInputType) - Required - The customer details. - **siteId** (String) - Required - The ID of the site. ### Response #### Success Response (200) - **ResultGQLType_Customer** (Object) - The created customer object. ``` -------------------------------- ### Addon Subscription Data Type Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v1 Represents an addon that has been subscribed to, including its start and end dates and status. ```APIDOC ## Addon Subscription Data Type ### Description Details a specific addon subscribed to by a customer. ### Type Definition ```graphql type AddOnSubscriptionGQLType { addOn: AddOnGQLType endedOn: DateTime id: String! movedTo: String quantity: Long startedOn: DateTime status: SubscriptionStatusGQLType } ``` ``` -------------------------------- ### GQL Queries - Settings Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Retrieves specific settings for a given site. ```APIDOC ## GET /graphql ### Description Retrieves specific settings for a given site. ### Method GET ### Endpoint /graphql ### Query Parameters - **siteId** (String!) - Required - The ID of the site. - **settings** ([String]) - Optional - A list of setting keys to retrieve. ### Response #### Success Response (200) - **settings** ([SettingGQLType]) - A list of requested settings. ``` -------------------------------- ### Get Payment Schedule Template Source: https://docs.subsbase.com/api-and-webhooks/payment-schedules-apis Retrieves a specific payment schedule template by its ID for a given site. ```APIDOC ## GET /websites/subsbase/paymentScheduleTemplates/{paymentScheduleTemplateId} ### Description Retrieves a specific payment schedule template by its ID for a given site. ### Method GET ### Endpoint /websites/subsbase/paymentScheduleTemplates/{paymentScheduleTemplateId} ### Parameters #### Path Parameters - **paymentScheduleTemplateId** (String!) - Required - The ID of the payment schedule template to retrieve. #### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Request Example ```graphql query GetPaymentScheduleTemplate($siteId: String!, $paymentScheduleTemplateId: String!) { paymentScheduleTemplate(siteId: $siteId, paymentScheduleTemplateId: $paymentScheduleTemplateId) { id siteId name description rule { name operation } payments { order name intervalUnit intervalDuration percentageAmount } } } ``` ### Request Variables Sample ```json { "paymentScheduleTemplateId": "0ca585a2-0a6c-41e2-a345-57e6cc4ba436", "siteId": "test-site" } ``` ### Response #### Success Response (200) - **id** (String) - The unique identifier for the template. - **siteId** (String) - The ID of the site associated with the template. - **name** (String) - The name of the payment schedule template. - **description** (String) - A description of the template. - **rule** (Object) - The rule associated with the payment schedule. - **name** (String) - The name of the rule. - **operation** (String) - The operation defined by the rule. - **payments** (Array) - Details of payments within the schedule. - **order** (Int) - The order of the payment in the schedule. - **name** (String) - The name of the payment. - **intervalUnit** (String) - The unit of time for the payment interval (e.g., DAY, WEEK, MONTH). - **intervalDuration** (Int) - The duration of the payment interval. - **percentageAmount** (Float) - The percentage of the total amount to be paid. #### Response Example ```json { "id": "0ca585a2-0a6c-41e2-a345-57e6cc4ba436", "siteId": "test-site", "name": "Quarterly Billing", "description": "Quarterly payment schedule.", "rule": { "name": "Quarterly Rule", "operation": "Every 3 Months" }, "payments": [ { "order": 1, "name": "First Quarter Payment", "intervalUnit": "MONTH", "intervalDuration": 3, "percentageAmount": 100.0 } ] } ``` ``` -------------------------------- ### POST /core/v2/graphql - Get Payment Schedule Source: https://docs.subsbase.com/api-and-webhooks/payment-schedules-apis Retrieves details for a specific payment schedule by its unique identifier. ```APIDOC ## POST /core/v2/graphql ### Description Returns a specific payment schedule. You can specify any fields detailed in the PaymentScheduleGQLType. ### Method POST ### Endpoint https://api.subsbase.io/core/v2/graphql ### Request Body - **siteId** (String) - Required - The ID of the site. - **paymentScheduleId** (String) - Required - The unique identifier of the payment schedule. ### Request Example { "siteId": "test-site", "paymentScheduleId": "6660b866-51c5-494d-b3c2-4644f6247d00" } ``` -------------------------------- ### Create Customer Payment Schedules From Template Source: https://docs.subsbase.com/api-and-webhooks/customers-api Mutation to create a payment schedule for a customer using an existing template. ```APIDOC ## Create Customer Payment Schedules From Template ### Description Creates a payment schedule for a customer based on a pre-defined template. ### Method Mutation ### Endpoint N/A (GraphQL) ### Parameters #### Query Parameters None #### Request Body None ### GraphQL Mutation ```graphql mutation CreateCustomerPaymentSchedulesFromTemplate( $siteId: String! $customerId: String! $paymentScheduleFromTemplate: PaymentScheduleFromTemplateGQLInputType! ) { customer(siteId: $siteId, customerId: $customerId) { paymentSchedules { createFromTemplate( paymentScheduleFromTemplate: $paymentScheduleFromTemplate ) { isSuccess message } } } } ``` ### Variables Sample ```json { "siteId": "test-site", "customerId": "test-site_341f7f56d2304428a19c85b6d6274322", "paymentScheduleFromTemplate": { "paymentScheduleTemplateId": "b54b9110-2627-45fd-a6d8-fa9374cb4578", "customerId": "test-site_341f7f56d2304428a19c85b6d6274322", "baseDate": "2023-02-28T22:00:00.000Z", "baseAmount": 20, "currencyCode": "egp", "product": "test-schedule-payment2", "selectedPaymentMethodId":"9392e570-f006-41c0-bbba-8705ce0030b8" } } ``` ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the creation was successful. - **message** (String) - A message detailing the outcome of the operation. #### Response Example ```json { "data": { "customer": { "paymentSchedules": { "createFromTemplate": { "isSuccess": true, "message": "Payment schedule created from template successfully." } } } } } ``` ``` -------------------------------- ### Get Draft Invoices Source: https://docs.subsbase.com/api-and-webhooks/invoices-api Query to retrieve a list of draft invoices with optional filtering, pagination, and sorting. ```APIDOC ## Get Draft Invoices ### Description Returns an array of draft invoices. You can specify any of the fields detailed in the Draft Invoice Type Definition. For details about Pagination, Sorting, and Filtering Input Types, please check out PaginationGQLInputType, SortingGQLInputType, FilteringGQLInputType. ### Method Query ### Endpoint N/A (GraphQL Query) ### Parameters #### Query Parameters - **siteId** (String!) - Required - The ID of the site. - **filter** (FilterGQLInputType) - Optional - Filters for the draft invoices. - **pagination** (PaginationGQLInputType) - Optional - Pagination settings. - **sorting** (Array) - Optional - Sorting criteria. ### Request Example ```json { "siteId": "test-site" } ``` ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the operation was successful. - **data** (Array) - An array of draft invoice objects. - **message** (String) - A message describing the result of the operation. #### Response Example ```json { "isSuccess": true, "data": [ { "id": "some-draft-invoice-id", "siteId": "test-site" // ... other properties from DraftInvoiceGQLType } ], "message": "Draft invoices retrieved successfully." } ``` ``` -------------------------------- ### Settings and Configuration Models Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Definitions for global settings, site-specific settings, and email configuration inputs. ```APIDOC ## Settings Models ### GlobalSettingGQLType - **data** (String!) - Setting data - **id** (String!) - Unique identifier ### EmailSettingsGQLInputType - **settings** (String!) - Configuration settings - **useApi** (Boolean!) - Enable API usage - **useSmtp** (Boolean!) - Enable SMTP usage ``` -------------------------------- ### Authentication Header Example Source: https://docs.subsbase.com/api-and-webhooks/authentication All requests to the Subsbase API must include an Authorization header with a JWT token. ```APIDOC ## POST /core/v2/graphql ### Description This is an example of how to include the Authorization header for API requests. ### Method POST ### Endpoint https://api.subsbase.io/core/v2/graphql ### Parameters #### Headers - **Authorization** (string) - Required - Bearer {your received jwt goes here} ``` -------------------------------- ### POST /graphql - Create Customer Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Creates a new customer record in the system. ```APIDOC ## POST /graphql ### Description Creates a new customer record. ### Method POST ### Endpoint /graphql ### Request Body - **customer** (CustomerGQLInputType) - Required - The customer object to create. ### Response #### Success Response (200) - **ResultGQLType_Customer** (Object) - The created customer result. ``` -------------------------------- ### Billing Cycle Type Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Represents a billing cycle, including its start and end dates, and associated plan subscription. ```graphql type BillingCycleGQLType { data: BillingCycleDataGQLType end: DateTime id: ID index: Int invoiceId: String nextBillingCycleId: ID planSubscription: SubscriptionGQLType planSubscriptionId: String siteId: String! start: DateTime } ``` -------------------------------- ### Get Dunning Profiles Source: https://docs.subsbase.com/api-and-webhooks/payment-schedules-apis Retrieves a list of dunning profiles for a given site, supporting pagination, sorting, and filtering. ```APIDOC ## GET /websites/subsbase/dunningProfiles ### Description Retrieves a list of dunning profiles for a given site. Supports pagination, sorting, and filtering. ### Method GET ### Endpoint /websites/subsbase/dunningProfiles ### Parameters #### Query Parameters - **siteId** (String!) - Required - The ID of the site. - **filter** (FilterGQLInputType) - Optional - Allows filtering of the results. - **pagination** (PaginationGQLInputType) - Optional - Controls pagination for the results. - **sorting** (Array) - Optional - Specifies the sorting order for the results. ### Request Example ```graphql query GetDunningProfiles($siteId: String!, $filter: FilterGQLInputType, $pagination: PaginationGQLInputType, $sorting: [SortingGQLInputType]) { dunningProfiles(siteId: $siteId, filter: $filter, pagination: $pagination, sorting: $sorting) { isSuccess message pagination { page perPage totalRecords } data { id siteId name dunningFailAction trials { index trialDelayInDays trialPercentage template } } } } ``` ### Request Variables Sample ```json { "siteId": "test-site", "pagination": { "perPage": 10, "page": 1 }, "sorting": [ { "field": "name", "direction": "Ascending" } ], "filter": null } ``` ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the operation was successful. - **message** (String) - A message describing the result of the operation. - **pagination** (Object) - Pagination details. - **page** (Int) - The current page number. - **perPage** (Int) - The number of records per page. - **totalRecords** (Int) - The total number of records available. - **data** (Array) - An array of dunning profiles. - **id** (String) - The unique identifier for the dunning profile. - **siteId** (String) - The ID of the site associated with the profile. - **name** (String) - The name of the dunning profile. - **dunningFailAction** (String) - The action to take when dunning fails. - **trials** (Array) - Details of dunning trials. - **index** (Int) - The index of the trial. - **trialDelayInDays** (Int) - The delay in days before the trial. - **trialPercentage** (Float) - The percentage applied during the trial. - **template** (String) - The template used for the trial notification. #### Response Example ```json { "isSuccess": true, "message": "Successfully retrieved dunning profiles.", "pagination": { "page": 1, "perPage": 10, "totalRecords": 5 }, "data": [ { "id": "dp_abc123", "siteId": "test-site", "name": "Standard Dunning", "dunningFailAction": "Cancel Subscription", "trials": [ { "index": 1, "trialDelayInDays": 3, "trialPercentage": 90.0, "template": "dunning_email_1" } ] } ] } ``` ``` -------------------------------- ### GQL Queries - Currency Settings Source: https://docs.subsbase.com/api-and-webhooks/graphql-schema-v2 Retrieves currency settings for a given site. ```APIDOC ## GET /graphql ### Description Retrieves currency settings for a given site. ### Method GET ### Endpoint /graphql ### Query Parameters - **siteId** (String!) - Required - The ID of the site. ### Response #### Success Response (200) - **currencySettings** (SettingGQLType) - The currency settings. ``` -------------------------------- ### Customers API - GetAddOns Query Source: https://docs.subsbase.com/api-and-webhooks/customers-api Fetches a list of addons available for a site. Supports filtering, pagination, and sorting. ```APIDOC ## GET /addons ### Description Retrieves a list of addons associated with a specific site. This query supports filtering, pagination, and sorting for comprehensive addon management. ### Method POST ### Endpoint `https://api.subsbase.io/core/v2/graphql` ### Parameters #### Query Parameters - **siteId** (String!) - Required - The ID of the site. - **filter** (FilterGQLInputType) - Optional - Criteria to filter the addons. - **pagination** (PaginationGQLInputType) - Optional - Controls the pagination of the results. - **sorting** (Array of SortingGQLInputType) - Optional - Specifies the order of the results. ### Request Example ```graphql query GetAddons($siteId: String!, $filter: FilterGQLInputType, $pagination: PaginationGQLInputType, $sorting: [SortingGQLInputType]) { addons(siteId: $siteId, filter: $filter, pagination: $pagination, sorting: $sorting) { isSuccess data { id # All properties are found in the AddonGQLType } message } } ``` ### Variables Sample ```json { "siteId": "test-site" } ``` ### Response #### Success Response (200) - **isSuccess** (Boolean) - Indicates if the query was successful. - **data** (Array of AddonGQLType) - An array of addon objects. - **message** (String) - A message describing the result of the query. ``` -------------------------------- ### Transactions API - Get Transaction Query Source: https://docs.subsbase.com/api-and-webhooks/transactions-api This query retrieves details for a specific transaction using its unique ID. ```APIDOC ## POST /core/v2/graphql ### Description Retrieves the details of a single transaction based on the provided site ID and transaction ID. ### Method POST ### Endpoint https://api.subsbase.io/core/v2/graphql ### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **X-SITE-ID** (string) - Required - The ID of the site for which to retrieve data. ### Request Body This endpoint accepts GraphQL queries and mutations. ### Request Example ```graphql query GetTransaction($siteId: String!, $transactionId: String!) { transaction(siteId: $siteId, transactionId: $transactionId) { amount currency referenceNumber gatewayResponse id invoice { id number } paymentMethodTransactionSource { id displayText isDefault type } walletTransactionSource { id displayText type } status timestamp utcTimestamp type customer { customerId fullName } } } ``` ### Variables Sample ```json { "siteId": "test-site", "transactionId": "tx_test-site_17191597036254857390" } ``` ### Response #### Success Response (200) - **amount** (float) - The transaction amount. - **currency** (string) - The currency of the transaction. - **referenceNumber** (string) - The reference number for the transaction. - **gatewayResponse** (string) - The gateway's response for the transaction. - **id** (string) - The unique identifier for the transaction. - **invoice** (object) - Details about the associated invoice. - **id** (string) - The ID of the invoice. - **number** (string) - The invoice number. - **paymentMethodTransactionSource** (object) - Details about the payment method source. - **id** (string) - The ID of the payment method source. - **displayText** (string) - A display-friendly name for the payment method source. - **isDefault** (boolean) - Indicates if this is the default payment method source. - **type** (string) - The type of payment method source. - **walletTransactionSource** (object) - Details about the wallet transaction source. - **id** (string) - The ID of the wallet transaction source. - **displayText** (string) - A display-friendly name for the wallet transaction source. - **type** (string) - The type of wallet transaction source. - **status** (string) - The status of the transaction. - **timestamp** (integer) - The transaction timestamp. - **utcTimestamp** (integer) - The transaction timestamp in UTC. - **type** (string) - The type of transaction. - **customer** (object) - Details about the customer. - **customerId** (string) - The customer ID. - **fullName** (string) - The full name of the customer. #### Response Example ```json { "data": { "transaction": { "amount": 50.00, "currency": "USD", "referenceNumber": "ref12345", "gatewayResponse": "Approved", "id": "tx_abcde", "invoice": { "id": "inv_1", "number": "INV-001" }, "paymentMethodTransactionSource": { "id": "pm_1", "displayText": "Credit Card", "isDefault": true, "type": "CARD" }, "walletTransactionSource": null, "status": "completed", "timestamp": 1678886400, "utcTimestamp": 1678886400, "type": "payment", "customer": { "customerId": "cust_1", "fullName": "John Doe" } } } } ``` ``` -------------------------------- ### Get Billing Cycles Query Source: https://docs.subsbase.com/api-and-webhooks/billing-cycles-api Retrieves an array of billing cycles based on provided filters, pagination, and sorting. ```graphql query GetBillingCycles($siteId: String!,$filter: FilterGQLInputType,$pagination: PaginationGQLInputType,$sorting: [SortingGQLInputType]) { billingCycles (siteId: $siteId,filter: $filter,pagination: $pagination,sorting: $sorting) { isSuccess data{ id #All properties are found in the BillingCycleGQLType } message } } ``` ```json // Variables Sample: {"siteId":"test-site" } ```