Create Subscription
Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Headers
A unique key for making the request idempotent. Must match pattern: ^[a-zA-Z0-9\-_:\.]+$. See Idempotent Requests for more details.
255^[a-zA-Z0-9\-_:\.]+$Body
Create Subscription
The amount in lowest count unit. e.g.: For USD 1, amount is 100 representing 100 cents (The minimum amount should be greater than 1 USD)
100
Three letter abbreviation of the currency. Refer supported currencies
"USD"
Billing details for the customer.
The URL we will callback to with the order status once it finishes.
"https://example.com/callback"
The interval group between subscriptions.
DAY, WEEK, MONTH, YEAR "MONTH"
The number of intervals between subscription billings. For example, interval = MONTH and intervalCount = 3 bills every 3 months.
2
The number of billing cycles for which the subscription will renew before ending. The first cycle is included in this count.
2
Your identifier of the order
"order123"
The URL to redirect the customer to when they cancel the subscription. If not provided, the callbackUrl will be used as fallback.
"https://example.com/cancel"
An optional amount that merchants can set to be charged to the customer at the time the subscription is activated. This amount replaces the first billing cycle charge — the regular subscription amount is not added on top of it. Regular billing resumes from the next cycle.
The amount is in the lowest count unit. e.g.: For USD 1, amount is 100 representing 100 cents (minimum amount should be greater than 1 USD).
Validation Rules:
- Not compatible with
trialPeriodCountandtrialPeriodInterval— cannot be provided simultaneously
x >= 1200
The number of trial periods before the first billing cycle. Must be greater than or equal to 0 if provided.
Validation Rules:
- If
trialPeriodCountis provided,trialPeriodIntervalmust also be provided trialPeriodCountis not compatible withupfrontAmount- both cannot be provided simultaneously
x >= 07
The interval for the trial period.
Validation Rules:
- Required when
trialPeriodCountis provided
DAY, WEEK, MONTH, YEAR "DAY"
A collection of key-value pairs that can be attached to an object for storing additional structured information. This is useful for capturing custom data or context-specific attributes.
Constraints:
- Maximum of 50 key-value pairs allowed.
- Each key must be no longer than 40 characters.
- Each value must be a string and cannot exceed 500 characters.
Flag to indicate whether phone number is required from the customer during checkout. By default, this is false.
false
The unique identifier for the customer, generated via the create-customer API. This can be used to associate the payment with a specific customer in your system.
"cus_Tfd3Jq1tZxPjYVhRQW2r3"
Product Page - showcases more about the product on the checkout page
Response
Create Subscription response
Unique identifier of the subscription
"sub_fooBOwYsaK50AEfK"
Timestamp of when the subscription was created
"2024-09-26T10:41:50.472+00:00"
The URL to redirect the customer to the xPay payment gateway for payment.
"https://pay.xpaycheckout.com/?subscription_id=67f53a6e2097773e4f0112c8"