Rubric
Contents — domains, guide and mocks

Identity, secrets and keys

CCDV-F 7.414 min read · checked 21 September 2026

Task statementIdentity, Secrets, and Key Management (1.6%) — managing secrets, credentials and API keys across development and production, identity validation, access approval and level verification, and authorized access monitoring

Where a credential should live at each stage

  1. Developer machinelocal env file, never committed
  2. CI pipelineinjected secret, masked in logs
  3. Stagingown key, own workspace, own limits
  4. Productionshort-lived token from your identity provider
The same application, three environments, three separate credentials. Nothing is shared downward, and nothing is committed at any stage.

Where secrets must not be

Start with the negative rules, because they account for most real incidents. A key does not belong in source code, in a committed configuration file, in a container image, in a log line, in an error message shown to a user, or in a prompt. The SDKs read ANTHROPIC_API_KEY from the environment by default precisely so that the key never has to appear in your code at all; in production it comes from a secret manager and is injected at deploy time.

One rule is specific to this API and easy to get wrong: a browser must never hold a Claude API key. The documentation notes that browser requests need a backend proxy — anything shipped to a front end is readable by anyone who opens the developer tools, and a key in a mobile binary is no better. Your server holds the credential, authenticates your own user, and calls the API on their behalf.

The prompt is the other place people forget. A key pasted into a system prompt so a tool can “use it” is now inside the context window, subject to everything in 7.1 about prompt leak. Credentials belong in the code that runs the tool, never in the text the model reads.

Scoping: workspaces, keys and roles

A Claude organisation can be divided into workspaces, and a workspace is the unit of isolation that matters for this objective. Workspaces separate API keys, spend limits, rate limits, members and their roles, and usage tracking, while billing and administration stay central. The documented uses are exactly the ones you want: one workspace per environment, per team or per product, each with its own limits.

That isolation is what turns a credential incident into a contained one. A key scoped to the staging workspace cannot spend the production budget or read production-scale rate limits, and a spend cap on a workspace bounds the damage of a leaked key or a runaway loop. Per-workspace usage also makes the cost attribution in 5.4 possible.

LevelWhat it grantsUse it for
Organisation adminManage users and everything belowA small number of named people
Organisation developerUse the playground and manage API keysEngineers who provision keys
Organisation userPlayground access onlyEveryone else
Workspace AdminFull control of that workspace's settings and membersThe team that owns the environment
Workspace DeveloperCreate and manage keys, use the API in that workspaceDay-to-day engineering
Service accountA non-human identity that keys and tokens act asApplications and pipelines, never a person's key

Use a service account for anything automated. A production service running on a named engineer's personal key is an outage waiting for that engineer to leave, and it destroys accountability: every audit trail points at a person who was asleep at the time. Access approval and level verification, in the objective's words, means someone with the authority to grant it deciding which role an identity gets, and that decision being reviewable later.

Better than a secret: federated identity

The strongest version of secret management is not having a long-lived secret at all. Workload identity federation lets a workload prove who it is with a signed token from your own identity provider — a cloud IAM role, a CI provider, a Kubernetes service account — and exchange it for a short-lived Claude access token bound to a service account. There is no static key to mint, store, rotate or leak.

A federated credential, end to end

Workload
Your IdP
Anthropic
Step 1: Workload to Your IdP: Request identity token
Step 2: Your IdP to Workload: Signed JWT with claims
Step 3: Workload to Anthropic: Exchange at the token endpoint
Step 4: Anthropic : Verify signature, match rule
Step 5: Anthropic to Workload: Short-lived access token
Step 6: Workload to Anthropic: Call the API; refresh before expiry
The only durable thing here is a configured rule. The credential in flight expires in minutes and the SDK refreshes it before it does.

Three things are configured once: a service account — the non-human identity the token acts as; a federation issuer — your identity provider, registered with its issuer URL and the public keys used to verify its signatures; and a federation rule — the bridge that says which claims from that issuer may assume which service account, with which scope and token lifetime. Anthropic validates the incoming token against the issuer's keys and the rule's conditions before issuing anything.

