🔑 Rotation Process

API Key Rotation Best Practices
A Practical Checklist

Rotation is two things: a fixed sequence of steps, and a calendar reminder that tells you when to run them. The steps haven't changed in a decade. The cadence is up to you. Here is the checklist most teams should use, and the parts most teams skip.

The rotation sequence, step by step

Most rotations follow the same six steps. The order matters. Skipping any of them is what causes the outages and the audit findings.

  1. 1
    Provision the new key. In the provider dashboard or via API, generate a replacement. Note the key ID and scope. Do not revoke the old one yet.
  2. 2
    Update environment variables and secret stores. Push the new key to every environment that consumes it: production, staging, CI runners, scheduled jobs. Use environment variables, never hardcoded values.
  3. 3
    Deploy. Roll out the new key to running services. Most platforms restart on env-var change, but verify each service has actually picked up the new value.
  4. 4
    Verify traffic on the new key. Check the provider's per-key usage logs. New key should show activity. Old key should drop to zero over the transition window (usually a few hours to 72 hours depending on your scheduled jobs).
  5. 5
    Revoke the old key. Once old-key traffic is zero, revoke it in the provider dashboard. This is the step everyone forgets. An unrevoked old key is a rotation that never happened.
  6. 6
    Log it and reset the reminder. Record the key ID, date, operator, and next rotation date. Reset your 90-day reminder so the cycle continues.

The transition period is the whole game

Nearly every rotation outage comes from the same mistake: revoking the old key before every consumer has migrated to the new one. The fix is the transition period, the window where both keys are valid at the same time. Most providers support this natively.

How long should the window be? It depends on what consumes the key:

Transition windows by consumer type

  • Stateless production services: a few hours after deploy
  • Services with cached config: 24 hours
  • Daily cron or batch jobs: 48 hours after deploy
  • Weekly scheduled jobs: 8 days minimum
  • Monthly reports or invoices: 32 days minimum
  • External integrations you can't deploy: until the partner confirms

If you skip the transition period and revoke immediately, you'll get paged. If you stretch it forever and never revoke, you have not rotated. The old key is still valid, the rotation logs say "done," and the audit finding comes anyway.

Mistakes that turn rotations into incidents

Each of these has caused a real outage on a real team.

🚫

Revoking before verification

You deploy the new key, refresh once, then revoke. Five minutes later your cron job that runs every six hours wakes up and fails because nobody told it about the rotation.

📦

Updating one env, missing four

Production gets the new key. Staging, the CI pipeline, the scheduled report runner, and the contractor's local .env file do not. The old key is in use across half your stack.

🗑️

Never revoking the old key

The transition period becomes permanent. A year later you have eight valid keys for one service, each with full access, all leaked somewhere different.

📝

No audit trail

You rotated, but nobody wrote down when or by whom. The SOC 2 auditor asks for the rotation log and you have to reconstruct it from Slack messages.

🔑

Hardcoded keys in the codebase

The key was committed in 2022. Now you're rotating the live env var, but the value also lives in three git branches and a Dockerfile. Pull from secrets, not source.

Rotating only when someone remembers

The most common failure mode. There was no rotation policy, no calendar entry, no follow-up. Someone noticed last quarter that the key was three years old.

The audit trail you should keep

SOC 2, ISO 27001, PCI DSS, and most compliance frameworks expect a documented record of rotations. The format doesn't matter much. The existence of the record does.

Minimum fields per rotation

  • Service / key name: Stripe live key, OpenAI prod, etc.
  • Old key ID: last 4 or 6 chars of the key identifier
  • New key ID: last 4 or 6 chars of the replacement
  • Rotation date: when the new key went live
  • Revocation date: when the old key was disabled
  • Operator: name or initials of the person who did it
  • Next rotation due: rotation date + 90 days (or your cadence)

A shared spreadsheet works. A Notion table works. A row in a database works. What does not work is "we definitely did this, we just don't remember exactly when."

The checklist runs itself, when you remember to start it

The full process takes about 30 minutes if you've done it before. The longer transition windows happen in the background. The hard part is not the work, it's the 90-day gap of forgetting in between.

See the main API key rotation reminder page or read how often to rotate for the cadence side of the question.

Set a reminder for your next rotation date. Get an email with enough time to actually run the checklist.

Create a Reminder

Done in seconds. No sign-up required.

Common questions about API key rotation process

How do you rotate API keys without downtime?

Use a transition period. Most providers let two valid keys exist at the same time. Provision the new key, deploy it to production, watch logs until traffic on the old key drops to zero, then revoke. The transition period is the gap that prevents downtime: usually a few hours to a day.

What is a key rotation transition period?

The window where both the old and new key are valid simultaneously. It lets cached configurations, queued jobs, scheduled tasks, and slow-deploying environments finish using the old key before you revoke it. Without a transition period, you cause an outage every time you rotate.

How long should the transition period be?

Long enough that every legitimate consumer of the old key has migrated. For stateless production services, a few hours is enough. For systems with cached config, batch jobs, or weekly cron schedules, extend to 24 to 72 hours. If you have a job that runs monthly, hold the old key for at least a month.

Should I keep a backup of the old key?

No. Once you have verified the new key works and the old key has zero traffic, revoke it and delete it everywhere. Keeping an old key around in case of rollback defeats the purpose of rotation. If the rotation fails, generate yet another new key.

How do I know which services use a key?

Most providers offer per-key usage logs. Check the dashboard for the last 24 hours of activity by key ID before revoking. If the old key shows nonzero traffic after the deploy, find the service still using it before you revoke. A surprise outage is the rotation failing loudly.

What should I log after rotating?

The key ID rotated, the date, the operator, and the next rotation due date. Most teams keep this in a simple spreadsheet or in their incident tracker. Auditors want to see a paper trail proving rotations happen on cadence, and so does future-you when you need to know whether a key was rotated before a known leak window.

Set Your Next Rotation Reminder

Free. No account. Get notified before the date so you actually run the checklist instead of pushing it again.

Create API Key Rotation Reminder

Last modified: