Data API

Data API overview

Every exposed table is served at /rest/v1/{table} on your project host. Two headers on every request: the publishable key and the user’s JWT.

The request shape

PieceValuePurpose
Hosthttps://{slug}.api.cubibase.comSelects the project
Path/rest/v1/{table}Selects the exposed table
apikey headerPublishable key (cb_pub_…)Identifies the project credential
Authorization headerBearer <USER_JWT>Identifies the end user
Request
GET https://example-project.api.cubibase.com/rest/v1/customers?plan=eq.pro&order=name.asc&limit=20
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT>
200 · response
{
  "data": [
    {
      "id": "8c1a0b2e-7d44-4a11-9c31-0b51a6e4d901",
      "name": "Mina Cho",
      "email": "mina@example.com",
      "plan": "pro",
      "owner_id": "user_mina"
    },
    {
      "id": "44ab91c3-0e55-4d72-b018-6f2c8a91bb70",
      "name": "Priya Shah",
      "email": "priya@example.org",
      "plan": "pro",
      "owner_id": "user_priya"
    }
  ]
}

Response envelope

Every successful response wraps its payload in a data field. Lists return an array; single rows and writes return one object.

CallStatusdata contains
GET /rest/v1/{table}200An array of rows (possibly empty)
GET /rest/v1/{table}/{id}200One row object
POST /rest/v1/{table}201The inserted row, all columns
PATCH /rest/v1/{table}/{id}200The updated row, all columns
DELETE /rest/v1/{table}/{id}200The deleted row, all columns
POST /rest/v1/rpc/{function}200The function result: a value, an object, or an array

Errors

Errors are JSON objects with a stable code, a human message, and a requestId you can match against the project logs.

401 · missing bearer token
{
  "error": {
    "code": "missing_end_user_token",
    "message": "An end-user bearer token is required",
    "requestId": "req_example"
  }
}
StatusCodeMeaning
401missing_api_key / invalid_api_keyThe publishable key is absent or wrong
401missing_end_user_token / invalid_tokenThe bearer JWT is absent or fails verification
404not_foundUnknown table, unexposed table, or missing row
405method_not_allowedThat operation is not exposed for the table

What the API does not do

  • No joins or nested resources: one table request addresses one table. Logic that spans tables belongs in a function, called over RPC.
  • No bulk writes: POST inserts one row; PATCH and DELETE address one primary key.
  • No arbitrary SQL from the application — the SQL editor is a Console tool. Functions you write and grant are the supported way to run custom logic.
  • Tables with composite primary keys are not served by the row-by-id routes.

Additional resources