Reference · Control API
Actions, handlers & schedules
Attach external or hosted action handlers to deployed queries, manage handler secrets and machines and schedule cron jobs.
Actions#
Logic routes attach external or Napalm-hosted HTTPS handlers to gatekeeper queries, manage per-branch handler secrets and pools, and configure cron schedules and background job queues.
Gatekeeper actions and hosted handlers
Pair a deployed query with an external HTTPS endpoint or managed per-branch handler pool receiving short-lived ES256 caller assertions.
Transactional job queues and cron schedules
Run deployed queries or actions on five-field IANA cron schedules and inspect, retry, cancel or clear ext::napalm::Job runs without exposing row values.
| Route | Description | Scope |
|---|---|---|
GET /# | List the actions on main or a specified ?branch= | Scoperead |
POST / | Attach a handler to a deployed query and return the handler’s secret once | Scopemanage |
POST /# | Detach a query’s handler, leaving an ordinary deployed query | Scopemanage |
POST/projects/{id}/actions#
An action is a deployed query paired with an HTTPS handler for work an EdgeQL statement cannot do directly, such as sending mail or charging a card. The query runs first as the caller under your access policies and selects the permitted rows. Those rows go to the handler, and the handler’s response becomes the call’s result without exposing the intermediate query rows to the caller. When the query returns zero rows, the handler is never called and the request fails with 403 nothing_found.
POST /projects/{id}/actions
- ?branchstring
- Target branch name (defaults to
main). - querystringrequired
- Name of a deployed query on the branch. Each query accepts at most one handler.
- urlstringrequired
- HTTPS URL of the handler. The URL’s host must appear on the branch’s allowed hosts (
409 host_not_allowedotherwise). - isWriteboolean
- Whether the handler mutates external or database state (default
true). Read-only credentials cannot call a writing action (403 read_only), and read-only agents are not offered the action. - timeoutSecondsinteger
- Maximum handler execution window, 1 to 30 seconds (default 10).
- answerSchemaobject
- OpenAPI 3.0 schema describing the handler’s JSON response (JSON Schema with
nullable: trueand no$ref), up to 16 KiB. OmitanswerSchemato type the response as arbitrary JSON.
secret appears only in the creation response because the control catalog stores only its hash. Actions are branch settings, like webhooks, so schema pushes and query deploys leave existing actions intact. A new branch starts with zero actions and holds up to 128 actions. An action whose query is removed stays dormant until a query of that name is deployed again. Detach a handler with POST / and an empty body. GET / also returns allowedHosts for the branch.
{ "queries": [{ "name": "emailNote", "query": "select Note { id, title, body, email := <str>$email } filter .id = <uuid>$note" }], "isDeployed": true}curl https://api.napalmdata.com/projects/$PROJECT/actions \ -H "Authorization: Bearer $NAPALM_TOKEN" \ -H "Content-Type: application/json" \ -d { "query": "emailNote", "url": "https://app.example.com/napalm/email-note", "answerSchema": { "type": "object", "required": ["sent"], "properties": { "sent": { "type": "boolean" } } } }{ "query": "emailNote", "url": "https://app.example.com/napalm/email-note", "isWrite": true, "timeoutSeconds": 10, "answerSchema": { "type": "object", "required": ["sent"], "properties": { "sent": { "type": "boolean" } } }, "secret": "kq3vXb0s…"}Typing the answer#
Because an action returns the handler’s payload rather than the gatekeeper query’s rows, answerSchema replaces the row shape everywhere types are published: GET /openapi.json, clients written by napalm generate and the MCP tool’s outputSchema when the root schema is an object. Napalm publishes answerSchema without validating handler output at runtime, marks the OpenAPI operation x-napalm-action: true and omits is_dry_run from generated clients.
Calling an action#
Call an action at POST /query/{name} on the Project API with the query’s variables. The Project API forwards the handler’s status code, Content-Type and body alongside a Napalm-Action response header. Passing is_dry_run: true on the Project API runs the gatekeeper query inside a rolled-back transaction and never invokes the handler. Agents invoke actions as MCP tools or A2A skills without dry-run access. Subscribing to an action over POST /subscribe fails with an action_not_live error frame so gatekeeper rows never leak over a live stream.
Napalm POSTs each invocation to the handler URL with a 60-second ES256 JWT in Authorization: Bearer. Verify the signature against {project_url}/.
POST /napalm/email-note HTTP/1.1Host: app.example.comAuthorization: Bearer eyJhbGciOiJFUzI1NiJ9…Content-Type: application/json { "action": "emailNote", "variables": { "note": "2f1c7a9e-…", "email": "ada@example.com" }, "data": [{ "id": "2f1c7a9e-…", "title": "Launch plan", "body": "…", "email": "ada@example.com" }]}variables contains only parameters declared by the query, and data holds the gatekeeper rows. Outbound handler payloads cap at 64 KiB (413 request_too_large) and handler responses cap at 1 MiB (502 answer_too_large). Unreachable or timed-out handlers return 502 action_unreachable.
JWT assertion claims
- iss / audstring
- The project’s base URL as issuer and your HTTPS handler URL as audience.
- substring
- Caller identifier: either the user’s
ext::auth::IdentityUUID orkey:<hash>. - napalm_callerstring
"person"for a user session or agent grant, or"key"for a service key.- napalm_grantstring
- The
ext::napalm::AgentGrantUUID when invoked through an OAuth agent grant. - actobject
- For an agent call, the OAuth client actor
{ "sub": client_id }(RFC 8693). - napalm_read_onlyboolean
- Whether the caller credential is restricted to read-only operations.
- napalm_actionstring
- Name of the deployed action being executed.
- napalm_body_sha256string
- Hex SHA-256 digest of the raw request body so the assertion binds to this exact payload.
Acting as the caller#
A handler that reads or mutates project rows as the caller exchanges the assertion at POST / (RFC 8693 OAuth 2.0 Token Exchange) within the assertion’s 60-second lifetime, authenticating with the action’s secret as bearer token.
The project verifies the issuer, audience, action secret and live identity or grant, then issues a 60-second bearer token carrying the same caller identity, grant, act claim and read-only posture for follow-up /query calls. Service-key and scheduled-job invocations exchange for a 60-second token bound to that live service key.
curl https://<label>.napalmdata.com/sign-in/agents/token \ -H "Authorization: Bearer $ACTION_SECRET" \ -d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \ -d subject_token_type=urn:ietf:params:oauth:token-type:jwt \ --data-urlencode "subject_token=$ASSERTION"{ "access_token": "eyJhbGciOiJIUzI1NiJ9…", "issued_token_type": "urn:ietf:params:oauth:token-type:access_token", "token_type": "Bearer", "expires_in": 60}Hosted handlers#
| Route | Description | Scope |
|---|---|---|
GET /# | Read the hosted machines, deploy and secret names for main or a specified ?branch= | Scoperead |
POST /# | Deploy a runtime’s code as a tar of files | Scopemanage |
POST /# | Deploy your own container by digest | Scopemanage |
POST /# | Set the size and number of the branch’s machines | Scopemanage |
POST /# | Set or remove a secret the handlers read | Scopemanage |
POST /# | Remove the branch’s handlers and handler machines | Scopemanage |
Hosted handlers run action handlers on dedicated per-branch machines managed by Napalm. Deploying registers each named handler as an action of the branch and replaces the previous deployment atomically. napalm handlers deploy builds local source folders and uploads to /handlers/bundle.
{ "pool": { "id": "c41d7a52-0e3b-4f6a-9d18-7b2e5c9a1f04", "branch": "main", "state": "ready", "region": "dfw", "cpuType": "shared", "memoryBytes": 268435456, "nodes": [{ "slug": "handler-k3x9", "insertTime": "2026-11-10T18:02:11+00:00" }], "deployment": { "runtime": "typescript", "handlers": [ { "query": "lookUpPrice", "isWrite": false, "timeoutSeconds": 10, "answerSchema": null }, { "query": "sendReceipt", "isWrite": true, "timeoutSeconds": 30, "answerSchema": null } ], "imageBytes": 214873600, "insertTime": "2026-11-10T18:02:11+00:00", "creator": { "id": "9a0c…", "handle": "ada" } } }, "secrets": ["RESEND_KEY", "STRIPE_SECRET_KEY"]}pool is null when no hosted handlers exist on the branch, and deployment is null when secrets have been staged ahead of the first deploy. state transitions from provisioning to ready, or needsAttention if the rollout failed. secrets lists configured variable names without ever returning secret values.
POST /projects/{id}/handlers/bundle
- ?runtimestringrequired
typescript,python,go,rustordart.- bodytarrequired
- Built files under
app/, up to 128 MiB (400 invalid_bundlefor entries outsideapp/). Entry points areapp/handlers.mjs(TypeScript),app/handlers.py(Python) or executableapp/handlers(Go, Rust, Dart), paired withapp/handlers.json. Existing external actions with the same query name return409 conflict.
curl https://api.napalmdata.com/projects/$PROJECT/handlers \ -H "Authorization: Bearer $NAPALM_TOKEN" \ -H "Content-Type: application/json" \ -d { "image": "ghcr.io/acme/handlers@sha256:6b1f…c2e4", "handlers": [{ "query": "sendReceipt" }, { "query": "lookUpPrice", "isWrite": false }] }The other bodies
- image, handlers, registrystring, object[], object
POST /handlers: container digest, handler manifest entries and optionalregistry: { username, password }used once to copy the image into Napalm’s registry (400 invalid_imagewhen unreadable,409 handlers_not_availablewhen unavailable).- cpuType, memoryBytes, nodeCountstring, integer, integer
/handlers/size:sharedwith 256, 512, 1,024 or 2,048 MiB, orperformancewith 2,048 MiB, across 1 to 8 machines.- name, valuestring, string
/handlers/secrets: environment variable name and value up to 64 KiB, or omitvalueto delete the secret.
Every hosted-handler mutation returns 202 Accepted with an operationId, or 409 cluster_busy while a prior rollout is still running. Removing hosted handlers detaches the branch’s actions before tearing down the machines so in-flight requests never route to a stopping pool.
Schedules and jobs#
Schedule and queue routes run deployed queries or actions on recurring five-field cron schedules under a branch service key, and let org managers inspect, retry, cancel or clear background jobs without exposing row variables.
Time-zoned cron schedules
POST / triggers a deployed query or action on a five-field cron expression in any IANA time zone.
Scoped ndb_ execution keys
Every scheduled run executes under the access policies and globals of its bound branch ndb_… service key.
| Route | Description | Scope |
|---|---|---|
GET /projects/{id}/jobs# | List the schedules and newest jobs on main or a specified ?branch= | Scoperead |
POST / | Put a deployed query on a schedule | Scopemanage |
POST /# | Remove a query’s schedule | Scopemanage |
POST /# | Make a failed job due again | Scopemanage |
POST /# | Cancel a waiting job, or a running job whose handler took the work on | Scopemanage |
POST /# | Delete finished jobs that ended more than a number of days ago | Scopemanage |
POST/projects/{id}/schedules#
A job is a deployed query or action queued inside PostgreSQL to run asynchronously, and a schedule queues jobs on a cron clock. Control routes let org managers configure cron schedules, inspect queue depth and retry or cancel individual jobs without reading application row variables.
POST /projects/{id}/schedules
- ?branchstring
- Target branch name (defaults to
main). - querystringrequired
- Name of a deployed query on the branch. Each query accepts one schedule (
409 conflictotherwise). - cronstringrequired
- Five-field cron expression (minute, hour, day of month, month, day of week). Unschedulable expressions or unknown zones fail with
400 invalid_schedule. - timeZonestring
- IANA time zone name such as
America/Los_Angeles(defaults toUTC). - keyIduuidrequired
- Live service key UUID on the branch. Every scheduled run executes under that key’s access policies.
- variablesobject
- JSON variables passed to each scheduled run, up to 16 KiB.
A new branch starts with zero schedules and holds up to 128 schedules. Send POST / with no body to delete the schedule and cancel the waiting next-run job.
GET /projects/{id}/jobs accepts optional ?branch, ?status (pending, running, completed, failed, cancelled), ?query and ?limit (up to 200). Job variables are omitted from control responses so org tokens stay value-blind, and caller reports only kind and via. type is ext::napalm::Job for a plain job, or the project’s own type that extends it. lastRun carries the newest attempt’s timeoutTime, and acceptTime once the action’s handler took the work on. stepCount and lastStep count the finished steps and name the newest. A step’s answer is never listed.
retry and cancel take no request body. retry re-queues a failed or cancelled job (returning 409 job_not_failed otherwise), while cancel stops a waiting job or a running job whose handler accepted async work (returning 409 job_not_pending otherwise). Cancelled jobs stay in the table with status cancelled, do not increment failedCount and can be retried later. Cancelling a scheduled job skips only that run, and an active handler receives job_run_ended on its next callback.
POST / takes days (0 to 3650) and an optional isEveryType, deleting completed, failed and cancelled jobs (along with their runs and steps) that ended more than days days ago. Only base ext::napalm::Job rows are cleared unless isEveryType is true, and any job still linked from another project row is kept. The response returns cleared with the deleted count and hasMore when matching jobs remain, so repeat the call until hasMore is false.
curl https://api.napalmdata.com/projects/$PROJECT/schedules \ -H "Authorization: Bearer $NAPALM_TOKEN" \ -H "Content-Type: application/json" \ -d { "query": "rollUpUsage", "cron": "0 3 * * *", "timeZone": "America/Los_Angeles", "keyId": "0b6f1f5e-2a4c-4d7e-9f3b-8c1d2e3f4a5b" }{ "query": "rollUpUsage", "cron": "0 3 * * *", "timeZone": "America/Los_Angeles", "keyId": "0b6f1f5e-2a4c-4d7e-9f3b-8c1d2e3f4a5b", "nextTimes": ["2026-11-11T11:00:00+00:00", "2026-11-12T11:00:00+00:00", "2026-11-13T11:00:00+00:00"]}{ "schedules": [{ "query": "rollUpUsage", "cron": "0 3 * * *", "timeZone": "America/Los_Angeles", "key": { "id": "0b6f1f5e-2a4c-4d7e-9f3b-8c1d2e3f4a5b", "label": "nightly-rollup", "isLive": true }, "hasVariables": false, "nextTime": "2026-11-11T11:00:00+00:00", "last": { "status": "completed", "scheduledTime": "2026-11-10T11:00:00+00:00", "finishTime": "2026-11-10T11:00:01+00:00", "error": null } }], "jobs": [{ "id": "c2e8d4a1-5b3f-4e7a-8d9c-0f1a2b3c4d5e", "type": "default::ImportJob", "query": "importRows", "status": "running", "runTime": "2026-11-10T18:00:00+00:00", "expireTime": "2026-11-11T18:00:00+00:00", "scheduledTime": null, "insertTime": "2026-11-10T18:00:00+00:00", "finishTime": null, "caller": { "kind": "session", "via": "http" }, "attemptCount": 1, "lastRun": { "status": "running", "startTime": "2026-11-10T18:00:00+00:00", "finishTime": null, "error": null, "timeoutTime": "2026-11-10T19:00:01+00:00", "acceptTime": "2026-11-10T18:00:01+00:00" }, "stepCount": 2, "lastStep": { "name": "train", "finishTime": "2026-11-10T18:20:00+00:00" } }, { "id": "7f3a91c2-4e8b-4a1d-9c0e-1b2d3e4f5a6b", "type": "ext::napalm::Job", "query": "rollUpUsage", "status": "pending", "runTime": "2026-11-11T11:00:00+00:00", "expireTime": "2026-11-12T11:00:00+00:00", "scheduledTime": "2026-11-11T11:00:00+00:00", "insertTime": "2026-11-10T11:00:01+00:00", "finishTime": null, "caller": { "kind": "key", "via": "schedule" }, "attemptCount": 0, "lastRun": null, "stepCount": 0, "lastStep": null }], "pendingCount": 1, "runningCount": 1, "failedCount": 0}