Pcornel
Browse topics
Options
Recent
Favorites
Security · Technical reference

API Keys

Direct answer

API keys are secrets that identify and authorize an application calling an API. Scope them narrowly, keep them out of code and repositories, rotate them and revoke them on any exposure.

When to use this

Use this when issuing, storing or revoking API keys.

First 30 seconds

1. API keys authenticate apps to APIs.

2. Scope minimal; restrict by IP/referrer.

3. Store in vaults/env injected at runtime.

4. Rotate and revoke.

5. Monitor usage.

Operational verification

key → API → scoped access

Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Common mistakes
  • Keys committed to Git or included in mobile apps and front-end JavaScript.
  • One key with full access used by many services.
  • No IP or referrer restrictions where the provider supports them.
  • No owner or expiry recorded.
Platform / version applicability
Cryptography, PKI and secrets
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformCryptography, PKI and secrets
Scope / prerequisiteUse this when issuing, storing or revoking API keys.
What next?2 suggested next steps
Evidence1
On this pageJump to a specific section
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • An API key acts as its owner to the API.
  • Scope keys to the minimum permissions.
  • Never commit keys to repositories.
Key checks
  • gitleaks detect --source . — keys in code
  • Key scopes and IP restrictions — least privilege
  • Key age — rotation
ReferenceWhy it matters1 section · depth on demand

Handling API keys

  • Scope narrowly (specific APIs, read-only where possible) and restrict by IP or referrer where supported.
  • Store in a secret manager or environment injected at runtime, not in code.
  • Rotate regularly and immediately after exposure; support two active keys for zero-downtime rotation.
  • Monitor usage for unusual volume or locations.
  • Prefer short-lived tokens (OAuth, workload identity) over static keys.
ReferenceImportant terms & boundaries2 sections · depth on demand

In depth

API keys identify and authenticate applications calling an API. They are easy to use but are typically long-lived bearer credentials, so leaks are common and serious.

Good practice:

PracticeReason
Minimum scopeRead-only where possible
One key per consumerPrecise revocation and audit
IP/referrer restrictionsLimit where a leaked key works
Expiry and rotationBound the lifetime
Server-side onlyNever embed in mobile apps or front-end code
Secret scanningDetect commits containing keys

Prefer short-lived tokens (OAuth client credentials, workload identity) over static API keys where the platform supports them.

Good practices

  • One key per consumer and purpose, with least-privilege scopes.
  • Store in a secret manager; inject at runtime.
  • Restrict by IP, referrer or service where possible.
  • Expire and rotate keys; prefer OAuth client credentials or workload identity over static keys.
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docCryptography, PKI and secrets current

Authoritative/upstream documentation reviewed for bounded claims in Secrets Management → API Keys. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html · confidence 94%
Confirmation

Confirm action

Continue?