Guides · Shipping & operations
Key and secret renewal
Renew service keys, org tokens, handler secrets, action secrets and sign-in credentials with zero downtime.
What you’ll build#
This guide renews every credential a production project holds without interrupting live traffic. Each workflow issues a replacement credential, cuts callers over and revokes the prior secret last.
Overlapping credential renewal
Replacement keys and tokens work alongside prior credentials until callers cut over.
The five project credential types differ in whether old and new secrets stay valid simultaneously during cutover.
| Credential | Held by | Overlap behavior |
|---|---|---|
| Service key | Backend servers, agents, schedules and webhooks | Overlap behaviorMultiple keys stay active simultaneously. |
| Org token | CI pipelines and admin scripts | Overlap behaviorMultiple tokens stay active simultaneously. |
| Hosted handler secret | Branch handler instances | Overlap behaviorHandler instances roll one at a time, reading the prior value until restart completes. |
| External action secret | Your external handler server | Overlap behaviorNo overlap. Each action holds a single secret. |
| Sign-in secrets | Project authentication service | Overlap behaviorReplaces in place without invalidating active user sessions. |
Sessions & keys compares credential types and permission scopes.
Before you start#
Sign in to the CLI with manage scope and list every active credential on your project before starting.
# Verify your active CLI login holds manage scopenapalm whoami # List active credentials and expiration dates across the projectnapalm keys ls notesnapalm tokens lsnapalm handlers ls notesnapalm actions ls notesnapalm sign-in show notesCredential expiration dates cannot be extended in place, so renew keys and tokens ahead of expiry.
Renew a service key#
A branch accepts multiple active service keys simultaneously, so the prior key and replacement key work side by side during rollout. Because a key’s label, branch, --read-only mode and per-key globals are fixed at creation, copy those flags onto the replacement key.
Issue the replacement key
Terminal# Inspect the current key's label, branch and access settingsnapalm keys ls notes # Issue a replacement key with matching settings (printed once on stdout)napalm keys create notes --label notes-api-2026-11 --read-only --days 90 # Compare row reach between the new and old keys to confirm identical permissionsnapalm keys ls notesnapalm keys reach notes <next-key-id>napalm keys reach notes <old-key-id>napalm keys lsdisplays each key’s target branch and read/write permissions alongside any bound globals. Pass matching--branchand--globalflags and set--daysbetween 1 and 365 days. Including a date in--labeldistinguishes successive keys clearly.The replacement key activates immediately and prints bare on standard output so you can pipe it directly into your secret manager.
Deploy the replacement key to your services
Update your application’s secret store and redeploy. Check Show activity above the project’s service keys in the console or run
napalm keys usageto confirm the old key’s last-used timestamp stops advancing. Napalm retains last-used timestamps for the lifetime of the branch so even quarterly jobs remain visible.Cut over schedules and row webhooks
Cron schedules and row-carrying webhooks bind to a specific service key ID and do not switch keys automatically. Revoking a key while a schedule or webhook still references it halts execution or delivery.
Terminal# Check whether any cron schedules or row webhooks depend on the old keynapalm schedules ls notesnapalm webhooks ls notes # Re-create the schedule bound to the replacement key between cron ticksnapalm schedules remove notes <query> --yesnapalm schedules add notes <query> '<cron>' --key <next-key-id> # Re-create the row webhook bound to the replacement key (prints a new signing secret)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>Re-create affected schedules and webhooks with
--key <next-key-id>, preserving existing--time-zoneand--variablessettings. Re-adding a webhook generates a freshNapalm-Signaturesecret, so update your webhook receiver’s secret at the same time.Revoke the old key
Terminal# Revoke the prior key once traffic drainsnapalm keys revoke notes <old-key-id>Revocation takes effect before
napalm keys revokereturns. Subsequent HTTP requests fail with401 invalid_key, and open live subscriptions close withkey_revokedwhile all other keys and user sessions continue uninterrupted.
Projects API documents the HTTP endpoints for automated key renewal scripts.
Renew the CI token#
Org tokens authenticate CI pipelines and automation scripts against the Control API. Multiple org tokens stay active at once so you can update repository secrets between runs without downtime.
# Inspect the active CI token's label, scope and expiration datenapalm tokens ls # Pipe a fresh 90-day manage token directly into your GitHub Actions secretnapalm tokens create --label deploy-2026-11 --scope manage --days 90 | gh secret set NAPALM_TOKEN # Revoke the prior token once a CI workflow succeeds with the replacementnapalm tokens revoke <old-token-id>- Actor identity
- Every org token acts on behalf of the organization member who created it.
- Scope and lifetime
--scopedefaults toreadunlessmanageis specified. Match the prior token’s Can column innapalm tokens ls.--daysdefaults to 30 days.- Standard output
napalm tokens createwrites only the raw token to stdout so you can pipe directly intogh secret setor a secret vault.- In-flight CI runs
- Wait for any in-progress CI workflows that started with the old token to finish before revoking.
- Revocation
- Revoked or expired org tokens immediately return
401 unauthorized.
Organization & billing documents the Control API token routes.
Renew a hosted handler secret#
Hosted handlers read external API credentials (such as Resend or Stripe keys) from branch-scoped environment secrets. Updating a secret triggers a rolling restart across your branch’s handler instances. Create the replacement key in your external provider first and keep the old provider key active until the rollout operation finishes.
# Prompt for the new secret value with echo disabled and return the rollout operation IDnapalm handlers secrets set notes RESEND_KEY --json # Wait for the rolling handler restart to completenapalm operations show <operation-id> --wait # List configured secret names (secret values are never returned)napalm handlers ls notes- Secret input
napalm handlers secrets setreads values interactively with echo off, from a file via--value-fileor from stdin via--value-file -so secrets never appear in shell history.- Per-branch scope
- Handler secrets are isolated per branch. Pass
--branchto update preview or staging branches that hold the same secret.
Hosted handlers covers secret naming rules and limits.
Renew an external action secret#
An external action handler on your own server presents its action secret to POST / to exchange call assertions for a caller-scoped session in call.db(). Because Napalm stores one secret per action and prints it only on creation, renewing an external action secret requires removing and re-adding the action during a brief maintenance window.
# Inspect the action's handler URL, timeout and read-only flagnapalm actions ls notes # Remove and re-add the action back to back to issue a new secretnapalm actions remove notes emailNote --yesnapalm actions add notes emailNote https://app.example.com/napalm/email-note --timeout 20- Between commands
- In the instant between
napalm actions removeandnapalm actions add, calls toemailNoteexecute as an ordinary read query without invoking the external handler. - Before redeploy
- Token exchanges using the prior secret fail at
/sign-in/agents/tokenwith401 invalid_clientuntil your handler server deploys the new secret. - Preserving flags
- Re-pass your prior
--read-only,--timeoutand--answer-schemaflags. Omitting--timeoutapplies the default 10-second timeout.
Renew sign-in secrets#
Built-in sign-in stores three external secrets: OAuth/OIDC client secrets, your SMTP password and your auth-webhook signing key. Because read endpoints never echo secrets back, each renewal resubmits the complete setting.
# Save the OAuth provider with a fresh client secret in NAPALM_CLIENT_SECRETnapalm sign-in provider notes github --client-id <client-id> # Save SMTP settings with a fresh password in NAPALM_SMTP_PASSWORDnapalm sign-in email notes --host smtp.example.com --sender "Notes <sign-in@example.com>" \ --username sign-in@example.com # Replace the webhook signing key in place via 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- OAuth client secret
- Create a second client secret in your identity provider’s console before updating Napalm, then delete the old secret at the provider afterward. Custom OIDC providers also require passing
--issuer-url,--display-nameand--slug(all listed innapalm sign-in show). - SMTP password
- Saving replaces the full SMTP configuration, so include
--portand--starttlswhenever your mail server uses non-default transport settings. - Webhook signing key
- Accept both the prior and replacement HMAC keys in your webhook receiver first, run
--replacewith the newNAPALM_SIGNING_KEYand drop the old key from your receiver once cutover finishes. - Active user sessions
- Updating OAuth, SMTP or webhook secrets never alters session-signing keys, so signed-in users stay signed in.
See Sign-in for your app and Identity providers & sign-in events for full setup details.
Check the renewal#
Confirm that revoked credentials fail immediately while active services, schedules, webhooks and CI continue running on their replacement secrets.
Verify the old service key is rejected
Terminalcurl -i https://notes.napalmdata.com/query/myNotes \ -H "Authorization: Bearer $OLD_KEY" -H "Content-Type: application/json" \ -d '{ "variables": {} }'Confirm the old key returns
401 invalid_keywhile the replacement key returns200.Check key and token status
napalm keys ls noteslists the prior key asrevokedand the replacement key asactive, andnapalm tokens lsconfirms the same for your CI org token.Inspect schedules and webhooks
napalm schedules ls notesandnapalm webhooks ls notesreference the replacement key’s label with zero revoked-key warnings.Trigger a CI run
Confirm
napalm whoamiinside CI prints the replacement token’s label and expiration date.Delete retired upstream secrets
Remove the old API key in your mail provider and the old client secret in your OAuth provider, then verify transactional emails and new OAuth logins still succeed.