Create an organization token, provision a project for a customer with labels and limits, and use its keys.
#1. Create an organization token
Dashboard › Organization › API tokens › New token. Give it the scopes your backend needs, for example projects:write, database:write, usage:read and webhooks:write. Store it as a secret (STITCHDB_TOKEN).
#2. Create a project for a customer
Terminal
curl -X POST https://stitchdb.com/platform/v1/projects \
-H "Authorization: Bearer $STITCHDB_TOKEN" -H 'Content-Type: application/json' \
-H 'Idempotency-Key: customer-cus_123' \
-d '{
"name": "Acme todo app",
"labels": { "customer_id": "cus_123" },
"limits": { "db_size_mb": 200, "api_rps": 20, "auth_users": 1000 },
"template": { "sql": "create table public.todos (id bigint generated always as identity primary key, task text not null); alter table public.todos enable row level security;" }
}'The answer comes back at once with status: "provisioning", the ref, the API URL and the keys. Retrying with the same Idempotency-Key returns the same project.
#3. Wait until it is ready
Poll GET /projects/<ref> until status is active and template_status is ready (usually 5-15 s), or subscribe to the project.ready webhook.
#4. Use it
JavaScript
import { createClient } from 'stitchdb-js'
const db = createClient(project.api_url, project.anon_key)
await db.from('todos').insert({ task: 'First task' })Read its usage with GET /projects/<ref>/usage, change its limits with PATCH /projects/<ref>/limits, delete it with DELETE /projects/<ref>.