Data API

Writing rows

POST inserts one row, PATCH updates one row by primary key, DELETE removes it. Each returns the affected row with every column.

Insert a row

POST /rest/v1/{table} with a JSON object of column values. Columns with defaults can be omitted. The response is 201 with the full inserted row.

Insert · request
POST https://example-project.api.cubibase.com/rest/v1/customers
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT>
Content-Type: application/json

{
  "name": "Mina Cho",
  "email": "mina@example.com",
  "plan": "pro",
  "owner_id": "<USER_ID>"
}

Update a row

PATCH /rest/v1/{table}/{id} with the fields to change. Only the listed columns are touched; the response is the full updated row.

Update · request
PATCH https://example-project.api.cubibase.com/rest/v1/customers/8c1a0b2e-7d44-4a11-9c31-0b51a6e4d901
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT>
Content-Type: application/json

{
  "plan": "team"
}

Delete a row

DELETE /rest/v1/{table}/{id} removes the row and returns it in data. A row that does not exist — or is hidden by the user’s policy — returns 404 not_found.

Delete · request
DELETE https://example-project.api.cubibase.com/rest/v1/customers/8c1a0b2e-7d44-4a11-9c31-0b51a6e4d901
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT>

Constraint errors

PostgreSQL constraints surface as stable error codes, so your app can react without parsing messages:

StatusCodeCause
409conflictUnique constraint violated (e.g. duplicate email)
400not_null_violationA required column was omitted
409foreign_key_violationA referenced row does not exist
400check_violationA value failed a check constraint
400invalid_inputA value does not fit the column type
403forbiddenThe row policy rejected the write

Additional resources