Reference · Project API
Project API
Every project serves an HTTPS API for queries, live streams, uploads, sign-in and questions. Each request runs under your access rules.
Authentication#
Every request goes to your project’s own host at <label>.napalmdata.com and passes one bearer credential in the Authorization: Bearer <token> header. The credential is a user session token from your project’s /sign-in routes or a project service key (ndb_…). Unauthenticated requests are rejected with 401 unauthorized before reaching the database.
Stateless calls, SSE & commit logs
One-shot POST /query calls, multiplexed POST /subscribe SSE conduits and GET /changes commit streams share the same bearer header and branch prefix.
Bearer-bound caller verdicts
User sessions bind global caller and ndb_… service keys bind serviceGlobals. Unauthenticated or unlisted-origin calls stop at the gate.
| Credential | Caller identity (global caller) | Injected globals |
|---|---|---|
| User session token | The authenticated user’s ext::auth::Identity record | Injected globalsConfigured userGlobals |
ndb_… service key | Empty set ({}) | Injected globalsConfigured serviceGlobals |
Requests to the root path (/query, /subscribe, etc.) run against main. To target a branch, prefix the path with /branches/{branch} (for example, /branches/pr-12/query) and authenticate with a credential issued for that branch. See Sessions and keys.
Endpoint directory#
| Section | Routes | Purpose |
|---|---|---|
| Running queries | POST / | PurposeExecute ad-hoc or deployed EdgeQL statements, preview mutations with dry runs, run vector/hybrid search and read access-filtered CDC changes. |
| Live queries | POST / | PurposeStream real-time row diffs over multiplexed Server-Sent Events as transactions commit. |
| Notifications & webhooks | GET / | PurposeRead the access-filtered change log with resumable bookmarks and receive signed webhook deliveries. |
| File uploads | POST / | PurposeFetch multipart upload URLs and verify uploaded file bytes against your schema’s size and format rules. |
| Sign-in | /sign-in, /sign-in/* | PurposeAuthenticate end users via passwords, magic links, passkeys, OAuth/OIDC and OAuth 2.1 agent consent grants. |
| Ask & schema | POST /ask, GET /schema | PurposeAnswer natural-language questions as the caller and retrieve the branch’s SDL schema (when shared). |
| Agent protocols | POST / | PurposeConnect agents over the Model Context Protocol or Agent-to-Agent JSON-RPC, and fetch the OpenAPI 3.0 spec for deployed queries. |
Download the complete machine-readable specification for both the Project API and Control API at /openapi.yaml.
Browser CORS and origins#
Cross-origin browser requests are permitted only from origins listed in your project’s allowed origins (up to 32 exact origins per project). Requests carrying an unlisted Origin header are rejected with 403 forbidden. Allowed origins use HTTPS. A dev server can use an HTTP origin on the same machine, such as http://localhost:5173. The project answers OPTIONS preflight requests automatically, allows the Authorization, Content-Type, Napalm-Bookmark, A2A-Version and Last-Event-ID request headers and exposes Napalm-Bookmark to browser code.
Request and runtime limits#
| Parameter | Limit |
|---|---|
| Maximum request body size | 1 MiB |
| Maximum response payload size | 16 MiB |
| Statement execution timeout | 60 seconds |
Natural-language /ask timeout | 120 seconds |
Statements per /query call | 1 EdgeQL statement (compiled to 1 atomic SQL query) |
| Concurrent live subscriptions | 1,000 subscriptions for each GiB of the project’s engine memory, across every branch |
| Waiting jobs | 10,000 per caller from any source. A schedule’s jobs never count. |
| Caching header | Every response includes Cache-Control: no-store |
Limits gathers every limit of a project, an org and the control API on one page.
Error codes#
All error responses share one JSON envelope: { "error": { "code": "…" } }. When a query fails inside the database engine (for example, due to an access policy violation or constraint failure), the error object also includes type with the EdgeQL exception class name.
| HTTP | Error code | Description |
|---|---|---|
| 400 | invalid_request | DescriptionMalformed JSON body or invalid parameter types. |
| 400 | query_rejected | DescriptionStatement violates the API sandbox (multi-statement script, DDL, session config or disallowed system module). |
| 400 | query_failed | DescriptionStatement was aborted by the engine (includes type, such as AccessPolicyError or ConstraintViolationError). A write sent with a read-only credential gets this code with type DisabledCapabilityError. |
| 400 | invalid_bookmark | DescriptionMalformed Napalm-Bookmark header or cursor bookmark. |
| 400 | dry_run_unsupported | Descriptionis_dry_run was requested on a read-only statement or a statement whose top-level result is not the mutated object set. |
| 400 | types_required | DescriptionGET /changes was called without a types filter on a project that does not share the schema. |
| 401 | unauthorized | DescriptionMissing Authorization: Bearer header. |
| 401 | invalid_key | DescriptionService key is unknown, expired, revoked or scoped to a different branch. |
| 401 | invalid_session | DescriptionUser session token failed verification or expired, or the user’s Identity was deleted. |
| 403 | forbidden | DescriptionRequest came from an unlisted browser Origin, or a read-only credential called an upload route. |
| 403 | deployed_query_required | DescriptionCaller attempted an ad-hoc query, /ask, /search or /changes when the project’s passthrough policy requires deployed queries. |
| 403 | nothing_found | DescriptionAn action’s query returned no rows for the active caller. The handler was not called. |
| 403 | read_only | DescriptionA read-only credential called an action that changes data. |
| 404 | not_found | DescriptionThe project endpoint is disabled, the deployed query name is unknown, or /schema or /ask was called while schema sharing is disabled. |
| 409 | ask_not_configured | DescriptionPOST /ask called on a project with no configured AI model provider. |
| 409 | model_not_configured | DescriptionA search by meaning ran on a project with no model provider for the type’s index. The search does not fall back to words alone. |
| 409 | branch_distributed | DescriptionGET /changes called on a branch spread over more than one shard. The change log does not yet cover multi-shard branches. |
| 409 | change_log_not_configured | DescriptionGET /changes called on a project whose cluster keeps no change log. Retries fail until the change log is enabled on the cluster. |
| 413 | request_too_large | DescriptionThe request body is over 1 MiB. |
| 413 | result_too_large | DescriptionQuery result exceeds 16 MiB. |
| 413 | presence_too_large | DescriptionA room state over 4 KiB or a room message over 16 KiB. |
| 422 | ask_unanswered | DescriptionThe model could not synthesize a valid compiling EdgeQL query for the question. |
| 424 | model_unavailable | DescriptionUpstream AI model provider timed out or failed on a question or a search. Retry shortly. |
| 429 | live_limit_reached | DescriptionOpening or adding subscriptions would exceed the project’s concurrent live subscription cap. |
| 429 | presence_limit_reached | DescriptionA stream joined more than 16 rooms or watched more than 256. |
| 429 | presence_rate_reached | DescriptionA server sent a room more than 32 messages in a second. |
| 429 | job_limit_reached | DescriptionThe statement queued a job past the limit of 10,000 waiting jobs per caller. None of the statement’s changes were kept. Retry after some jobs run. |
| 502 | action_unreachable | DescriptionAn action’s handler could not be reached or ran past the time limit. The handler may still have acted. |
| 502 | answer_too_large | DescriptionAn action’s handler responded with more than 1 MiB. |
| 503 | project_unavailable | DescriptionThe project’s database shard is temporarily unreachable. Retry shortly. |
| 503 | live_unavailable | DescriptionThe branch cannot stream changes yet. Retry shortly. |
| 503 | log_unavailable | DescriptionThe branch change log cannot be read right now for the requested GET /changes window. Retry shortly. |
| 504 | ask_timeout | DescriptionA question took more than 120 seconds with the model’s turns. |