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.
Compiler-verified EdgeQL synthesis
Generated statements typecheck against your active SDL and access rules before running read-only, escalating model tiers on compiler diagnostics.
Grounded answers and hybrid retrieval
Synthesized queries can traverse links, aggregates and ext::ai or fts indexes while returning exact rows alongside the prose summary.
POST/ask#
The /ask response includes the synthesized EdgeQL statement, so the route is available only when schema sharing (isSchemaShared) is enabled on the project and the project’s passthrough policy admits the caller.
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 the project’s model provider. A project with no model provider answers 409 ask_not_configured. Each synthesized statement is typechecked against your schema and access policies before anything runs. If compilation fails, the compiler diagnostics go back to the model (escalating from a fast tier to a frontier reasoning model when needed). The statement that compiles runs read-only as the caller. Every response reports the model used, the number of compilation attempts and the usage token counts.
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.