Problem
Long-lived API keys leak through logs, repos and former employees, yet revoking one instantly breaks every integration that uses it. Teams therefore avoid rotating, extending exposure indefinitely.
Also known as: credential-rotation, dual-key-rotation
Replace credentials regularly or on compromise without causing downtime for clients.
Long-lived API keys leak through logs, repos and former employees, yet revoking one instantly breaks every integration that uses it. Teams therefore avoid rotating, extending exposure indefinitely.
Rotation turns credential compromise from a permanent problem into a bounded one. The core trick is overlap: two keys valid at once so clients switch without a coordinated cutover.
Good developer experience decides whether rotation happens. Provide clear dashboards showing key age and last use, email owners before expiry, and offer an API for automated rotation. Document the rotation procedure in your integration guide and exercise the emergency revoke path in game days.
Key format: sk_live_ab12cd34_<random 32B> # prefix = lookup id
Store: { prefix, sha256(secret), scopes, created, expires, lastUsed }
T0 client has key A
T1 client creates key B (A and B both valid)
T2 client deploys B; A lastUsed stops advancing
T3 client or policy revokes A (only B valid)
Verify: lookup by prefix, constant-time compare hash
Alerting on a revoked key still being presented can reveal a leak or a forgotten integration.
Low — key store and hashing
Medium — lifecycle automation and reminders
Low
Old key never revoked because usage tracking is missing
Plaintext keys stored server-side and leaked in a breach
Emergency revoke breaks clients with no second key ready