Skip to main content
The /api/database/* endpoints are a thin proxy over PostgREST, scoped to your project’s public schema. They use the same operators and conventions as PostgREST under the hood. Every call requires the project’s service role key: a signed-in user’s access token gets 403 (see Which key for which route). The proxy calls PostgREST with the service role key, so RLS doesn’t filter what it returns; for per-user reads under RLS, call PostgREST directly with the user’s access token. System schemas (ai, auth, storage, pg_catalog, information_schema, etc.) are blocked at this layer — those are managed via dedicated routes (/api/agents, /api/knowledge-bases, …). When you need the full PostgREST query language (filter operators, embedded relations, ordering, RPC calls), use the PostgREST endpoints instead. Use this proxy from your backend when you want one auth model across all platform calls and don’t need the full PostgREST surface.

Common Patterns

Discover tables with GET /tables, then read or mutate rows by primary key. The /openapi endpoint returns the project’s full PostgREST OpenAPI spec — useful for UIs that render an API reference for user-defined tables.

GET /api/database/tables

List tables in the schema (only public is currently allowed). Returns { "tables": ["users", "orders", ...] }.
string
Defaults to public. Any other value returns 400.

GET /api/database/tables/

List rows from a table via PostgREST. Supports limit (default 50) and offset query parameters.
string
required
Table name in the public schema. Must match ^[A-Za-z_][A-Za-z0-9_]*$.
integer
Defaults to 50.
integer
Defaults to 0.
string
Defaults to public.

GET /api/database/tables//

Fetch a single row by id. Returns the row as a JSON object (uses PostgREST’s Accept: application/vnd.pgrst.object+json).
string
required
Table name
string
required
Row primary key
string
Defaults to public.

POST /api/database/tables/

Insert a row. The body is forwarded to PostgREST with Prefer: return=representation, so the response contains the inserted row.
string
required
Table name

PATCH /api/database/tables//

Update a row by id. Returns the updated row.
string
required
Table name
string
required
Row primary key

DELETE /api/database/tables//

Delete a row by id.
string
required
Table name
string
required
Row primary key

GET /api/database/openapi

Return the project’s full PostgREST OpenAPI/Swagger spec. The frontend uses this to render an API reference for user-defined tables; you can use it to drive a settings UI or to introspect the schema programmatically.

Error Responses

Errors from this proxy return {"error": "<message>"}. Errors from the upstream PostgREST/Postgres are forwarded verbatim with their original status code.