Identity, Secrets and Key Management
Official scope (Exam Guide v1.0): secrets, credentials and API keys; identity validation; access approval and level verification; authorised access monitoring.
Three ways to authenticate
| Method | Credential | Best for |
|---|---|---|
| API key | Static sk-ant-api... secret as Authorization: Bearer (legacy x-api-key still works) | Local dev, scripts, servers that control secret storage |
| Workload Identity Federation | Short-lived token exchanged from your IdP's identity token (POST /v1/oauth/token); the SDK refreshes it | Cloud workloads, CI/CD, Kubernetes: removes static secrets |
| App Attest | Short-lived token (1 hour, Messages API only) for a genuine attested iOS/macOS app | Apps calling the API directly with no back end |
Key types
| Type | Acts as | Stops working when |
|---|---|---|
| Personal key | You, with your roles | You leave the org (archived) or lose workspace access |
| Service account key | A service account | The service account is archived or removed |
| Workspace key (legacy) | No one; belongs to the workspace | Expires, disabled/deleted, or workspace archived |
Prefer identity-backed keys (personal, service account): they cannot outlive their owner. Shared or automated workloads use a service account, never a personal key. A key not scoped to a workspace must send anthropic-workspace-id on each request.
Lifecycle
- Expiry chosen at creation (3 hours, 1 day, 7 days, 30 days, custom, or never) and cannot be changed later; expired keys return 401 and cannot be revived.
- Disable is reversible; delete is permanent (archived). Store keys in a secrets manager; rotate.
- Expiry limits a leak but is not a substitute for hygiene.
- Federation is only as strong as the IdP configuration; a static upstream secret that can mint IdP tokens undermines it.
Patterns (design guidance)
- Server-side proxy: never ship a key to a browser or mobile app (unless App Attest); your server holds it, applies limits, logs.
- Separate keys per environment and service, scoped to a workspace, so one leak exposes little.
- Agents and Claude Code: no secrets in prompts, CLAUDE.md or committed settings; keep them in the environment or a secrets manager and deny the agent read access to secret files.
Identity validation and access approval (design guidance)
Confirm the caller before issuing or honouring credentials; grant the minimum level; require approval for elevated access; re-verify before sensitive operations.
Authorised access monitoring (verified tools)
Admin API lists keys with expires_at and status; Console usage export and the Usage and Cost API break usage down by API key and model; alert on unusual use; audit who created and who uses each key.
If a key leaks (design guidance)
Disable → rotate and redeploy → find the exposure → review usage for abuse → fix the process.
Exam traps
- Key in front-end JavaScript.
- Personal key powering a shared service.
- "Expiry means we can skip rotation."
- Static keys in CI when federation is available.
References
- Authentication — checked Oct 16, 2026
- Usage and Cost API — checked Oct 16, 2026
- Errors — checked Oct 16, 2026
Check your understanding
CI pipeline needs API access. Best credential?Show answerHide answer
Answer
Workload Identity Federation (else a service account key).Developer leaves; the shared service breaks. Root cause?Show answerHide answer
Answer
A personal key on a shared workload.Suspected leak. First action?Show answerHide answer
Answer
Disable the key.How do you see which key is driving unusual spend?Show answerHide answer
Answer
Usage export or Usage and Cost API grouped by API key.