REST API reference
Every Table and View in the public Schema gets an automatic API at https://<ref>.baas.arianet.app/rest/v1/<table>. A new Table is available in the API at once. Each request runs with the role of its key or User, and RLS and Policies decide which Rows are seen or changed.
BAAS_URL=https://<ref>.baas.arianet.app
ANON_KEY=<ANON_KEY>
Headers
| Header | Value |
|---|---|
apikey | Required. The Anon Key or Publishable Key (on a server: the Service Key or Secret Key). |
Authorization | Bearer <access_token> when a User is signed in; the request runs as authenticated with that User's id. Without it, the key's role is used (anon or service_role). |
Content-Type | application/json for request bodies. |
Prefer | Response behaviour: return=representation (return the written Rows), return=minimal, count=exact, resolution=merge-duplicates or resolution=ignore-duplicates (upsert). Separate several with commas. |
Range | Paging by Row range, such as Range: 0-24 (with Range-Unit: items). |
Accept | application/json (default) or text/csv. |
Roles:
| Role | With | RLS |
|---|---|---|
anon | Anon/Publishable Key without a User token | applies |
authenticated | a User's token in Authorization | applies; auth.uid() is that User's id |
service_role | Service/Secret Key | bypassed |
Browsers can call the API directly: responses allow CORS for any origin, because keys (not cookies) authorise requests.
Read
GET /rest/v1/{table}
# all columns
curl "$BAAS_URL/rest/v1/todos?select=*" -H "apikey: $ANON_KEY"
# chosen columns, with an alias and a cast
curl "$BAAS_URL/rest/v1/todos?select=id,title,createdAt:created_at,price::text" -H "apikey: $ANON_KEY"
selectpicks the columns; without it, all columns are returned.alias:columnrenames andcolumn::typecasts.- JSON columns:
select=meta->color,meta->>size(->returns JSON,->>text). - Related Tables (through a foreign key) in the same request:
select=id,title,author(id,name)for a to-one reference,select=id,name,todos(id,title)for the related Rows. Withauthor!inner(name)only Rows that have a related Row are returned. - A response has at most 1000 Rows; for more, page through them.
Filters
A filter is column=operator.value in the query string. Several filters are combined with AND.
| Operator | Meaning | Example |
|---|---|---|
eq | equal | status=eq.done |
neq | not equal | status=neq.done |
gt, gte | greater than, or equal | price=gte.1000 |
lt, lte | less than, or equal | created_at=lt.2026-12-01 |
like, ilike | pattern (* instead of %); ilike ignores case | title=ilike.*milk* |
in | one of the values | id=in.(1,2,3) |
is | null, true, false | deleted_at=is.null |
cs, cd | array/JSON contains / is contained in | tags=cs.{work,urgent} |
ov | array or range overlap | tags=ov.{a,b} |
fts, plfts, phfts, wfts | full-text search | body=fts.hello |
not. | negates any operator | status=not.eq.done |
or / and | combine conditions | or=(status.eq.new,priority.gt.3) |
curl "$BAAS_URL/rest/v1/todos?select=*&done=is.false&or=(priority.gte.3,title.ilike.*urgent*)" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN"
Put values containing commas, parentheses or dots in " and URL-encode them. Filter on a related Table: select=*,todos(*)&todos.done=eq.false.
Ordering
order=column.asc or order=column.desc, with nullsfirst / nullslast, several columns separated by commas:
curl "$BAAS_URL/rest/v1/todos?select=*&order=done.asc,created_at.desc.nullslast" -H "apikey: $ANON_KEY"
Paging
With limit and offset:
curl "$BAAS_URL/rest/v1/todos?select=*&order=id&limit=25&offset=50" -H "apikey: $ANON_KEY"
Or with the Range header. For the total count, send Prefer: count=exact; the response then has a Content-Range header such as 50-74/312:
curl -i "$BAAS_URL/rest/v1/todos?select=*" -H "apikey: $ANON_KEY" \
-H "Range: 0-24" -H "Prefer: count=exact"
On large Tables, count=planned or count=estimated is faster. Always page with an order so the order is stable.
Insert
POST /rest/v1/{table}
curl -X POST "$BAAS_URL/rest/v1/todos" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" -H "Prefer: return=representation" \
-d '{"title": "Buy bread"}'
- For several Rows, send an array:
[{"title": "a"}, {"title": "b"}]. - Without
Prefer: return=representationthe answer is201with no body. - The Row must pass the
WITH CHECKof anINSERTPolicy, otherwise you get error42501. ?columns=title,donereads only these columns from the body.
Upsert
Insert, or update when the key already exists:
curl -X POST "$BAAS_URL/rest/v1/profiles?on_conflict=user_id" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: resolution=merge-duplicates,return=representation" \
-d '{"user_id": "<user-id>", "display_name": "Ali"}'
on_conflictnames the unique column or columns (default: the primary key).resolution=ignore-duplicatesskips duplicate Rows.- An upsert needs both an
INSERTand anUPDATEPolicy.
Update
PATCH /rest/v1/{table}
curl -X PATCH "$BAAS_URL/rest/v1/todos?id=eq.42" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" -H "Prefer: return=representation" \
-d '{"done": true}'
Always add a filter. Without one, every Row the Policies allow is changed. Rows the UPDATE Policy does not see are left alone (without an error).
Delete
DELETE /rest/v1/{table}
curl -X DELETE "$BAAS_URL/rest/v1/todos?id=eq.42" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN"
As with updates, without a filter every allowed Row is deleted. Prefer: return=representation returns the deleted Rows.
Call a Function with rpc
POST /rest/v1/rpc/{function}
Any Function in the public Schema can be called. Arguments are sent as JSON by parameter name:
create function public.todo_stats(min_priority int)
returns table (done boolean, total bigint)
language sql stable
as $$
select done, count(*) from public.todos where priority >= min_priority group by done
$$;
curl -X POST "$BAAS_URL/rest/v1/rpc/todo_stats" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"min_priority": 2}'
stableorimmutableFunctions can also be called withGETand query parameters:GET /rest/v1/rpc/todo_stats?min_priority=2.- A Function runs as the caller and RLS applies, unless it was created
security definer. In asecurity definerFunction alwaysset search_path = ''and check access yourself. - Filters,
orderandlimitalso work on the result of Functions that return a table.
Errors
Errors about reaching the Project (before the request reaches the API) look like this:
{"code": "invalid_api_key", "message": "…", "request_id": "…"}
| HTTP | code | Meaning |
|---|---|---|
401 | no_api_key | No apikey header was sent. |
401 | invalid_api_key | The key is wrong or revoked (for example an old key after a rotation's overlap). |
402 | egress_limit_reached | The Free Plan's monthly Egress is used up. |
403 | project_suspended | The Project is suspended. |
404 | project_not_found | No Project at this address. |
429 | rate_limit_exceeded | More requests than the Plan allows; retry after Retry-After seconds. |
503 | project_resuming | The Project is starting after an automatic pause; retry after Retry-After (about 5 seconds). |
503 | project_paused | You paused the Project. |
503 | project_provisioning | The Project is still being created. |
502 | upstream_unavailable | The service did not answer for a moment; retry. |
API and Database errors look like this:
{"code": "42501", "message": "new row violates row-level security policy for table \"todos\"", "details": null, "hint": null}
code is either the Database's own SQLSTATE (for example 42501 permission or Policy violation, 23505 duplicate value, 23503 foreign key violation, 42P01 the Table does not exist, 22P02 invalid value for the column type) or the REST layer's own code for errors such as a bad parameter. Compatible client libraries understand these codes. Every response has an X-Request-Id header; include it when you report a problem.
Only the public Schema is served by the REST API. Read Tables of other Schemas through a Function in public, or from a server over the direct connection.