API Key Management (Issuance, Rotation, Scoping)
On this page
API Key Rules
- Never ship keys to browsers or mobile apps as a secret.
- Scope keys (per service, per environment, per permission set).
- Prefer short-lived tokens or mTLS for internal services.
Scoping Model
- Read-only vs write separated.
- Per-tenant keys where needed.
- Explicit allowlist of endpoints/actions per key.
Rotation Strategy
Rotate key: 1) Create new key (keep old valid) 2) Deploy consumers with new key 3) Verify success rate and error rate 4) Revoke old key 5) Search logs for old key id usage
Leak Detection
- Secret scanning in CI + repository hooks.
- Alert on unusual key usage (new IP ranges, spike in calls, new user agent).
Emergency Revoke Runbook
- Revoke key immediately.
- Identify blast radius (which services/tenants used it).
- Rotate dependent secrets if the key granted access to them.
- Postmortem: add tests/controls to prevent repeat.