Skip to the page

Learn · Schema & access

Sessions & keys

User sessions and service keys query one project under its access rules. Org tokens manage projects and never read project rows.

In the schema
—

Credential overview#

Napalm separates end-user sessions, backend data-plane keys and infrastructure control tokens across three non-overlapping credentials. No credential crosses between the Project API and Control API, and every data-plane call runs under your schema’s access policy rules.

User session (eyJ…)

Signed JWT session or short-lived browser page token minted at /sign-in and bound to global caller on one branch.

Service key (ndb_…)

Branch-scoped bearer credential running with global caller := {}, serviceGlobals and optional --read-only or --allow-query limits.

Org token (napalm_…)

Control API token (read or manage scope on api.napalmdata.com) that manages clusters and schemas without reading row values.

CredentialIssued byTarget API and identityHard boundaries
User sessionProject sign-in (/sign-in/*)Target API and identityProject API as an ext::auth::Identity (global caller) + userGlobalsHard boundariesScoped to one project and branch. Cannot call the Control API or bypass access policies.
Service key (ndb_…)Org manager (Console, CLI or Control API)Target API and identityProject API with global caller := {} + serviceGlobalsHard boundariesScoped to one project and branch, and to named deployed queries where the key lists them. Cannot call the Control API, bypass policies or impersonate a user.
Org token (napalm_…)Org manager (Console, napalm login or CLI)Target API and identityControl API (read or manage scope)Hard boundariesManages infrastructure and configuration only. Value-blind to application rows.

User sessions#

User sessions are signed JWTs issued by a project’s built-in /sign-in/* flows (OAuth, OpenID Connect, email and password, magic links or WebAuthn passkeys) and by OAuth 2.1 agent delegation grants (/sign-in/agents/*). A user stays signed in for 14 days by default and up to 365 days when configured. The session’s refresh token renews the hour-long bearer token. Signing out ends the session at the project. See Session renewal and sign-out.

On every request, Napalm checks the session’s signature, issuer and expiry, confirms the ext::auth::Identity still exists and binds the identity to global caller. See Sign-in for the client PKCE exchange and OAuth 2.1 agent consent flows.

Service keys#

Service keys authenticate backend servers, background workers, CI jobs or internal agents against a single project and branch (main by default). Requests using a service key execute with global caller := {} and any serviceGlobals configured on the endpoint.

Allowlisted queries & pre-issuance reach

Keys created with --allow-query execute only named deployed queries across HTTP, MCP and A2A, while napalm keys reach --new previews reachable row counts before issuance.

Issuing a service key
napalm keys create notes --label laptop --read-only --save
Created laptop for notes, read-only, for 30 days
ndb_Qm9zZS1yZWQtZXhhbXBsZS1rZXk
Saved for napalm query and napalm mcp.
Shown once
The plaintext ndb_… secret is returned only at creation. Napalm keeps only a hash of the secret.
Read-only ceiling
Keys created with --read-only (isReadOnly: true) can run reads and live subscriptions. Napalm rejects any insert, update, delete or write action.
Explicit expiry
Every service key carries a required TTL between 1 and 365 days.
Pre-issuance reach audit
Run napalm keys reach notes --new --read-only (or check the preview in the console’s Issue Key dialog) to see exact per-type row counts the key could select, update or delete before creating it. See Auditing access.
Immediate revocation
Revoke a key in the console or with napalm keys revoke. Subsequent requests fail immediately, and open SSE live streams using that key terminate within seconds.
Per-key globals
Set per-key globals at creation: napalm keys create notes --label trainer --global default::role=trainer. Per-key globals override the branch’s serviceGlobals for that key’s calls, queued jobs and webhook reads, so a rule on global role can tell one key from another. A per-key global can also identify one customer of your app and restrict the key to that customer’s rows. Service keys for one organization’s servers shows the rule. Only an org manager sets a service key’s globals, whereas an end user sets globals on an agent grant, so read agent-grant globals only inside deny policies (see Grants held to one tenant). Per-key globals are fixed at creation. Issue a replacement key and revoke the previous key when globals change. Before creating the key, napalm explain-access notes <object-id> --new --global default::role=trainer explains access on one object for a trainer key.
Deployed queries only
Name the deployed queries a key may call at creation: napalm keys create notes --label worker --allow-query listNotes --allow-query addNote. The key calls only those queries over HTTP, MCP, A2A and the Gel protocol. Any other deployed query answers 403 forbidden. Ad-hoc statements, questions, searches, schema reads and GET /changes answer 403 deployed_query_required regardless of the branch’s passthrough setting. Each listed query must already be deployed on the key’s branch when you create the key. Issue a replacement key and revoke the previous key to change the allowlist.
Call budget
Cap a key’s calls at creation: napalm keys create notes --label partner --call-budget 1000/hour. The key makes at most 1,000 calls in each hour. A budget holds 1 to 1,000,000,000 calls in each hour or each day. Hours and days follow the clock in UTC. A call past the budget answers 429 call_budget_reached with Retry-After and runs nothing. A refused call counts against no budget. The keys list and napalm keys usage show the calls this period against the budget. Issue a replacement key and revoke the previous key to change the budget. See Limits.
Audit labels
Labels (up to 128 characters) identify the key in the console, query telemetry and audit logs.

Org tokens#

Org tokens authenticate the napalm CLI, GitHub Actions and infrastructure scripts against the Control API (https://api.napalmdata.com) in one of two scopes.

read
Inspect projects, clusters, branches, jobs, service key metadata, reach counts, query insights, charges and audit activity without reading row values.
manage
All read operations plus schema migrations, query deployments, actions, webhooks, key issuance and revocation, branches, backups, restores and cluster scaling.

Issue org tokens interactively with napalm login (30-day default TTL), from the console or with napalm tokens create.

Renewal and least privilege#

Scope every backend key and CI token to the narrowest branch, query list and permission ceiling each caller needs, and renew credentials ahead of expiry without dropping live traffic.

Zero-gap credential cutover

Issue a replacement ndb_… service key or napalm_… org token, shift servers, schedules and webhooks onto the new secret, then run napalm keys revoke.

Keep keys server-side
Store ndb_… service keys and napalm_… org tokens only in backend secret managers or CI secrets. Never ship service keys or org tokens in browser bundles or mobile apps.
Scope down by default
Issue --read-only service keys for reporting jobs and coding agents, --allow-query keys for a service that calls a few deployed queries and --scope read org tokens for pull-request check workflows.
Renewal without downtime
Create a replacement service key or org token, deploy the new secret to your services, verify traffic and then revoke the old credential.
Incident response
Revoke a compromised token immediately via the console or CLI. Then run napalm activity (GET /events) or napalm changes to review actions taken with the token.

Key and secret renewal walks through each renewal, with the schedules and webhooks that name a key and the secrets of handlers, actions and sign-in.

Token prefixes#

Distinct string prefixes make each credential recognizable in environment configs, audit logs and automated secret-scanning rules.

PrefixCredential type
ndb_Project service key (data-plane bearer token scoped to one project and branch).
napalm_Org token, the bearer token for the control API at https://api.napalmdata.com.
eyJ…Signed JWT user session, OAuth 2.1 agent access token or action assertion.

Type a word or two to search every docs page.