Billing Topup
POST /api/billing/topup
Creates a checkout session for a prepaid top-up and returns its URL, session ID, and amount in cents. The return URL must use HTTPS and an allowed dashboard host. The configured minimum amount is at least 2500 cents; the maximum is 200000 cents. Include a valid topup_nonce with each request. Requires an authenticated user. Bearer access tokens need the billing.write ability, and the associated account needs the billing.change permission. The * wildcard also satisfies the bearer ability check. Browser session authentication uses the account permission check without a token-ability check. API-key credentials are not accepted. A bearer token missing its ability receives a 403 JSON body with error: "token_ability_missing", required: ["billing.write"], and have.
Authenticate with a portal session token.
Request body
application/json object
amount_centsinteger requiredRange: 2500 to 200000return_urlstring (uri) requiredLength: at most 2048 characterstopup_noncestring requiredA client-generated nonce containing 16 to 64 letters, digits, underscores, or hyphens.
Length: 16 to 64 characters. Pattern:^[A-Za-z0-9_-]{16,64}$
Generated sample
{
"amount_cents": 2500,
"return_url": "https://example.com",
"topup_nonce": "string"
}Responses
200 Checkout session created.
application/json object
amount_centsinteger requiredcheckout_urlstring (uri) requiredsession_idstring required
Generated sample
{
"amount_cents": 0,
"checkout_url": "https://example.com",
"session_id": "string"
}401 Authentication is missing or invalid.
application/json object
errorobject requiredcodestring requiredValue:"unauthenticated"messagestring required
403 The bearer token lacks the required ability or the authenticated account lacks the required permission.
application/json any
Any of
- object
errorstring requiredValue:"token_ability_missing"havearray of string requiredmessagestring requiredrequiredarray of string required
- object
messagestring required
409 The Idempotency-Key cannot be used for this request because it conflicts with another request (idempotency_key_conflict), is still in progress (idempotency_request_in_progress), or its response was not retained (idempotency_response_not_retained).
application/json IdempotencyError
errorobject requiredcodestring requiredOne of:"idempotency_key_conflict","idempotency_request_in_progress","idempotency_response_not_retained"messagestring requiredtypestring requiredValue:"idempotency_error"
422 The amount, HTTPS return URL, billing details, nonce, or request fields are invalid.
application/json object
errorany requiredOne of
- string
- object
codestringfieldsobjectOther keys: array of string
messagestring
- object
codestringmessagestring
429 The request was rate limited. API-generated responses are JSON;
Response headers
Retry-Afterstring headerSeconds to wait before retrying, when provided.
X-RateLimit-Scopestring headerIdentifies the scope of the request limit, when provided.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
text/html string
502 The checkout session could not be created.
application/json object
errorobject requiredcodestring requiredValue:"stripe_error"messagestring required