Skip to content

API Reference — PostgreSQL Data API

REST CRUD and querying over SQL-backed collections, with PostgREST-style filtering, projection, ordering and keyset pagination. Every request is scoped to the caller's tenant by Row-Level Security (see Security).

Authenticate with an apikey header. Examples use $API (gateway host) and $KEY.

Endpoints

MethodPathPurpose
GET/v1/collections/{name}/documentsList / filter rows
POST/v1/collections/{name}/documentsCreate a row (document as JSON body)
PUT/v1/collections/{name}/documents/{id}Update a row
DELETE/v1/collections/{name}/documents/{id}Delete a row
POST/v1/collections/{name}/queryStructured query

Create

bash
curl -sX POST $API/v1/collections/orders/documents \
  -H "apikey: $KEY" -H 'content-type: application/json' \
  -d '{"customer":"acme","total":42.5,"status":"open"}'

Filtering

Query params are PostgREST-style column=operator.value; a bare column=value defaults to eq:

OperatorExample
eq, neq?status=eq.open
gt, gte, lt, lte?total=gte.100
in?id=in.(1,2,3)
like, ilike?name=ilike.%ac%
json_path_eq?meta=json_path_eq.…

Scalars are coerced: ?age=gte.18 compares as a number, ?active=eq.true as a boolean.

Projection & ordering

bash
curl -s "$API/v1/collections/orders/documents?select=id,total&order=total.desc" -H "apikey: $KEY"
  • select=col1,col2 — restrict returned columns.
  • order=col.asc|desc — sort.

Keyset (cursor) pagination

bash
# first page
curl -s "$API/v1/collections/orders/documents?page[size]=20" -H "apikey: $KEY"
# next page — pass the opaque cursor returned by the previous page
curl -s "$API/v1/collections/orders/documents?page[size]=20&page[after]=<cursor>" -H "apikey: $KEY"

Keyset pagination (not OFFSET) keeps paging stable and fast on large tables. The cursor is opaque (serializePostgresDataApiCursor); pass it back verbatim in page[after].

Structured query

For more complex reads use the query endpoint:

bash
curl -sX POST $API/v1/collections/orders/query \
  -H "apikey: $KEY" -H 'content-type: application/json' \
  -d '{"filter":{"status":"open"},"order":[["total","desc"]],"limit":50}'

Schema (DDL)

Defining collections/tables, columns and indexes is a structural_admin operation — create them from the console or via POST /v1/schemas (see Control Plane). The executor backs DDL with postgres-ddl-executor.mjs (schema/table/column/index).

Isolation

Reads and writes run under a non-BYPASSRLS role with the tenant set per request, so RLS filters every statement — you only ever see your tenant's rows, even via a misformed query.

Released under the MIT License.