Skip to main content
POST
cURL
Buys amountCents × creditsPerUsd / 100 credits (rounded down) for the customer, within the catalog’s topUps bounds.
  • paymentMethod: "checkout" (the default) answers the pending top-up with a checkoutUrl. The credits are granted when the customer pays.
  • paymentMethod: "saved" charges the default card now as a one-item invoice and answers the top-up succeeded, or 402 payment_failed or authentication_required (send the customer through Checkout instead). A customer with no saved card gets 400 no_payment_method.
An amount outside the bounds is 400 top_up_amount_out_of_range; without topUps in the catalog, 400 top_ups_not_configured. Needs the Billing permission.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
customerId
string
required

Your ID for the customer, such as your user ID.

Required string length: 1 - 255
amountCents
integer
required

What to charge, in US cents, within the catalog's topUps.minCents and maxCents. Buys amountCents × creditsPerUsd / 100 credits, rounded down.

Required range: x <= 99999999
paymentMethod
enum<string>

checkout (the default) answers a Stripe Checkout URL; saved charges the customer's default card now.

Available options:
checkout,
saved
successUrl
string

Checkout only: where Stripe sends the customer after paying. Overrides Settings › Checkout, with attach's rules.

Maximum string length: 2048
cancelUrl
string

Checkout only: where Stripe sends the customer if they leave. Overrides Settings › Checkout.

Maximum string length: 2048

Response

Saved card: the top-up, succeeded and granted. Checkout: the pending top-up with its checkoutUrl.

id
integer
required
customerId
string
required
status
enum<string>
required
Available options:
pending,
succeeded,
failed
failureReason
string | null
required
credits
integer
required
amountCents
integer
required
stripeInvoiceId
string | null
required
checkoutUrl
string | null
required

Checkout only: where to send the customer to pay.