Skip to the page

Guides · Shipping & operations

Key and secret renewal

Renew service keys, org tokens, handler secrets, action secrets and sign-in secrets without a gap in service.

API
—
In the schema
—

What you’ll build#

This page renews each credential a live app holds without a gap in service. Every renewal issues a successor, deploys the successor with the app and revokes the old credential last. Credentials differ in whether the old and new values overlap during rollout.

Overlapping credential renewal

Issue a successor ndb_… service key or napalm_… org token while the active credential drains, cut over schedules and webhooks, then revoke the old credential.

CredentialHeld byOverlap
Service keyYour servers, agents, schedules and webhooksOverlapTwo keys work at once.
Org tokenCI and scriptsOverlapTwo tokens work at once.
Hosted handler secretThe branch’s handler instancesOverlapHandler instances restart one at a time. Some calls read the old value until the rollout finishes.
Action secretYour action handler’s serverOverlapNo overlap. An action holds one secret.
Sign-in secretsThe project’s sign-inOverlapEach save replaces the old value. People stay signed in.

Sessions & keys compares the credentials and each credential’s access.

Before you start#

You need a live project like the first app’s and a CLI signed in with manage scope. Inspect your active token scope and list every credential on the project first.

Terminal
# Your token's scope. Issuing and revoking need a token that can make changes.napalm whoami # The project's credentials. Keys and tokens show an expiry date.napalm keys ls notesnapalm tokens lsnapalm handlers ls notesnapalm actions ls notesnapalm sign-in show notes

An expiry date cannot be extended in place, so renew each key or token ahead of the listed expiration date.

Renew a service key#

A project accepts several live service keys at once, so the old key and the next key work side by side during the change. A key’s label, branch, read-only setting and globals are fixed at creation. The next key copies the old key’s settings.

  1. Issue the next key

    Terminal
    # The old key's label, branch and access, to copynapalm keys ls notes # The next key with the same settings, shown once on standard outputnapalm keys create notes --label notes-api-2026-11 --read-only --days 90 # The next key's id, listed first. Equal counts mean equal access.napalm keys ls notesnapalm keys reach notes <next-key-id>napalm keys reach notes <old-key-id>

    napalm keys ls shows each key’s branch, and the Can column shows read or write access with any globals. Pass --branch and each --global the old key holds. --days takes 1 to 365 days. A date in the label tells the two keys apart in the list.

    The new key works as soon as napalm keys create prints it. Only the key value goes to standard output, so you can pipe it straight into a secret store.

  2. Deploy the next key

    Put the next key where the service reads secrets and deploy the service. In the console, Show activity above a project’s service keys gives each key’s last use, and napalm keys usage prints the same list. The old key’s last use stops moving once every instance of the service runs with the next key. Napalm keeps a key’s last use for as long as the branch exists, so a key that a quarterly job uses still shows the quarter’s call.

  3. Move schedules and webhooks to the next key

    A schedule runs each job as one key, and a webhook that sends rows reads the rows as one key. Napalm does not move schedules or webhooks to the next key automatically. Once you revoke the old key, any schedule or webhook still bound to it stops running or delivering.

    Terminal
    # Each schedule's key and each rows webhook's key, by labelnapalm schedules ls notesnapalm webhooks ls notes # A schedule on the next key, removed and added between two runsnapalm schedules remove notes <query> --yesnapalm schedules add notes <query> '<cron>' --key <next-key-id> # A rows webhook on the next key. The new signing secret prints once.napalm webhooks remove notes https://api.example.com/hooks/napalm --yesnapalm webhooks add notes https://api.example.com/hooks/napalm --event note_changed --key <next-key-id>

    A schedule and a webhook each change key by being removed and added again. Add the schedule with the same cron, --time-zone and --variables as before. The webhook added again gets a new signing secret, so deploy the receiver with the new secret at the same time.

  4. Revoke the old key

    Terminal
    # Once the old key's calls stopnapalm keys revoke notes <old-key-id>

    The old key stops working before napalm keys revoke answers. The next call with the old key answers 401 invalid_key, and an expired key gets the same answer. A live stream still open with the old key ends with a key_revoked error. No other key and no person’s session changes.

Projects lists the control API’s key routes for scripts.

Renew the CI token#

An org token signs CI and scripts in to the control API. Two org tokens work at once, so CI moves to the next token between two runs.

Terminal
# The old token's label, access and expirynapalm tokens ls # The next token, piped into the repository's secret. Napalm shows the token once.napalm tokens create --label deploy-2026-11 --scope manage --days 90 | gh secret set NAPALM_TOKEN # After a CI run with the next token passesnapalm tokens revoke <old-token-id>
Whose token
An org token acts as the person who created it, so the next token acts as you.
Scope and lifetime
--scope is read unless you pass manage. Copy the old token’s access from the Can column of napalm tokens ls. --days sets the lifetime and defaults to 30 days.
Standard output
napalm tokens create prints the token alone on standard output, so the pipe carries the token straight into the secret.
Runs in progress
A run that started before the change still holds the old token. Revoke the old token after those runs finish.
Revocation
The next request with a revoked or expired token answers 401 unauthorized.

