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

KeyPrefixWhere it livesWhat it does
Publishablecb_pub_Your app (browser, mobile)Identifies the project on every Data API and Auth call
Secretcb_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.

Service request
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.

Every request carries both headers
GET https://example-project.api.cubibase.com/rest/v1/customers
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT>
SituationResponse
No apikey header401 missing_api_key
Key not valid for this project401 invalid_api_key
Valid key, no bearer token and no secret key401 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.

Additional resources