HTTP API
| Endpoint | Auth | |
|---|---|---|
GET / |
no | server version, endpoints, authentication and skill install command (unless --serve-skill off) |
GET /skill, GET /skill/{file} |
no | agent skill documentation; scripts too with --serve-skill all |
GET /v1/capabilities |
yes | the credential, document features and delegation contract |
POST /v1/query |
yes | run a statement, or a dry run |
GET /v1/schema |
yes | tables, views and columns the caller may query |
GET /v1/databases |
yes | databases containing objects the caller may query |
POST /mcp |
yes | native MCP when --mcp is enabled; see Native MCP |
GET /v1/docs, GET /v1/docs/{id} |
yes | semantic documents (with --docs-dir) |
POST /v1/docs/search |
yes | documents that fit a question |
POST /v1/docs, PUT/PATCH/DELETE /v1/docs/{id} |
yes | write documents, as the policy allows |
GET /healthz |
no | liveness |
Prometheus /metrics is served on a separate port; see
Metrics. With --flight-listen, the same data
is also served over Arrow Flight SQL, for
database IDEs and ADBC clients.
POST /v1/query
Section titled “POST /v1/query”One statement per request. Parameters are bound server-side.
{"sql": "SELECT * FROM orders WHERE id = $1", "params": [42], "database": "sales", "format": "csv"}| Field | |
|---|---|
sql |
one SQL statement |
params |
values for $1, $2, … |
format |
json (default), csv, ndjson, arrow or parquet; also ?format= or Accept |
database |
catalog for unqualified names; defaults to the catalog file’s default |
max_rows |
lowers the row limit for this response; it can never raise it |
dry_run |
inspect and authorize without executing |
Responses
Section titled “Responses”JSON:
{"columns":[{"name":"id","type":"BIGINT"}],"data":[{"id":3}],"row_count":1}arrowis an Arrow IPC stream (application/vnd.apache.arrow.stream) and is the fastest format for large results.parquetis an Apache Parquet file (application/vnd.apache.parquet), available in builds with-tags duckdb_arrow, and respectsmax_rows.- Send
Accept-Encoding: gzipfor compressed JSON, CSV or NDJSON responses. DECIMAL,HUGEINTandUUIDare sent as strings, so no precision is lost.- Every response carries
X-Request-Id, the same id as in the audit log, and authenticated onesX-Curral-Effective-Subject, the identity the request ran as.
Row limits
Section titled “Row limits”The smallest of --max-rows, the role’s max_rows and the request’s
max_rows wins. No LIMIT is added to the SQL: the server stops reading
when the limit is reached and signals the cut with X-Curral-Max-Rows and
the trailer X-Curral-Error: row limit reached. For cheap samples, put a
LIMIT in the SQL yourself.
Errors
Section titled “Errors”Before the stream starts, errors are {"error": "..."} with a status:
| Status | |
|---|---|
| 400 | invalid SQL or request |
| 401 | not authenticated |
| 403 | denied by the policy, the engine or row/column protection, or an execution identity refused |
| 404 | unknown route or document, out-of-scope document, or /v1/docs without --docs-dir |
| 412 | If-Match on /v1/docs no longer matches the document |
| 429 | over the user’s concurrency quota, or locked out |
| 499 | client disconnected |
| 503 | queue full, or the audit log cannot be written |
| 504 | query timeout |
Once a 200 has been sent, an error goes into the X-Curral-Error trailer
(and an "error" field in JSON). X-Curral-Row-Count carries the total.
What is blocked
Section titled “What is blocked”duckdb_tables(),duckdb_columns()and similar functions,information_schema.*,pg_catalog.*,sqlite_master,SHOW TABLES: 403 for every role. Use/v1/schema.DESCRIBE/SHOWof a table is authorized as a read of that table, and returns columns even when row filters or masks apply.SUMMARIZEreads protected rows;EXPLAINremains refused for protected tables.SHOWof a name DuckDB would read as a setting, or of one quoted identifier with dots or quotes inside, arrivesresolved: false; so doSHOW/DESCRIBEinside aWITHclause and a bareSHOWnext to a directpragma_show(...)call. Qualify the table or useDESCRIBE.- DuckDB’s hints in errors (“Did you mean…?”) can name objects the caller cannot read, so they are stripped from responses (kept in the logs).
GET /v1/capabilities
Section titled “GET /v1/capabilities”Describes the credential without granting data access. A delegating service calls it with its key alone, before sending identities:
{"execution_context_version":1,"delegation_required":true,"subject":"portal", "attributes":{"tenant":"tenant-a"},"formats":["json","csv","ndjson","arrow"], "docs":{"enabled":true,"scope":"schema","ranker":"bm25","delegated_writes":false},"version":"v0.9.0"}For any other credential delegation_required is false and subject is
the caller. docs.enabled says whether /v1/docs is available; docs.scope
is all or schema, and docs.ranker is jev with a Jev key, bm25
otherwise. docs.delegated_writes reports whether the key supports delegated
document writes. A write still requires an effective identity and policy
permission.
In v0.9.0, the capabilities response still lists JSON, CSV, NDJSON and Arrow; Parquet is supported by Arrow-enabled builds even though it is not yet listed in that response.
Request headers
Section titled “Request headers”| Header | |
|---|---|
Authorization |
Basic, Bearer curral_... or Bearer <JWT> |
X-Curral-Execution-Context |
delegating keys only: the identity the request runs as; see Execution delegation |
X-Curral-Caller-Context |
other API keys: who the key is calling for, recorded in the audit log only |
GET /v1/schema
Section titled “GET /v1/schema”Lists tables, views and columns, showing each user only what they could
query: every object goes through the same inspection, policy and
protections as SELECT * FROM object.
curl -u analyst https://curral.example.com/v1/schemacurl -u analyst 'https://curral.example.com/v1/schema?database=lake&schema=analytics&table=customers'{"default_database":"lake", "databases":[{"name":"lake","type":"iceberg","schema":"analytics","read_only":false}], "tables":[{"database":"lake","schema":"analytics","name":"customers","kind":"table", "columns":[{"name":"name","type":"VARCHAR","nullable":true}, {"name":"ssn","type":"VARCHAR","nullable":true,"masked":true}], "row_filtered":true}]}- Filters
database,schemaandtableare case-insensitive. maskedandrow_filteredshow the protections that apply to the caller.commentcarriesCOMMENT ONtext when present.docscounts matching semantic documents and is omitted when none match. With--docs-scope schema, only documents visible to the caller count.
The listing is cached (--schema-cache-ttl, 10 minutes) and filtered per user
in memory, so it uses no DuckDB slot: about 0.5 ms cached versus ~4 s cold
against R2. DDL through curral refreshes it immediately; policy and RLS
changes apply at once.
/v1/docs
Section titled “/v1/docs”With --docs-dir, curral serves semantic documents: notes on what
schemas and tables mean, with sample SQL, for agents to read before writing
queries. Without it, every /v1/docs route answers 404.
curl -u analyst 'https://curral.example.com/v1/docs?table=orders&fields=header'curl -u analyst https://curral.example.com/v1/docs/search -d '{"q": "revenue per customer"}'The format, filters, writes with If-Match and the policy decision are in
Semantic documents; ranking and the response of
/v1/docs/search are in Searching documents.
Dry run
Section titled “Dry run”Add "dry_run": true to see what the policy decides, without executing:
{"dry_run":true,"decision":"deny","decided_by":"policy","statement_type":"DELETE", "database":"sales","tables":["sales.main.orders"],"targets":["sales.main.orders"], "functions":[],"databases":["sales"],"resolved":true,"policy_sha256":"..."}The response also shows limits, row filters and masked columns that would
apply. If protections cannot be applied (for example, a protected table behind
an unverifiable indirect read, EXPLAIN, or a write reading a protected table), the dry run returns
decision: deny, decided_by: protection and the reason. Invalid SQL still
returns 400.
Export Parquet
Section titled “Export Parquet”curl --fail-with-body -u analyst 'https://curral.example.com/v1/query?format=parquet' \ -H 'Content-Type: application/json' \ -d '{"sql":"SELECT * FROM orders","max_rows":10000}' \ -o orders.parquetThe row cap still applies; this may be a partial export. Check the response headers and trailers for limit signals as described under Row limits.