Skip to content
TriedDocs
Account

Create checkout

Start a credit purchase on a Stripe Checkout page.

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

Starts a one-off credit purchase. It creates a Stripe Checkout session in payment mode and returns its URL. Admin only.

Request#

Field Type Required Description
amount number Yes AUD to buy, 5 to 10000.

Example request#

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

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

Response#

200 OK

{
  "provider": "stripe",
  "url": "https://checkout.stripe.com/c/pay/cs_live_a1B2c3D4e5F6g7H8",
  "reference": "cs_live_a1B2c3D4e5F6g7H8"
}
Field Type Description
provider string stripe.
url string Stripe Checkout URL to redirect the user to.
reference string Stripe Checkout session ID.

After payment, Stripe returns the user to the dashboard at /billing?checkout=success. Cancelling returns to /billing.

Errors#

Status When
400 Validation failed, for example amount: Required.
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.

To save a card instead of buying credits, use Create checkout session with mode: "setup".