CCDV-F Prep unofficial
← All skills

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 Origin header 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-id on 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_KEY outranks federation. Unset it everywhere, check with ant 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, principal and scope, 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.
  • dangerouslyAllowBrowser as 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

SituationChoiceWhy
Browser app needs ClaudeOwn back end holds the credentialPage code is readable by users
CI with OIDC tokensWorkload Identity FederationNo stored secret
Unattended server, no identity providerService account keySurvives staff changes
Developer on a laptopCLI sign-inShort-lived, nothing to rotate
Automate members and workspacesAdmin 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 federationorg:admin tokenAdmin keys are not accepted
Suspected leakDisable or delete, then replaceOnly that stops the key
Limit where a stolen key worksIP allowlistRequests from other addresses are rejected
Limit how long it worksExpiration or WIFBounds the lifetime

Sources