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

Sign-in issues a JWT bound to global caller on one project branch.

Service key

Backend keys authenticate servers and workers on one branch under service globals.

Org token

Control tokens manage clusters, branches and schemas without reading row values.

Each credential targets a single API surface and enforces hard scope boundaries.

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 allowlisted deployed queries when configured. 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 and never reads 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.

Scoped service keys

Service keys enforce read-only mode, query allowlists, call budgets and reach previews.

Create a service key from the CLI, the console or the Control API with an explicit expiration window.

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.

Each service key enforces strict expiration, scope and revocation rules.

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 with napalm keys create notes --label trainer --global default::role=trainer. These values override the branch’s serviceGlobals on calls, queued jobs and webhook reads so policies can distinguish roles or pin a key to one customer (see Service keys for one organization’s servers). Org managers set service-key globals, whereas end users pick consent globals on agent grants, so read consent globals only inside deny policies (see Scoping grants with consent globals). Per-key values are fixed at creation, so issue a replacement key and revoke the old key when values change. Test access beforehand with napalm explain-access notes <object-id> --new --global default::role=trainer.
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 can call only those queries over HTTP, MCP and A2A. Any other deployed query returns 403 forbidden. Ad-hoc statements, questions, searches, schema reads and GET /changes return 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. Budgets accept 1 to 1,000,000,000 calls per UTC hour or day. Calls past the budget return 429 call_budget_reached with Retry-After without running, and rejected calls do not count toward the budget. Check usage in the console or with napalm keys usage, and issue a replacement key when you need a different 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.

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 renewing service keys used by schedules and webhooks alongside handler, action and sign-in secrets.

Zero-downtime key renewal

Deploy a replacement key to your services before revoking the expiring credential.

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.