Static key against federated identity

Long-lived API key

  • Valid until someone revokes it
  • Must be stored somewhere, by someone
  • Rotation is a scheduled chore
  • Trust rests on where the string is kept

Federated short-lived token

  • Expires in minutes; the SDK refreshes it
  • Nothing durable to store
  • Rotation is the normal operation
  • Trust rests on your identity provider's controls
Both authenticate. Only one of them makes “a key leaked” a survivable Tuesday by construction rather than by process.

Monitoring authorised access

The last clause of the objective is about knowing who has access and noticing when that changes. The Admin API is the instrument: it manages organisation members and their roles, invites, workspaces and workspace members, and service accounts, and it lists API keys with their status and expiry so you can find the ones nobody is rotating. It deliberately cannot call the Messages API — an admin credential is for administration only, which is itself a least-privilege design worth copying.

Finding keys that need attentionpython
# Admin credentials only — this key cannot call the Messages API.
keys = client.beta.organization.api_keys.list(status="active")

for k in keys:
    stale = k.expires_at is None                  # no expiry set at all
    if stale:
        report(f"{k.name} ({k.id}) has no expiry — schedule rotation")

# Pair it with spend: the usage report groups by api_key_id, so a key
# that appears in the key list but never in usage is a key to revoke.

Two habits do most of the work. Review membership and roles on a schedule, and remove people when they leave — offboarding through the API is the documented approach, and it is the step most often skipped. And watch usage per key: a key with no traffic is a key to revoke, and a key whose traffic suddenly changes shape is worth a question. Anthropic's own recommendations are exactly this — audit roles regularly, monitor key usage and expiry, rotate periodically, clean up unused workspaces and expired invites.

A credential hygiene review

  • Passes: No credential in source control, images or logsScan history, not just the current tree
  • Passes: Separate keys per environment, in separate workspacesSpend and rate limits set per workspace
  • Fails: Applications and pipelines use service accountsA personal key in production breaks the audit trail
  • Fails: Keys have an expiry, and rotation is a config changeList keys and check expires_at
  • Passes: No API key reachable from a browser or mobile clientCalls go through your own backend
  • Check: Membership and roles reviewed; leavers removedAutomate offboarding through the Admin API
  • Check: Usage monitored per key, with alerts on anomaliesA quiet key and a suddenly busy key both deserve attention
Nothing here is exotic. The two failing rows are what turn an ordinary mistake into an incident.

Traps the wrong answers are built from

Tempting but wrongDo this instead
Committing a key and fixing it by deleting the fileRevoke and reissue first; history and logs keep the old value forever.
One shared key across development, CI, staging and productionA key per environment in its own workspace, with its own spend and rate limits.
Calling the Claude API directly from a browser or mobile appKeep the credential server-side and proxy the call through your own backend.
Running production on a named engineer's personal keyUse a service account, so access survives the person and the audit trail names the system.
Putting a credential in the system prompt so a tool can use itKeep secrets in the code that runs the tool; the context window is not a vault.
Leaving ANTHROPIC_API_KEY set after migrating to federationClear it everywhere — it takes precedence and silently keeps the old key alive.
Provisioning access and never reviewing itAudit members, roles and key expiry on a schedule, and automate offboarding.

You should now be able to

  • Keep credentials out of source, images, logs, browsers and prompts, and load them from the environment or a secret manager.
  • Scope access with workspaces, per-environment keys, spend and rate limits, and appropriate roles.
  • Choose service accounts for automated workloads and explain why personal keys fail there.
  • Describe workload identity federation and what it replaces.
  • Respond to an exposed key in the right order: revoke, reissue, assess, clean up.
  • Monitor authorised access with the Admin API — roles, key status and expiry — and act on what it shows.

Practice questions

