Reference · Project API
Ask & schema
Ask a plain-English question, compile it to a typechecked EdgeQL query and run it read-only as the caller.
- API
POST /ask,GET /schema- CLI
napalm ask- In the schema
- —
Natural-language questions#
POST /ask turns a plain-language question into a single schema-checked EdgeQL statement, executes reads strictly under the caller’s access policies and holds mutations back as reviewable proposals.
Typechecked query synthesis
Synthesized EdgeQL statements compile against your schema and access policies before running read-only.
Grounded row answers
Responses return the synthesized query and exact database rows alongside the natural-language answer.
Because the /ask response returns the synthesized EdgeQL statement, the route requires schema sharing (isSchemaShared) and passthrough access for the caller.
POST/ask#
Body
- questionstringrequired
- Natural-language question (up to 2,000 characters).
- answerboolean
- Whether to send the results back to the model for a prose summary. Defaults to
true. Withfalse, the response holds only the synthesizedqueryand the rawdatarows. - is_dry_runboolean
- Whether to run a proposed mutation (
insert,updateordelete) as a dry run. The dry run rolls back, and the response holds the before/after diff.
curl https://notes.napalmdata.com/ask \ -H "Authorization: Bearer $SESSION" \ -H "Content-Type: application/json" \ -d '{ "question": "Which of my notes mention the launch?" }'{ "data": [ { "title": "Launch checklist" } ], "query": "select Note { title } filter .owner = global caller and .title ilike '%launch%' limit 50", "answer": "One of your notes mentions the launch: Launch checklist.", "model": "napalm:anthropic/claude-haiku-5.5", "attempts": 1, "usage": { "input_tokens": 4120, "output_tokens": 61 }}Model routing, typechecking and token usage#
POST /ask uses your project’s configured model provider and returns 409 ask_not_configured when none is set. Napalm typechecks every synthesized statement against your schema and access policies before execution. When compilation fails, Napalm feeds the compiler diagnostics back to the model and escalates to a stronger reasoning model if needed. Once a read statement compiles, it runs read-only as the caller. Every response reports the model, compilation attempts and token usage.
Mutation proposals and dry runs#
POST /ask never commits a mutation. If answering a question requires an insert, update or delete, the endpoint returns the synthesized statement inside proposed without running it. Your application or user can review the proposal and submit the statement to POST /query.
When you pass "is_dry_run": true (with a read-write credential), Napalm runs the proposed mutation inside a transaction under the caller’s access policies and rolls it back. proposed.dry_run holds the exact before and after objects, affected table counts and the snapshot’s position. If the caller’s access policy rejects the mutation or the statement shape does not support dry-run capture, proposed.dry_run_failure gives the reason.
{ "proposed": { "query": "delete Note filter .owner = global caller and .title = 'Launch checklist'", "reason": "The question asks for a change. Nothing ran; run the statement yourself if you mean it." }, "model": "napalm:anthropic/claude-haiku-5.5", "attempts": 1, "usage": { "input_tokens": 4080, "output_tokens": 34 }}{ "proposed": { "query": "delete Note filter .owner = global caller and .title = 'Launch checklist'", "reason": "The question asks for a change. It ran as a dry run and was rolled back, so nothing was kept; run the statement yourself if you mean it.", "dry_run": { "changes": [ { "id": "3f2a9c1e-7b4d-11f0-9c1e-0c8e2f7d4b19", "type": "default::Note", "action": "delete", "before": { "id": "3f2a9c1e-7b4d-11f0-9c1e-0c8e2f7d4b19", "title": "Launch checklist" }, "after": null } ], "placement": { "class": "base" }, "rows": [{ "type": "default::Note", "inserted": 0, "updated": 0, "deleted": 1 }], "position": "nbm_0192c3f4_8k2p9v4m1x" } }, "model": "napalm:anthropic/claude-haiku-5.5", "attempts": 1, "usage": { "input_tokens": 4080, "output_tokens": 34 }}The SDL schema#
GET/schema#
GET /schema returns { "sdl": "…" } with the branch’s current SDL schema to any authenticated caller. When schema sharing is disabled on the project, both GET /schema and POST /ask return 404 not_found.