Skip to content

Create Stripe Checkout session to add a payment method

POST /billing/checkout-setup-session

Returns a Stripe Checkout URL in setup mode to save a card for automatic payment of future invoices. Redirect the browser to url; on completion Stripe returns to success_url and Truto marks the card as the customer's default payment method.

Request Body

cancel_urlstring

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

success_urlstring

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

team_idstring · uuid

Response Body

session_idstring
Example: cs_test_a1b2c3
urlstring

Errors

StatusDescription
400A redirect URL is not on the app origin
403Forbidden if the caller is not an admin of the team
404The team has no Stripe customer yet
503Billing is not configured on this deployment (STRIPE_SECRET_KEY unset)
curl -X POST 'https://api.truto.one/billing/checkout-setup-session' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "team_id": "your_team_id",
  "success_url": "your_success_url",
  "cancel_url": "your_cancel_url"
}'
const body = {
  "team_id": "your_team_id",
  "success_url": "your_success_url",
  "cancel_url": "your_cancel_url"
};

const response = await fetch('https://api.truto.one/billing/checkout-setup-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-setup-session"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "team_id": "your_team_id",
    "success_url": "your_success_url",
    "cancel_url": "your_cancel_url"
}

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