Skip to content
TriedDocs
Account

Create setup intent

Create a Stripe SetupIntent so the browser can save a card with Stripe Elements.

POSThttps://api.tried.com.au/billing/payment-methods/setup-intent

Needs keys Creates a Stripe SetupIntent for an off-session card. Confirm it in the browser with Stripe Elements and the returned publishable_key, then call Set default payment method with the new payment method. Needs STRIPE_SECRET_KEY; STRIPE_PUBLISHABLE_KEY fills publishable_key. The first call creates a Stripe customer for the workspace. Admin only.

Request#

This endpoint takes no path, query or body parameters.

Example request#

curl -X POST https://api.tried.com.au/billing/payment-methods/setup-intent \
  -H "Authorization: Bearer $TRIED_API_KEY"
const res = await fetch("https://api.tried.com.au/billing/payment-methods/setup-intent", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.TRIED_API_KEY}` },
});
const intent = await res.json();
import os, requests

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

Response#

200 OK

With Stripe:

{
  "mock": false,
  "provider": "stripe",
  "client_secret": "seti_1QxYz2AbCdEfGhIj_secret_Kl3Mn4Op5Qr6St7Uv",
  "setup_intent_id": "seti_1QxYz2AbCdEfGhIj",
  "publishable_key": "pk_live_51AbCdEf",
  "customer_id": "cus_QxYz2AbCdEfGhI"
}

In mock mode no Stripe call is made:

{
  "mock": true,
  "provider": "mock",
  "client_secret": "seti_mock_5e7a9c1b3d5f7a9c1e3b5d7f_secret_mock",
  "publishable_key": null,
  "customer_id": null
}

Errors#

Status When
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.