Database and REST
/rest/v1: PostgREST-style reads and writes under row-level security, with filters, embedding and upserts.
Your data is Postgres. Connect with any Postgres driver, ORM or psql:
- postgres mode: your own database URL;
- chronos mode:
postgres://app:<engine_token>@127.0.0.1:54329/main?sslmode=require(chronos.pg_listen). The password isengine_tokenfrom the data folder'ssecrets.json; any login name works exceptforkbase, the engine's own.
On top of it, /rest/v1/<table> serves the tables and views of rest.schemas over HTTP, the way PostgREST does. So
supabase-js works as is:
import { createClient } from "@supabase/supabase-js";
const supabase = createClient("http://127.0.0.1:8000", ANON_KEY);
const { data } = await supabase.from("notes").select("id, body, tags(name)").gt("n", 1).order("n", { ascending: false });Reads
GET /rest/v1/notes?select=id,body,tags(name)&n=gt.1&order=n.desc&limit=20&offset=40
apikey: <anon key>
Authorization: Bearer <access token> (when someone is signed in)select: columns,*, renames (title:body), and one level of embedding along single-column foreign keys either way:tags(name),note:notes(body),rel!column(...)when two keys join the same tables.order=col.asc|desc[.nullsfirst|.nullslast], several separated by commas.limit,offset. A read returns at mostrest.max_rows(1000).Prefer: count=exactadds the total toContent-Range.Accept: application/vnd.pgrst.object+jsonasks for exactly one row (406 otherwise).
Filters
column=operator.value:
| Operator | SQL |
|---|---|
eq, neq | =, <> |
gt, gte, lt, lte | >, >=, <, <= |
like, ilike | LIKE, ILIKE (* is %) |
is | IS NULL, IS TRUE, IS FALSE |
in | IN (...): id=in.(1,2,3) |
cs, cd | contains, contained by (arrays, JSON) |
not. before any operator negates it (status=not.eq.closed). Combine with
or=(a.eq.1,and(b.gt.2,c.is.null)).
Writes
POST /rest/v1/notes | insert one object or an array |
POST with Prefer: resolution=merge-duplicates | upsert; on_conflict=cols (default: the primary key) |
PATCH /rest/v1/notes?id=eq.5 | update the rows the filters match |
DELETE /rest/v1/notes?id=eq.5 | delete them |
PATCH and DELETE need at least one filter, and refuse limit and offset: a mistake never touches every row.
Prefer: return=representation returns the written rows.
Other schemas in rest.schemas: Accept-Profile: <schema> for reads, Content-Profile: <schema> for writes.
Schema
GET /rest/v1/ lists the served tables, their columns and keys. A table you make or change is served at once.
Who sees what
Every request runs as a role (anon, authenticated or service_role) with the caller's token claims in
request.jwt.claims. A new table is closed to anon and authenticated until you grant it, and row-level
security decides which rows. See Auth, row-level security.
Forkbase's own schemas (auth, storage, forkbase, agents, jobs, mcp) are never served.
Errors
{"code": "42501", "message": "permission denied for table notes", "details": null, "hint": null}Postgres errors keep their SQLSTATE code. Request mistakes use PostgREST's PGRST... codes.
Something wrong or missing? Edit this page on GitHub or open an issue.