Skip to main content
The Database primitive operates on a fullstack app’s Supabase project. All routes are app-scoped and exist under both the company mount (/v1/apps/:id/...) and the per-user mount (/v1/users/:user_id/apps/:id/...). The :user_id may be default (your own project) or an end-user id (multi-tenant). On per-user mounts the kit must enable the database primitive.

Endpoints

MethodPathDescription
POST/v1/apps/:id/db/queryRun SQL (SELECT / DML / DDL) via the Supabase Management API
GET/v1/apps/:id/db/tablesList public-schema tables with row counts
ANY/v1/apps/:id/db/rest/*PostgREST data API passthrough (service-role key)
ANY/v1/apps/:id/supabase/proxy/v1/projects/{ref}/database/migrationsTracked migrations (Management API — gated to approved Supabase orgs)

SQL

curl -X POST https://api.usenaive.ai/v1/apps/<app-id>/db/query \
  -H "Authorization: Bearer nv_sk_live_..." -H "Content-Type: application/json" \
  -d '{"sql": "select * from users limit 10"}'
Returns the result rows as a JSON array. DDL is supported. Fullstack apps only (501 feature_not_configured otherwise).

PostgREST

# Select
curl "https://api.usenaive.ai/v1/apps/<app-id>/db/rest/notes?select=id,body&order=id.desc" \
  -H "Authorization: Bearer nv_sk_live_..."

# Insert (Prefer returns the created row)
curl -X POST https://api.usenaive.ai/v1/apps/<app-id>/db/rest/notes \
  -H "Authorization: Bearer nv_sk_live_..." -H "Content-Type: application/json" \
  -H "Prefer: return=representation" -d '{"body": "hello"}'
Forwards to the project’s /rest/v1/* with the service-role key (RLS bypassed). Uses PostgREST query syntax.

SDK

await naive.database.query("select now()");
await naive.forUser(userId).database.from("notes").insert({ body: "hello" });
See the Database guide and the database sub-client.