API Key
A secret or identifier presented by a software client to associate API requests with a project, application, or principal.
Download Markdown (.md)Soroush’s Product Wiki · https://wiki.soroush.uk/topic/api-key/
01What it means
An API key is a value issued to a client and sent with API requests. Depending on the system it may identify usage, authenticate a workload, authorize limited access, or only support metering. A static bearer key proves possession, not the identity of the person operating the client.[1][2]
- 01IssueHigh-entropy secret + owner
- 02StoreSecret manager or protected form
- 03SendApproved header over TLS
- 04VerifyScope, limits, usage metadata
- 05Rotate or revokeOverlap, expiry, exposure
A static key proves possession and may identify a workload; it does not identify the person operating a client.
02Why it matters
API keys provide simple machine access and attribution, but leaked keys are easy to replay. Issuance, scope, storage, rotation, monitoring, and revocation determine whether convenience becomes persistent unauthorized access.
03When to use it
Use API keys for controlled machine clients and low-complexity service access when their limitations are acceptable. Use OAuth, workload identity, mutual TLS, or signed requests when delegation, short lifetimes, stronger client proof, or user context is required.
04How it works
- Issue a high-entropy key to a named owner and show the secret through a protected channel.
- Store only a protected form where possible and keep the client copy in a secret manager.
- Send it in an approved header over TLS, never in a public client or URL.
- Look up the key, enforce scope and limits, and record safe usage metadata.
- Rotate keys with overlap and revoke them on expiry, disuse, or suspected exposure.
05A practical example
A reporting service receives a read-only API key for one tenant. The key lives in its secret manager, requests are rate-limited and logged, and two active-key slots allow rotation without downtime.
06Where it breaks
Static keys are commonly bearer credentials with no user identity, phishing resistance, or built-in expiry. Keys embedded in mobile apps, browser code, repositories, logs, or URLs should be assumed recoverable.
Common mistakes
- Embedding a secret API key in downloadable frontend or mobile code.
- Sending keys in query strings that enter logs and histories.
- Issuing one permanent key shared by many systems.
- Treating identification by a public or restricted key as strong authentication.
07Sources
- REST Security Cheat SheetOWASP Foundation · Security practice guidanceREST Security Cheat Sheet
- API Keys API DocumentationGoogle Cloud · Official technical documentationAPI Keys API Documentation