Organization & billing lists the token routes.

Renew a hosted handler’s secret#

A hosted handler reads a secret like a mail provider’s key as an environment variable. A new value reaches the handlers through a rolling operation that restarts the branch’s handler instances one at a time. Handlers keep answering during the rollout, and some calls still read the old value until the last instance restarts. Create the new credential at the provider first and keep the old credential active there until the operation finishes.

Terminal
# The new value at a prompt with echo off. --json prints the operation's id.napalm handlers secrets set notes RESEND_KEY --json # Wait for the rollout to finish with the new valuenapalm operations show <operation-id> --wait # The branch's secret names. Napalm never shows a value.napalm handlers ls notes
The value
napalm handlers secrets set reads the value at a prompt, from a file with --value-file or from standard input with --value-file -. The command line never carries the value.
Branches
Each branch keeps separate secrets. Set the new value with --branch on each branch whose handlers read the old value.

Hosted handlers covers secret names and storage.

Renew an action’s secret#

An external action handler on your own server holds the action’s secret and presents that secret to exchange each invocation for the caller’s session in call.db(). Napalm stores one secret per action and prints it only when the action is added. Issuing a new secret requires removing and re-adding the action, so this renewal has no overlap. Run it during a quiet window.

Terminal
# The action's handler, time limit and read-only setting, to copynapalm actions ls notes # Back to back. The second command prints the new secret once.napalm actions remove notes emailNote --yesnapalm actions add notes emailNote https://app.example.com/napalm/email-note --timeout 20
Between the commands
A call runs emailNote like any other deployed query, and the handler gets no call.
Until the deploy
The old secret no longer trades a call. The trade at /sign-in/agents/token answers 401 invalid_client until the server holds the new secret.
The same settings
Add the action with the same --read-only, --timeout and --answer-schema as before. napalm actions add sets a 10-second limit when --timeout is left out.

Renew the sign-in secrets#

The project’s sign-in keeps three secrets of yours: each OAuth provider’s client secret, the mail server’s password and the key that signs sign-in events. No answer returns a secret, so each renewal sends the full setting again.

Terminal
# The client id again, and the new client secret from NAPALM_CLIENT_SECRETnapalm sign-in provider notes github --client-id <client-id> # Every mail server setting again, and the new password from NAPALM_SMTP_PASSWORDnapalm sign-in email notes --host smtp.example.com --sender "Notes <sign-in@example.com>" \  --username sign-in@example.com # The same address and events, and the new signing key from NAPALM_SIGNING_KEYnapalm sign-in webhooks add notes https://app.example.com/hooks/sign-in \  --event IdentityCreated --event EmailVerified --replace https://app.example.com/hooks/sign-in napalm sign-in show notes
Client secret
Make the new secret in the provider’s console. If the provider lets a client hold two secrets, keep the old secret there until the save. An OpenID Connect provider also takes --issuer-url, --display-name and --slug again. napalm sign-in show lists each provider’s client id, issuer and slug.
Mail password
The save replaces the whole mail server setting. Pass --port and --starttls again when the old setting had those flags.
Event key
You choose this key and share it with your route. --replace swaps the destination in one step, so let the route accept the old key and the new key until the save.
People
No sign-in save changes the key that signs sessions, so people already signed in stay signed in.

Sign-in sets up the providers. Identity providers & sign-in events sets up the event route.

Check the renewal#

Confirm that revoked credentials fail immediately while active services, schedules, webhooks and CI continue running on their replacement secrets.

  1. Call the project with the old key

    Terminal
    curl -i https://notes.napalmdata.com/query/myNotes \  -H "Authorization: Bearer $OLD_KEY" -H "Content-Type: application/json" \  -d '{ "variables": {} }'

    The answer is 401 invalid_key. The same call with the next key answers 200.

  2. List the keys and tokens

    napalm keys ls notes shows the old key as revoked and the next key as active. napalm tokens ls shows the same for the CI token.

  3. Read the schedules and webhooks

    napalm schedules ls notes and napalm webhooks ls notes name the next key’s label. Neither command prints a warning about a key that stopped working.

  4. Run CI once

    A step that runs napalm whoami prints the next token’s label and expiry.

  5. Delete the old provider credentials

    Delete the old mail key and the old client secret at each provider. The hosted handler still sends mail, and a new sign-in with GitHub succeeds.

Type a word or two to search every docs page.