Original questions written for this lesson, in the exam’s style. Answer first, then open the reasoning — every option is explained, including why the wrong ones are tempting.

  1. Question 1

    An engineer discovers that a production API key has been printed into an application log for the last three weeks. The logs are retained for ninety days and are readable by the whole engineering team.

    What should happen first?

    1. ARedact the key from the log pipeline and purge the affected log lines.
    2. BRevoke the key and issue a replacement from the secret manager.
    3. CRestrict log access to a smaller group and monitor for unusual usage.
    4. DSet a spend limit on the workspace to cap any damage.
    Show answer and reasoning
    1. AIncorrect. Necessary clean-up, but it leaves a live credential that many people have already been able to read.
    2. BCorrect. An exposed credential must be assumed copied; revocation is the only action that ends the exposure.
    3. CIncorrect. It reduces future exposure and might detect misuse, but the key remains valid for anyone who already has it.
    4. DIncorrect. A sensible control to have in place beforehand; it bounds the loss rather than stopping it.
  2. Question 2

    A team runs its production service on Kubernetes and wants to stop storing a long-lived Claude API key in its cluster secrets. Their clusters already issue signed identity tokens to workloads.

    Which two statements about workload identity federation are correct? (Select 2.)

    1. AThe workload exchanges its signed token for a short-lived Claude access token.
    2. BA federation rule decides which token claims may act as which service account.
    3. CFederation removes the need for workspaces and spend limits.
    4. DThe static key can stay in the environment as a fallback.
    5. EAnthropic issues the identity token that the workload presents.
    6. FFederated tokens are valid until explicitly revoked.
    Show answer and reasoning
    1. ACorrect. That exchange is the mechanism: the identity provider's token is validated and a time-limited token is issued.
    2. BCorrect. The rule bridges the registered issuer to a service account, with match conditions, scope and token lifetime.
    3. CIncorrect. The issued token is still bound to a workspace and subject to its limits; scoping remains just as relevant.
    4. DIncorrect. A key in the environment takes precedence over federation, so the migration would silently not take effect.
    5. EIncorrect. Your own identity provider issues it; Anthropic validates it and returns an access token.
    6. FIncorrect. They are deliberately short-lived and refreshed by the SDK before expiry.
  3. Question 3

    A company has one Claude organisation and one default workspace. Every team's service uses a key created by whoever set the service up, several of them personal keys. Finance cannot attribute spend, and a developer who left last month still appears in the member list.

    Which change addresses the most problems at once?

    1. ARotate every key immediately and ask each team to label its keys clearly.
    2. BCreate a workspace per team with service-account keys, audited via the Admin API.
    3. CMove all of the existing keys into a shared secret manager with access control.
    4. DEnable workload identity federation for every service.
    Show answer and reasoning
    1. AIncorrect. Rotation is worthwhile, but labels do not isolate spend, limits or permissions — and the leaver still has access.
    2. BCorrect. Workspaces isolate keys, limits, members and usage tracking; service accounts fix attribution; the audit removes the leaver.
    3. CIncorrect. Better storage for the same over-broad credentials; it changes nothing about scope or attribution.
    4. DIncorrect. An excellent destination, but without workspaces and role review the scoping and offboarding problems remain.
  4. Question 4

    A front-end team wants to call the Claude API directly from a single-page application to avoid the latency of their own backend. They propose storing the key in an environment variable at build time.

    Why does this not work?

    1. ABuild-time environment variables are compiled into the bundle and are readable by any user.
    2. BThe API rejects requests whose origin is a browser, so the call would fail.
    3. CFront-end frameworks cannot set the required version header.
    4. DLatency would be worse because the browser cannot reuse connections.
    Show answer and reasoning
    1. ACorrect. Anything shipped to a browser is public; browser requests need a backend proxy holding the credential.
    2. BIncorrect. The problem is credential exposure rather than a guaranteed technical block.
    3. CIncorrect. They can set headers; the objection is that the key would be visible.
    4. DIncorrect. A performance argument, not the security reason this design is rejected.

Sources

Drafted with AI assistance and checked against the sources above; expert review is in progress. Spotted an error? Tell us and it gets fixed, dated and listed on how this is written.