Skip to content
TriedDocs
Account

Create checkout session

Create a Stripe Checkout session to save a card or buy credits.

POSThttps://api.tried.com.au/billing/checkout-session

Needs keys Creates a hosted Stripe Checkout session for the workspace's Stripe customer. setup mode saves a card; payment mode buys credits and saves the card for off-session use; the credit is added when the Stripe webhook reports the paid session. Needs STRIPE_SECRET_KEY. Without it, the mock returns a dashboard URL and makes no Stripe call. Admin only.

Request#

Field Type Required Description
mode string No setup or payment. Default setup.
amount number No AUD for payment mode, 5 to 10000. Default 20.

Example request#

curl -X POST https://api.tried.com.au/billing/checkout-session \
  -H "Authorization: Bearer $TRIED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "setup"
  }'
const res = await fetch("https://api.tried.com.au/billing/checkout-session", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TRIED_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "mode": "setup"
  }),
});
const session = await res.json();
import os, requests

res = requests.post(
    "https://api.tried.com.au/billing/checkout-session",
    headers={"Authorization": f"Bearer {os.environ['TRIED_API_KEY']}"},
    json={
        "mode": "setup",
    },
)
session = res.json()

Response#

200 OK

With Stripe:

{
  "mock": false,
  "provider": "stripe",
  "url": "https://checkout.stripe.com/c/pay/cs_live_b2C3d4E5f6G7h8I9",
  "session_id": "cs_live_b2C3d4E5f6G7h8I9"
}

In mock mode:

{
  "mock": true,
  "provider": "mock",
  "url": "https://app.tried.com.au/billing?checkout=success&mock=1",
  "session_id": "cs_mock_1b3d5f7a9c1e3b5d7f9a1c3e"
}

Redirect the user to url. Stripe returns them to /billing?checkout=success on the dashboard, or /billing?checkout=cancelled if they cancel.

Errors#

Status When
400 Validation failed, for example `mode: Invalid enum value. Expected 'setup'
401 Missing or invalid API key.
403 The key's IP allowlist or scopes reject the request. This route needs the admin scope. A dashboard user without the right role gets Requires role: admin. API keys act as admin.
429 Rate limit exceeded. See Rate limits.
500 Stripe rejected the request. Outside production the message is Stripe's error text.

See Errors for the body format.