Skip to content

Query API

Endpoint

POST /api/{database}/{table}

All verbs go through the same endpoint. The operation is defined in the request body.

Headers

http
Authorization: Bearer cxk_your_token_here
Content-Type: application/json

Request body

ts
{
  verb:    "select" | "insert" | "update" | "delete",  // required
  data?:   { [column: string]: any },  // insert / update
  filters?: { [column: string]: any }, // update / delete / select
  columns?: string[],                  // select — columns to return
  limit?:   number,                    // select — max rows (default 100, max 1000)
  orderBy?: string,                    // select — e.g. "created_at DESC"
}

SELECT

Fetch rows from a table.

json
POST /api/mydb/users

{
  "verb": "select",
  "filters": { "active": true },
  "columns": ["id", "email", "name"],
  "limit": 20,
  "orderBy": "created_at DESC"
}

Response:

json
{
  "success": true,
  "data": {
    "rows": [
      { "id": 1, "email": "alice@example.com", "name": "Alice" }
    ],
    "count": 1
  }
}

TIP

Omit filters to return all rows (up to limit).


INSERT

Add a new row.

json
POST /api/mydb/users

{
  "verb": "insert",
  "data": {
    "email": "bob@example.com",
    "name": "Bob",
    "active": true
  }
}

Response:

json
{
  "success": true,
  "data": {
    "inserted": 1,
    "id": 42
  }
}

UPDATE

Modify existing rows. filters is required to prevent accidental full-table updates.

json
POST /api/mydb/users

{
  "verb": "update",
  "data":    { "active": false },
  "filters": { "id": 42 }
}

Response:

json
{
  "success": true,
  "data": { "updated": 1 }
}

DELETE

Remove rows. filters is required to prevent accidental full-table deletes.

json
POST /api/mydb/users

{
  "verb": "delete",
  "filters": { "id": 42 }
}

Response:

json
{
  "success": true,
  "data": { "deleted": 1 }
}

Notes

  • All verbs require the token to have the matching permission
  • update and delete without filters return 400 Bad Request
  • limit maximum is 1,000 rows per request
  • Column names in filters are case-sensitive and must match the table schema