Skip to content
POST /billing/checkout-top-up-session

Returns a Stripe Checkout session to buy credits now (hosted url, or with ui_mode elements a client_secret for Stripe's Elements in the app). For teams whose usage is paid from a prepaid balance (usage_payment prepaid). The Checkout takes amount_cents in payment mode for the team's Stripe customer; the card paid with is saved for later top-ups and becomes the default. Once paid, the balance is credited with the amount, once, and the payment gets its own Stripe invoice. Credits bought never count toward the spend limit, and change no plan.

Request Body

amount_centsinteger

What to buy, in whole dollars ($50 to $10,000).

cancel_urlstring

hosted only. Must be on the app origin. Defaults to the Billing settings page.

return_urlstring

elements only. Must be on the app origin. Defaults to the Billing settings page.

success_urlstring

hosted only. Must be on the app origin. Defaults to the Billing settings page.

team_idstring · uuid

The team; or send it as the team_id query parameter.

ui_modestring

hosted returns url, Stripe's own page. elements returns client_secret, publishable_key and consent_text, for the app to show Stripe's Payment and Express Checkout Elements itself (Stripe.js initCheckoutElementsSdk) and confirm in place; it leaves the app only for a payment method that must redirect, to return_url.

Possible values:
hostedelements

Response Body

amount_centsinteger

What the Checkout charges, in cents.

Example: 12000
client_secretstring

Starts Stripe's Elements (ui_mode elements, Stripe.js initCheckoutElementsSdk); null when hosted.

consent_textstring

What the payer agrees to. Stripe shows it on its hosted page; with elements the app must show it by its Pay button.

publishable_keystring

The Stripe publishable key to start Stripe.js with; null when hosted.

session_idstring
Example: cs_test_a1b2c3
urlstring

Stripe's hosted page (ui_mode hosted); null for elements.

Errors

StatusDescription
400amount_cents missing, out of range or not whole dollars, or a redirect URL is not on the app origin or is for the other ui_mode
403Forbidden if the caller is not an admin of the team
409The team does not pay usage from a prepaid balance (or has no billing account or Stripe customer), is on the Free plan (it adds a card by paying, with POST /billing/checkout-setup-session), or an earlier credits Checkout of this team is still being confirmed
503Billing is not configured on this deployment (STRIPE_SECRET_KEY unset), or ui_mode elements was asked for and STRIPE_PUBLISHABLE_KEY is unset
curl -X POST 'https://api.truto.one/billing/checkout-top-up-session' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "team_id": "your_team_id",
  "amount_cents": 0,
  "ui_mode": "hosted",
  "success_url": "your_success_url",
  "cancel_url": "your_cancel_url",
  "return_url": "your_return_url"
}'
const body = {
  "team_id": "your_team_id",
  "amount_cents": 0,
  "ui_mode": "hosted",
  "success_url": "your_success_url",
  "cancel_url": "your_cancel_url",
  "return_url": "your_return_url"
};

const response = await fetch('https://api.truto.one/billing/checkout-top-up-session', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
import requests

url = "https://api.truto.one/billing/checkout-top-up-session"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "team_id": "your_team_id",
    "amount_cents": 0,
    "ui_mode": "hosted",
    "success_url": "your_success_url",
    "cancel_url": "your_cancel_url",
    "return_url": "your_return_url"
}

response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())