Security and Safety
API Key and Credential Handling
Exam objective: Handling Anthropic API keys and credentials correctly in development and production, including server-side proxying rather than client embedding, workspace-scoped keys versus admin keys, environment separation, rotation, and access monitoring, without exposing any key beyond its intended scope.
What the exam tests
Whether you can put the right credential in the right place and nowhere else: keep it on the server, give each workload an identity and the narrowest scope, separate environments, rotate and revoke correctly, and watch how credentials are used.
Key rules
Placement
- Keys stay out of source control, client-side code and prompts. Store them in a secrets manager; SDKs read
ANTHROPIC_API_KEY. - Web apps: the browser calls your back end, and the back end calls Claude. Build a new upstream request: forwarding the browser's
Originheader makes the API treat it as a browser call. - iOS and macOS apps can use App Attest, with no key inside the app.
- Agents that run untrusted content: inject the credential in a proxy outside the agent's security boundary.
Which credential
- Developer API keys call Claude. Admin API keys manage the organization and cannot call Claude.
- Personal key: a tool only you run; stops when you leave. Service account key: shared or unattended workloads. Legacy workspace key: acts as no one and outlives its creator; replace it.
- Prefer short-lived tokens: CLI sign-in on your own computer, Workload Identity Federation (WIF) where there is an identity provider (CI, cloud, Kubernetes).
- A key is scoped to one workspace or to the organization. Organization-scoped keys must send
anthropic-workspace-idon each Claude API request.
Environment separation
- Use separate workspaces for development, staging and production, each with its own keys and spend and rate limits. Files, batches and skills are workspace-scoped.
Rotation and revocation
- Expiration is chosen at creation and cannot be changed.
- Replace without downtime: create, deploy, disable the old key, confirm, delete.
- Disable is reversible; delete is permanent. Deleting a copy of a secret (for example a CI secret) does not revoke the key.
- Moving to WIF: a leftover
ANTHROPIC_API_KEYoutranks federation. Unset it everywhere, check withant auth status, then delete the key.
ant auth status # shows which credential source wins
Monitoring and limiting exposure
- List API Keys shows
status,expires_at,principalandscope, never the secret. - Usage reports can filter and group by API key and workspace.
- IP allowlisting (beta) limits where a key works; it does not limit how long.
Traps
- Obfuscating, encrypting or lazily downloading a key into a client. The user still gets it.
dangerouslyAllowBrowseras a fix for a failing browser call.- Using an Admin API key "because it has more permissions" for model calls.
- A personal key in a production job.
- Several keys in one workspace presented as environment isolation: they share resources and limits.
- Removing a leaked key from git history and keeping it in use.
- Telling an agent in the system prompt not to read its key. That is not a boundary.
- Assuming the Admin API can create Developer API keys. It cannot.
Decide quickly
| Situation | Choice | Why |
|---|---|---|
| Browser app needs Claude | Own back end holds the credential | Page code is readable by users |
| CI with OIDC tokens | Workload Identity Federation | No stored secret |
| Unattended server, no identity provider | Service account key | Survives staff changes |
| Developer on a laptop | CLI sign-in | Short-lived, nothing to rotate |
| Automate members and workspaces | Admin API key or org:admin token (organization-scoped personal or service account keys also work, with their account's permissions) | Management needs organization reach |
| Manage service accounts or federation | org:admin token | Admin keys are not accepted |
| Suspected leak | Disable or delete, then replace | Only that stops the key |
| Limit where a stolen key works | IP allowlist | Requests from other addresses are rejected |
| Limit how long it works | Expiration or WIF | Bounds the lifetime |