Reference · Project API
Running queries
Run an EdgeQL statement or a deployed query, preview a change with a dry run and read your own writes from any replica.
- In the schema
- —
EdgeQL statements#
POST /query and POST /query/{name} compile each EdgeQL statement alongside your schema’s access policies into one atomic SQL query, returning typed JSON and an updated causal bookmark.
Single-statement graph queries
Nested object shapes, forward links, computed backlinks and multi-type FOR writes execute in one round trip under the caller’s rules.
Rolled-back dry-run diffs
Passing "is_dry_run": true executes mutations inside a rolled-back transaction and returns exact before and after states with zero side effects.
POST/query#
Body
- querystringrequired
- A single EdgeQL data statement (
select,insert,update,delete,grouporfor). - variablesobject
- Key-value map binding the statement’s
$nameparameters. Decimal and bigint values preserve full precision. - is_dry_runboolean
- When
true, runs a mutation inside a transaction, captures before/after object states and rolls back without committing.
Globals, session configuration, target branch and database role come only from the bearer credential and endpoint settings. The request body never sets those values. See Queries for language syntax.
curl https://notes.napalmdata.com/query \ -H "Authorization: Bearer $NAPALM_KEY" \ -H "Content-Type: application/json" \ -d { "query": "select Note { title } filter .title ilike <str>$q", "variables": { "q": "%launch%" } }{ "data": [ { "title": "Launch checklist" } ]}Deployed query calls#
POST/query/{name}#
Calls one of the project’s deployed queries by name. When {name} matches a deployed query, the server runs the stored statement. The request body needs only variables (and optional is_dry_run), and the server ignores a query field sent by an older client. GET /openapi.json returns the OpenAPI 3.0 specification for all deployed queries.
Your project’s passthrough policy sets which callers can send ad-hoc statements to POST /query. The options are everyone (all), service keys only (keys) and nobody (none). Callers excluded from passthrough can still invoke any deployed query at POST /query/{name}. Ad-hoc statements from those callers return 403 deployed_query_required.
A deployed query with a handler attached is an action, and the query’s rows go to your HTTPS handler. The response carries the handler’s own status, content type and body, plus a Napalm-Action header naming the action. If the query returns no rows, the call is refused with 403 nothing_found and the handler is never called.
A query’s changes since a bookmark#
POST/query/{name}/changes#
Returns the row diff needed to bring a cached copy of a deployed query’s result up to date since after, rather than re-sending the full result. The query runs as the caller under your schema’s access rules regardless of passthrough policy, matching POST /query/{name}. In the client SDKs, sync requests the same diff over a live stream.
Body
- afterstringrequired
- The bookmark the copy stands at: an earlier answer’s
bookmark, or thefloorof the last live frame the copy applied. - variablesobject
- The query’s
$namevariables.
The response carries bookmark alongside one of three payload shapes. An empty changed array alone means none of the query’s inputs changed. changed paired with order carries each modified row in full plus every current result ID in order, so any cached row absent from order has left the result. data carries the full result when a change affects linked objects or follows a new query deployment. The response never exposes rows or IDs the caller cannot read.
410 bookmark_too_old means the bookmark predates the retained change log, so fetch a fresh result from POST /query/{name}. A cluster with no change log returns 409 change_log_not_configured. An action returns 400 action_not_live, and a query that writes returns 400 query_rejected.
curl https://notes.napalmdata.com/query/listNotes/changes \ -H "Authorization: Bearer $NAPALM_KEY" \ -H "Content-Type: application/json" \ -d { "variables": {}, "after": "2026.11.1:7465436217498812345:3:2A/5F01C8E0" }Access policy behavior#
A select silently filters out rows the caller may not read. update and delete statements target only rows visible under update read / delete policies. If an insert or update writes values that violate an allow insert or allow update write rule, the transaction aborts with 400 query_failed.
{ "error": { "code": "query_failed", "type": "AccessPolicyError" }}Dry-run mutation previews#
Pass "is_dry_run": true on any single-statement insert, update or delete (either ad-hoc at POST /query or on a mutating deployed query at POST /query/{name}). The engine executes the mutation as the caller under all access policies, captures the exact before and after state of every modified object and rolls the transaction back. No side effects escape the transaction, so no webhooks fire and no background jobs are queued.
When the project shares the schema, rows also summarizes total inserted, updated and deleted row counts across every table the statement touched (including cascading triggers and mutation rewrites).
Snapshot position#
The returned position is the bookmark of the dry run’s snapshot. After the user approves and before you run the mutation for real, call GET / to check whether a concurrent transaction changed the target records. You can also pass position in Napalm-Bookmark so later reads observe at least that state.
Limits#
Each branch allows 100 dry runs, tests, checks and plans per minute across all callers. Requests past that limit do not run and return 429 rate_limited with the wait time in Retry-After (also reported in MCP tool text and as retry_after_seconds in A2A errors).
A dry run holds row locks on modified rows until rollback and gets 10 seconds instead of a statement’s 60. A write past that limit returns 503 project_unavailable and rolls back.
curl https://notes.napalmdata.com/query \ -H "Authorization: Bearer $NAPALM_KEY" \ -H "Content-Type: application/json" \ -d { "query": "update Note filter .title = <str>$title set { title := <str>$to }", "variables": { "title": "Launch checklist", "to": "Launch plan" }, "is_dry_run": true }{ "changes": [{ "id": "8f2c1e64-0b7a-4f4e-9d2b-3a6c5e1f7d90", "type": "default::Note", "action": "update", "before": { "id": "8f2c…", "title": "Launch checklist" }, "after": { "id": "8f2c…", "title": "Launch plan" } }], "rows": [{ "type": "default::Note", "inserted": 0, "updated": 1, "deleted": 0 }], "position": "nbm_0192c3f4_8k2p9v4m1x"}Causal bookmarks#
Use the Napalm-Bookmark header so a client session always observes the session’s own writes. The guarantee holds even when later reads go to a different engine or replica.
Ordered commit position
Every committed mutation, live frame, webhook delivery and /changes page records an ordered shard commit position.
Opaque Napalm-Bookmark header
Responses return Napalm-Bookmark, and clients echo the highest token seen back on subsequent requests.
Caught-up replica routing
Bookmarked reads wait briefly if needed or route to a replica caught up to that commit so callers always read their own writes.
Napalm-Bookmark:(empty)- Executes the request and returns an opaque causal bookmark in the
Napalm-Bookmarkresponse header. Napalm-Bookmark: <bookmark>- Reads data at least as new as the bookmark. The read may wait briefly for that data. Returns an updated bookmark after any write.
The Napalm-Bookmark header holds an opaque string. Clients must pass the bookmark back unparsed and unchanged. Without a bookmark, reads still see every write acknowledged before the request arrived. The one exception is an engine’s in-memory query cache, which may serve a read up to 1 second old. The Napalm-Freshness response header reports the cached read’s age.
Every position a project hands out is a bookmark, under several field names: a live frame’s lsn, a change’s bookmark and a page’s next from GET /changes, and a webhook delivery’s Napalm-Position. Any of those positions works as Napalm-Bookmark. A job woken by a webhook can send the delivery’s position, and the job’s read then sees the writes the delivery reported. Any position also works as reach on GET /changes, which reads the change log up to that position.
Napalm’s clients track the bookmark for you. A NapalmClient (napalm-client, or Dart’s napalm_client) holds the furthest bookmark received so far and sends that bookmark with every request. Live queries open from that bookmark. Generated clients built on the client’s fetch or httpClient send the bookmark too (see typed clients). Agents need no bookmark, because an MCP or A2A call always reads every write acknowledged before the call, including the agent’s own. No agent call is answered from the cache.
Vector and hybrid search#
POST/search#
POST /search runs a hybrid search over one object type that has both an ext::ai::index and an fts::index. The search fuses matches by meaning with matches by words and returns matching objects ordered by relevance under the caller’s select access policies. The route is open to callers the project’s passthrough policy admits. A caller the passthrough leaves out searches through a deployed query that calls ext::ai::hybrid_search. See Search for the query’s shape.
The project’s model embeds the search query. If the type’s index has no model provider, the route answers 409 model_not_configured. If the provider does not answer, the route answers 424 model_unavailable. The search never falls back to words alone.
curl https://notes.napalmdata.com/search \ -H "Authorization: Bearer $SESSION" \ -H "Content-Type: application/json" \ -d { "type": "Note", "query": "launch timeline and milestones", "limit": 5 }Change data export#
GET/changes#
Returns committed transactions from the branch’s durable change log in commit order. The caller’s read access policies filter the transactions. Search indexes, analytics pipelines and local caches can stay synchronized this way without external CDC connectors.
Query parameters
- afterstring
- Reading resumes after this commit bookmark (
nextfrom the previous response). - sincestring
- An RFC 3339 start time for a read with no
afterbookmark. - untilstring
- Optional upper-bound RFC 3339 timestamp.
- typesstring
- Comma-separated object type names (such as
Note,Person). Required when schema sharing is disabled. - limitinteger
- Maximum transactions per page (1 to 1,000, default 100).
Each transaction in items carries a bookmark, commit_time, anonymized caller metadata ({ "kind", "via" }) and rows (type, op, id, fields, and for watched types the previous values of changed fields). For types with row-level select policies (checked access), Napalm re-checks visibility as the caller before sending field values. The response also carries next and is_caught_up for pagination.
See Notifications & webhooks for gap handling, per-type access, webhook deliveries and tailing the log from a webhook’s position.
curl "https://notes.napalmdata.com/changes?since=2026-11-08T00:00:00Z&types=Note&limit=100" \ -H "Authorization: Bearer $NAPALM_KEY"