An API key is a credential, not a user identifier and not a complete authorization model. If every integration shares one permanent key with broad access, a single leak can expose every operation and there is no reliable way to identify or revoke one consumer. Give each integration its own credential and define what it is allowed to do.
Design credential records
Store a verifier or a securely hashed representation when the credential only needs to be checked, rather than storing the raw key. Show the secret once at creation and make clear that it cannot be retrieved later. Associate it with an owner, creation time, last-used time, expiry, allowed scopes and status. Use high-entropy random values generated by a cryptographically secure random source.
Rotate without downtime
Support a controlled overlap window in which an old and new credential can both be valid. Create the replacement, deliver it through a secure channel, confirm the consumer has switched, then revoke the old key. Set an explicit deadline for the overlap. A rotation process that has no verification step can cause outages or leave old credentials active indefinitely.
Enforce scope on every request
Authenticate the credential, then authorize the requested operation against its scopes and the target resource. Do not assume that knowing a project identifier grants access to it. Apply rate limits per credential and record safe audit metadata such as credential ID, endpoint and outcome—never the raw secret.
Operational response
Provide a revocation path for suspected compromise. Search logs and deployment configuration for accidental exposure, rotate affected credentials and review activity since the earliest plausible compromise. Keep secrets outside source control and public web directories, and restrict access to production configuration.
Further reading
- OWASP Secrets Management Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
- OWASP REST Security Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html