Database
Truss wraps PostgreSQL with a SQL workbench, schema browser, ERD visualizer, and a client API for your applications. The dashboard lets you browse tables, run queries, and visualize your schema. The client API gives you SQL-over-HTTP and automatic CRUD endpoints.
SQL-over-HTTP
Run arbitrary SQL via the client API. Requires a service_role API key.
curl -X POST http://localhost:8787/v1/sql \ -H "apikey: truss_sk_your_key" \ -H "Content-Type: application/json" \ -d '{ "sql": "SELECT id, name, email FROM users WHERE active = true", "params": [], "row_limit": 100 }'const res = await fetch('http://localhost:8787/v1/sql', { method: 'POST', headers: { 'apikey': 'truss_sk_your_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ sql: 'SELECT * FROM users WHERE id = $1', params: [42] })});const { rows, columns, rowCount } = await res.json();Response includes rows, rowCount, columns (with type info), and command (SELECT, INSERT, etc.).
Transactions
Bundle multiple statements in a single transaction:
curl -X POST http://localhost:8787/v1/sql/transaction \ -H "apikey: truss_sk_your_key" \ -H "Content-Type: application/json" \ -d '{ "statements": [ {"sql": "INSERT INTO orders (user_id, total) VALUES ($1, $2)", "params": [1, 99.99]}, {"sql": "UPDATE users SET order_count = order_count + 1 WHERE id = $1", "params": [1]} ] }'Up to 20 statements per transaction. If any statement fails, the entire transaction rolls back.
Auto-REST (CRUD)
Every table gets automatic REST endpoints at /v1/db/:table. Works with both anon and service_role keys.
Select rows
# Get all userscurl "http://localhost:8787/v1/db/users" \ -H "apikey: truss_pk_your_anon_key"
# With filters, ordering, paginationcurl "http://localhost:8787/v1/db/users?active=eq.true&order=created_at.desc&limit=10&offset=0" \ -H "apikey: truss_pk_your_anon_key"
# Select specific columnscurl "http://localhost:8787/v1/db/users?select=id,name,email" \ -H "apikey: truss_pk_your_anon_key"Filter operators
| Operator | Example | SQL equivalent |
|---|---|---|
eq | ?status=eq.active | status = 'active' |
neq | ?role=neq.admin | role != 'admin' |
gt / gte | ?age=gt.18 | age > 18 |
lt / lte | ?price=lt.100 | price < 100 |
like | ?name=like.*john* | name LIKE '%john%' |
ilike | ?name=ilike.*john* | name ILIKE '%john%' |
is | ?deleted_at=is.null | deleted_at IS NULL |
in | ?id=in.(1,2,3) | id IN (1, 2, 3) |
Insert rows
# Single rowcurl -X POST http://localhost:8787/v1/db/users \ -H "apikey: truss_sk_your_key" \ -H "Content-Type: application/json" \ -d '{"name": "Alice", "email": "alice@example.com"}'
# Multiple rowscurl -X POST http://localhost:8787/v1/db/users \ -H "apikey: truss_sk_your_key" \ -H "Content-Type: application/json" \ -d '[ {"name": "Alice", "email": "alice@example.com"}, {"name": "Bob", "email": "bob@example.com"} ]'Update rows
Filters are required — you can’t update without a WHERE clause.
curl -X PATCH "http://localhost:8787/v1/db/users?id=eq.42" \ -H "apikey: truss_sk_your_key" \ -H "Content-Type: application/json" \ -d '{"name": "Updated Name"}'Delete rows
Filters are required — you can’t delete without a WHERE clause.
curl -X DELETE "http://localhost:8787/v1/db/users?id=eq.42" \ -H "apikey: truss_sk_your_key"Call functions
curl -X POST http://localhost:8787/v1/db/rpc/my_function \ -H "apikey: truss_sk_your_key" \ -H "Content-Type: application/json" \ -d '{"arg1": "value1", "arg2": 42}'Row-Level Security (RLS)
When using an anon key, Truss sets the Postgres role to authenticated and passes JWT claims via set_config. Your RLS policies can reference:
current_setting('request.jwt.claims', true)— full JWT payloadcurrent_setting('request.jwt.sub', true)— thesubclaim (user ID)
With a service_role key, RLS is bypassed entirely (role is set to postgres).
Dashboard features
The dashboard provides a full SQL workbench with:
- Monaco editor with syntax highlighting and auto-complete
- Schema browser — tables, columns, indexes, constraints
- ERD visualizer — auto-generated entity-relationship diagrams
- Saved queries — store and re-run frequently used queries
- Database branching — create isolated database branches for testing
- Backups — point-in-time recovery (PITR)