---
title: "How often should you rotate API keys? A workable policy"
description: "A practical API key rotation policy: intervals by risk tier, what triggers an immediate rotation, who owns each key, and how to rotate without outages."
date: 2026-11-30
updated: 2026-11-30
author: "Keysquid team"
category: "Strategy"
tags: [api-keys, rotation, policy, compliance, strategy]
primary_keyword: "api key rotation policy"
draft: false
faq:
  - q: "How often should API keys be rotated?"
    a: "There is no single number in the standards. A workable default is every 30 days for keys that can move money or reach production data, every 90 days for other production keys, and every 180 days or on a developer's departure for development keys. Rotate immediately after any suspected leak, whatever the schedule says."
  - q: "Does NIST say how often to rotate API keys?"
    a: "Not as a fixed interval. NIST SP 800-57 Part 1 describes cryptoperiods, the time a key is authorised for use, and says they should be set according to risk factors such as the sensitivity of what the key protects and how exposed it is. Organisations choose the interval."
  - q: "Do I need to rotate keys that haven't leaked?"
    a: "Yes, if you can do it without breaking things. Most leaks are found late or never, so a schedule limits how long an unnoticed leak stays useful. It also proves your rotation process works before you need it in an emergency."
  - q: "Why don't we force password changes but do rotate API keys?"
    a: "Because they fail differently. NIST's digital identity guidelines advise against forcing people to change passwords on a schedule, since it leads to weaker, predictable passwords. A machine doesn't pick a weaker key when you rotate it, and API keys are copied into far more places, so scheduled rotation costs little and limits exposure."
sources:
  - https://csrc.nist.gov/pubs/sp/800/57/pt1/r5/final
  - https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
  - https://pages.nist.gov/800-63-4/sp800-63b.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html
---

**Rotate the keys that can hurt you most every 30 days, other production keys every 90, development keys every 180 or when someone leaves, and every key immediately after a suspected leak.** That's the short version of the policy below. No standard hands you those numbers: NIST and OWASP both say to set intervals by risk, and most teams never get past that sentence. This post turns it into tiers, triggers and owners you can actually write down and follow.

## What the standards actually say

NIST SP 800-57 Part 1 defines a **cryptoperiod**: the time a key is authorised for use. It says cryptoperiods should be set by weighing risk factors such as how sensitive the protected data is, how exposed the key is, and how costly a compromise would be ([NIST SP 800-57 Part 1 Rev. 5](https://csrc.nist.gov/pubs/sp/800/57/pt1/r5/final)). PCI DSS v4 then requires key changes at the end of whatever cryptoperiod you define, and replacement of any key known or suspected to be compromised.

The OWASP Secrets Management Cheat Sheet puts rotation alongside revocation and expiration as part of the secret lifecycle, and recommends automating it so it actually happens ([OWASP](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)). AWS's IAM best practices say to rotate access keys regularly for use cases that need long-term credentials, and to prefer temporary credentials where possible ([AWS IAM best practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)).

So the standards agree on three things: **pick an interval based on risk, write it down, and replace compromised keys at once**. The interval is yours to choose.

### API keys aren't passwords

NIST's digital identity guidelines advise against forcing people to change their passwords on a schedule ([NIST SP 800-63B](https://pages.nist.gov/800-63-4/sp800-63b.html)), and people sometimes take that to mean rotation is out of fashion. It isn't the same problem. Forced password changes push humans toward predictable patterns. A machine generates a fresh random key every time, and API keys are copied into many more places (CI, hosting platforms, laptops, logs), so a schedule limits exposure at little cost, as long as the rotation itself is safe.

## The policy: tiers, not one number

Sort every key into one of three tiers by what an attacker could do with it.

| Tier | Examples | Scheduled rotation | Notes |
| --- | --- | --- | --- |
| 1: money and production data | Stripe secret keys, AWS keys with write access, database admin credentials, payment provider keys | Every 30 days | Prefer restricted or scoped keys so the tier shrinks |
| 2: other production keys | OpenAI and Anthropic keys, email and SMS providers, analytics write keys, webhooks | Every 90 days | Add spend caps and expiry where the provider supports them |
| 3: development and test | Test-mode keys, sandbox accounts, personal dev keys | Every 180 days, and when an owner leaves | Should never work against production |

Two rules sit above the tiers:

- **Event triggers beat the calendar.** Rotate at once when a key appears in a commit, log, screenshot, ticket or chat; when a laptop is lost; when someone with access leaves; when a vendor that held the key reports a breach; or when usage looks wrong.
- **Shorter is better if it's automatic.** A 90-day schedule that's manual and dreaded is worse than nothing, because it trains people to skip it. If rotation is automated and safe, move tier 2 to 30 days too.

## Write it down in one page

A policy only works if people can find it and follow it in a hurry. Keep it to one page with four parts: the tier table, the list of event triggers, the owner rule, and the rotation procedure. Link it from your incident runbook, so the person handling a leak at 2am lands on the same steps as the person doing a routine rotation on a Tuesday. Review it twice a year, or after any incident where a key was involved, and record what you changed and why.

If you're audited (PCI DSS, SOC 2, ISO 27001), auditors will ask for exactly this: the defined cryptoperiods, evidence that keys were changed on time, and evidence that compromised keys were replaced. A rotation log with dates, key names and who approved each change answers all three.

## Who owns each key

Every key needs a named owner (a team, not a person who might leave) and a recorded list of where it's used. That list is what makes rotation safe: you can't replace a key everywhere if you don't know where everywhere is. A key with no owner should be revoked after a short notice period; if something breaks, you've found its owner.

## How to rotate without an outage

Most rotation outages come from revoking the old key before every consumer has the new one. The safe sequence works for almost any provider:

1. **Create** the new key with the same or narrower permissions, and add limits: spend caps, expiry, IP allowlists.
2. **Deploy** it to every place the old key lives, while the old key still works.
3. **Verify** each consumer is using the new key, using the provider's usage or last-used data.
4. **Wait** a grace period (an hour to a day, depending on how long your caches and deploys take).
5. **Revoke** the old key, and watch for errors.

Our guide to [rotating an OpenAI key without downtime](/blog/rotate-openai-api-key-without-downtime) walks through these steps for one provider, and the [rotation guides by provider](/rotate) cover the differences for Stripe, AWS, Twilio and others.

## Measure it

A policy you don't check decays. Track three numbers each month:

- **Keys past their rotation date**, by tier. This should be zero for tier 1.
- **Keys with no owner or no known usage.** Investigate, then revoke.
- **Time to rotate after a leak alert**, from detection to revocation. Aim for minutes, not days.

## Making it automatic

The policy above is easy to write and hard to follow by hand, because every rotation touches the provider's dashboard, your secret store and every deploy target. That's the part Keysquid does: set a schedule per key, and it creates the new key at the provider with your limits, pushes it to every synced destination, verifies it, and revokes the old one after the grace period. Values are encrypted to an agent you run, so Keysquid never sees them. See [which providers rotate automatically](/rotate) or [start a trial](/signup) and put your tier 1 keys on a 30-day schedule today.
