Skip to the page

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.

One HTTPS project endpoint

Queries, SSE live streams, file uploads, PKCE sign-in and /mcp or /a2a agent calls all enter through <label>.napalmdata.com rather than a raw SQL socket.

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.

CredentialCaller identity (global caller)Injected globals
User session tokenThe authenticated user’s ext::auth::Identity recordInjected globalsConfigured userGlobals
ndb_… service keyEmpty 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#

SectionRoutesPurpose
Running queriesPOST /query, /query/{name}, POST /search, GET /changesPurposeExecute ad-hoc or deployed EdgeQL statements, preview mutations with dry runs, run vector/hybrid search and read access-filtered CDC changes.
Live queriesPOST /subscribe, /subscribe/{stream}PurposeStream real-time row diffs over multiplexed Server-Sent Events as transactions commit.
Notifications & webhooksGET /changes, webhook deliveriesPurposeRead the access-filtered change log with resumable bookmarks and receive signed webhook deliveries.
File uploadsPOST /uploads/parts, /uploads/completePurposeFetch 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 & schemaPOST /ask, GET /schemaPurposeAnswer natural-language questions as the caller and retrieve the branch’s SDL schema (when shared).
Agent protocolsPOST /mcp, POST /a2a, GET /openapi.jsonPurposeConnect 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#

ParameterLimit
Maximum request body size1 MiB
Maximum response payload size16 MiB
Statement execution timeout60 seconds
Natural-language /ask timeout120 seconds
Statements per /query call1 EdgeQL statement (compiled to 1 atomic SQL query)
Concurrent live subscriptions1,000 subscriptions for each GiB of the project’s engine memory, across every branch
Waiting jobs10,000 per caller from any source. A schedule’s jobs never count.
Caching headerEvery 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.

HTTPError codeDescription
400invalid_requestDescriptionMalformed JSON body or invalid parameter types.
400query_rejectedDescriptionStatement violates the API sandbox (multi-statement script, DDL, session config or disallowed system module).
400query_failedDescriptionStatement 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.
400invalid_bookmarkDescriptionMalformed Napalm-Bookmark header or cursor bookmark.
400dry_run_unsupportedDescriptionis_dry_run was requested on a read-only statement or a statement whose top-level result is not the mutated object set.
400types_requiredDescriptionGET /changes was called without a types filter on a project that does not share the schema.
401unauthorizedDescriptionMissing Authorization: Bearer header.
401invalid_keyDescriptionService key is unknown, expired, revoked or scoped to a different branch.
401invalid_sessionDescriptionUser session token failed verification or expired, or the user’s Identity was deleted.
403forbiddenDescriptionRequest came from an unlisted browser Origin, or a read-only credential called an upload route.
403deployed_query_requiredDescriptionCaller attempted an ad-hoc query, /ask, /search or /changes when the project’s passthrough policy requires deployed queries.
403nothing_foundDescriptionAn action’s query returned no rows for the active caller. The handler was not called.
403read_onlyDescriptionA read-only credential called an action that changes data.
404not_foundDescriptionThe project endpoint is disabled, the deployed query name is unknown, or /schema or /ask was called while schema sharing is disabled.
409ask_not_configuredDescriptionPOST /ask called on a project with no configured AI model provider.
409model_not_configuredDescriptionA 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.
409branch_distributedDescriptionGET /changes called on a branch spread over more than one shard. The change log does not yet cover multi-shard branches.
409change_log_not_configuredDescriptionGET /changes called on a project whose cluster keeps no change log. Retries fail until the change log is enabled on the cluster.
413request_too_largeDescriptionThe request body is over 1 MiB.
413result_too_largeDescriptionQuery result exceeds 16 MiB.
413presence_too_largeDescriptionA room state over 4 KiB or a room message over 16 KiB.
422ask_unansweredDescriptionThe model could not synthesize a valid compiling EdgeQL query for the question.
424model_unavailableDescriptionUpstream AI model provider timed out or failed on a question or a search. Retry shortly.
429live_limit_reachedDescriptionOpening or adding subscriptions would exceed the project’s concurrent live subscription cap.
429presence_limit_reachedDescriptionA stream joined more than 16 rooms or watched more than 256.
429presence_rate_reachedDescriptionA server sent a room more than 32 messages in a second.
429job_limit_reachedDescriptionThe 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.
502action_unreachableDescriptionAn action’s handler could not be reached or ran past the time limit. The handler may still have acted.
502answer_too_largeDescriptionAn action’s handler responded with more than 1 MiB.
503project_unavailableDescriptionThe project’s database shard is temporarily unreachable. Retry shortly.
503live_unavailableDescriptionThe branch cannot stream changes yet. Retry shortly.
503log_unavailableDescriptionThe branch change log cannot be read right now for the requested GET /changes window. Retry shortly.
504ask_timeoutDescriptionA question took more than 120 seconds with the model’s turns.

Type a word or two to search every docs page.