Skip to content
Sign in Create account

Billing Topup

POST /api/v1/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_cents integer required
    Range: 2500 to 200000
  • return_url string (uri) required
    Length: at most 2048 characters
  • topup_nonce string required

    A 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_cents integer required
  • checkout_url string (uri) required
  • session_id string required

Generated sample

{
  "amount_cents": 0,
  "checkout_url": "https://example.com",
  "session_id": "string"
}
401 Authentication is missing or invalid.

application/json object

  • error object required
    • code string required
      Value: "unauthenticated"
    • message string required
403 The bearer token lacks the required ability or the authenticated account lacks the required permission.

application/json any

Any of

  • object
    • error string required
      Value: "token_ability_missing"
    • have array of string required
    • message string required
    • required array of string required
  • object
    • message string 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

  • error object required
    • code string required
      One of: "idempotency_key_conflict", "idempotency_request_in_progress", "idempotency_response_not_retained"
    • message string required
    • type string required
      Value: "idempotency_error"
422 The amount, HTTPS return URL, billing details, nonce, or request fields are invalid.

application/json object

  • error any required

    One of

    • string
    • object
      • code string
      • fields object

        Other keys: array of string

      • message string
    • object
      • code string
      • message string
429 The request was rate limited. API-generated responses are JSON;

Response headers

  • Retry-After string header

    Seconds to wait before retrying, when provided.

  • X-RateLimit-Scope string header

    Identifies the scope of the request limit, when provided.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

text/html string

502 The checkout session could not be created.

application/json object

  • error object required
    • code string required
      Value: "stripe_error"
    • message string required