Secret rotation is the planned replacement of a credential before it is stolen, copied into a log, or left in a repo that no longer needs it. Waiting for an incident means you rotate under a clock, with half the clients still holding the old value.

A rotation window is the overlap during which both the old secret and the new one are accepted. That overlap is the product. Without it, every consumer breaks at the same minute. With a sloppy window, the old secret never dies and the exercise was theater.

What rotation protects

API keys, signing keys, database passwords, and third-party tokens all age. They land in CI variables, laptop shells, crash dumps, and vendor dashboards. Rotation shrinks the time a leaked copy stays useful.

Protect these classes first:

Design choices that matter

Publish the window the same way you publish an API change. Operators and partners need dates, not a surprise 401.

Prefer two active key versions over a flag that disables verification. For signing keys, accept signatures from version N and N-1, and sign new tokens with N only.

Common mistakes

Rotation fails in boring ways.

Safe rollout

Write the runbook before the first scheduled rotation. Name who creates the new secret, who updates each consumer, who watches error rates, and who revokes.

Do a dry run against staging with a synthetic client that still sends the old value until cutoff, then a second client on the new value. Confirm both succeed during the window and only the new value succeeds after it.

On production, announce the window in the partner changelog. Watch auth failure rate, not just CPU. Keep the previous secret revocable in one action if you see unexpected use from a host you do not recognize. That is different from leaving it valid until you are sure.

What to tell operators

Document the header or field that carries the key ID, the date format you use for cutoff, and how a client should reload config without a full outage. Ask partners to support two active keys. A client that can hold only one value will skip the window and page you at cutoff.

Schedule rotation for credentials that touch customer data. A window you can explain in a sentence is a control. A secret that never changes is a standing exception.