Skip to main content
POST
Create a checkout session

Authorizations

X-Suby-Api-Key
string
header
required

Secret API key. sk_live_… (production) or sk_sandbox_… (sandbox).

Headers

Idempotency-Key
string

Optional key (≤255 chars, e.g. a UUID v4) making this POST safe to retry · the response is cached 24h and a retry with the SAME key replays it instead of re-executing. The same key with a different body → 422 IDEMPOTENCY_KEY_CONFLICT; a retry while the first is in flight → 409.

Maximum string length: 255
Example:

"5f3b9c2e-1a4d-4f2b-9c31-7e2a1b6d8c04"

Body

application/json

mode=payment takes exactly ONE pricing intent · productId, lineItems (no recurring product in a basket) or priceCents + currency. mode=subscription takes productId alone. mode=setup takes none and rejects lineItems, priceCents, currency, discountCode and taxBehavior · its productId names, it does not price.

mode
enum<string>
required

payment one-time charge · subscription opens a subscription and bills cycle 1 · setup stores a card without charging.

Available options:
payment,
subscription,
setup
successUrl
string<uri>
required

Redirect after a successful payment.

cancelUrl
string<uri>
required

Redirect if the payer cancels.

productId
string

Pricing intent A · a single product. Exclusive with lineItems / priceCents. On mode=setup it names rather than prices.

Example:

"pro_abc123"

lineItems
object[]

Pricing intent B · 1–20 product lines charged as one Payment. Exclusive with productId / priceCents.

Required array length: 1 - 20 elements
priceCents
string

Pricing intent C · ad-hoc amount in minor units, string of digits. Requires currency. Exclusive with productId / lineItems.

Pattern: ^[1-9]\\d*$
Example:

"1999"

currency
string

ISO 4217. Required with priceCents.

Pattern: ^[A-Z]{3}$
displayName
string

Label on the hosted page + Payment snapshot. Defaults to the product's (or the payment link's).

Maximum string length: 200
displayDescription
string | null

Copy under the label. Same fallback as displayName.

Maximum string length: 500
taxBehavior
enum<string>

MoR VAT · exclusive adds VAT on top, inclusive extracts it. Signed into the session. Defaults to the product's; with lineItems or a bare priceCents, to exclusive · a basket consults none of its lines, so a bundle of TTC prices must say inclusive. Inert on crypto.

Available options:
inclusive,
exclusive
customer
object

Optional · the hosted page collects the identity otherwise. id binds the session to a known customer, email only pre-fills.

discountCode
string

Pre-apply a promo code. Validated here and again at pay · an unknown, deactivated, expired, exhausted, wrong-currency or non-applicable code is rejected 422 DISCOUNT_CODE_* rather than signed into the session and silently dropped at payment time.

Maximum string length: 40
savePaymentMethod
boolean
default:false

Store the card once the charge captures, for later off-session debits. mode=payment only · a setup session does this by definition.

metadata
object

Key-value pairs. ≤50 keys, keys ≤40 chars, values are strings ≤500 chars (or null to clear). Nested structures must be JSON-stringified into a single string value.

customFields
object[]

Extra fields collected on the hosted checkout page (max 10).

Maximum array length: 10
expiresIn
integer

Session TTL in seconds (default 24h, max 7d).

Required range: 60 <= x <= 604800

Response

Checkout session created

success
boolean
required
Example:

true

data
object
required

Endpoint-specific payload.

message
string