Also available: Markdown version · llms.txt · full site content
Platform
API keys
The publishable key identifies your project to the API. It is meant to live in your client — but it never authorizes rows by itself.
Two kinds of key
| Key | Prefix | Where it lives | What it does |
|---|---|---|---|
| Publishable | cb_pub_ | Your app (browser, mobile) | Identifies the project on every Data API and Auth call |
| Secret | cb_sec_ | Server-side only (trusted servers, AI agents) | Authenticates Data API and RPC calls as the service actor; shown once, stored hashed |
Using the secret key (service actor)
A secret key authenticates REST and RPC calls without an end-user JWT. Send it as the apikey header or as Authorization: Bearer. The request runs with cubibase.role = 'service' and an empty cubibase.user_id(). Row-level security still applies — a table without a service policy returns no rows.
GET https://example-project.api.cubibase.com/rest/v1/customers
apikey: cb_sec_…Grant service access explicitly with a policy, for example cubibase.current_role() = 'service' for SELECT, or keep service access limited to SECURITY DEFINER functions. Every service write is recorded in the audit log.
Using the publishable key
Send it in the apikey header on every request to the project host — Data API and Auth alike. The engine checks it against the project resolved from the host.
GET https://example-project.api.cubibase.com/rest/v1/customers
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT>| Situation | Response |
|---|---|
No apikey header | 401 missing_api_key |
| Key not valid for this project | 401 invalid_api_key |
| Valid key, no bearer token and no secret key | 401 missing_end_user_token |
Keeping keys safe
- The publishable key is public by design, but treat it as a project credential: it names your project to the API.
- Row access comes from the end-user JWT and the table’s policies — not from the key.
- Manage keys from Console → project → API keys: create, revoke, and rotate.
- If a key leaks and you want it dead, revoke it; requests using it fail immediately.