Skip to content

Security and governanceGuide

Leaked Anthropic API key? Revoke, scope and cap it

Anthropic's keys are no longer one kind of secret. A personal key acts as the person who made it, a service account key as a workload, a legacy workspace key as nobody. Which one leaked decides what the attacker could do, and what you have to check in the first hour.

By INFRO Editorial

Published

8 min read

A stack of translucent amber glass layers on a dark ground with small points of light drifting through them

In short

If an Anthropic API key leaks, disable or delete it on the API keys page of the Claude Console, then find its key type and workspace, read its usage with the Usage page or the Usage and Cost API filtered by API key, replace it with a scoped key that expires, set a workspace spend limit below the organization's, rule out an Admin API key or an admin's unscoped personal key, and contact Anthropic Support if activity continues. GitHub reports Claude keys found in public repositories to Anthropic, which deactivates them.

Key takeaways

  • Disable is reversible and Delete is permanent; for a key you believe is in someone else's hands, delete it.
  • Check the key type first: a personal key acts as its creator, and one not scoped to a workspace can call the Admin API with that person's permissions.
  • Read usage for the leaked key alone: the Usage and Cost API filters by API key and workspace at one-minute granularity.
  • Replace it with a workspace-scoped key that expires, and put a spend limit on that workspace; the default workspace cannot take one.
  • GitHub reports Claude keys found in public repositories to Anthropic, which deactivates them; a key leaked anywhere else is yours to find.

Leaked Anthropic API key — what now? Delete the key on the API keys page of the Claude Console first. Then check what kind of key it was and which workspace it could reach, read its usage on its own, replace it with a scoped key that expires, put a spend limit on the workspace, rule out an admin credential leaking with it, and contact Anthropic Support if suspicious activity continues. Anthropic's own advice for a key you suspect is compromised is to revoke it immediately1.

Anthropic's key model has changed. A key is now a personal key, a service account key or a legacy workspace key, and each fails differently when it leaks. That is why the second step matters as much as the first.

The first hour at a glance

WhenStepWhere
Minute 0–5Delete the keyClaude Console → API keys
5–15Identify key type, owner, workspace scope, expiryAPI keys page, Admin API
15–30Read usage for that keyUsage page, Logs, Usage and Cost API
15–45Replace it where it was deployedSecret manager, CI, hosts, tools
30–50Workspace and organization spend limitsWorkspaces, Billing page
45–60Admin credentials, members, supportAdmin keys page, Members, Help Center

1. Delete the key

In the Claude Console, open the API keys page (platform.claude.com/settings/keys), click the three dots next to the key and select Delete API key1. The console also offers Disable. The difference matters:

  • Disable is reversible: the Admin API reports the key as inactive, and Re-enable returns it to active.
  • Delete is permanent: the key is archived and still appears in List API Keys with status: "archived"2.

Our reading: for a key you believe someone else holds, delete it. A disabled key can be turned back on by anyone who can manage keys, and in step 6 you may find that an admin credential was exposed too.

Anthropic may have acted already. It is a GitHub secret scanning partner: when GitHub finds a Claude key in a public repository it notifies Anthropic, Anthropic "automatically deactivates the exposed API key", and the affected user receives an email3. GitHub's pattern list covers Anthropic API keys, admin API keys, service account and user API keys and session IDs as partner patterns4, and since 13 October 2026 the two newer key types are blocked by push protection by default, including on free public repositories5. None of that covers a key that leaked from a log, a laptop or a third-party tool. In the OpenCode Console incident, OpenCode told affected users to revoke the keys they had saved there with each provider and replace them6; what OpenCode has said is covered separately.

2. Find out what kind of key it was

The key type decides what an attacker could do with it2:

Key typeActs asWhere it worksStops working when
Personal keyThe user who created it, with their rolesOne workspace, or every workspace their role allowsThe user loses access to the organization (or to that workspace)
Service account keyA service accountOne workspace, or anything the service account can reachThe service account is archived or removed from the workspace
Workspace key (legacy)No one; it belongs to the workspaceThat workspaceIt expires, is disabled or deleted, or the workspace is archived

Two consequences for a leak:

  • A personal or service account key that is not scoped to a workspace is accepted by the Admin API, with the same permissions as the linked account7. If the leaked key belonged to an organization admin and was not workspace-scoped, treat it as an admin credential leak and go straight to step 6.
  • A multi-workspace key reaches every workspace its identity can. Write down which workspaces those are, because each one's usage is now in scope.

Also note the key's expiry. The Admin API's List API Keys returns each key's expires_at (null for a key with no expiration) and its scope, either one workspace or the organization7.

3. Read the usage for that key

Start with the Usage and Logs pages in the Console, which Anthropic recommends reviewing regularly3. For a per-key view, the Usage and Cost API's /v1/organizations/usage_report/messages endpoint filters and groups by API key, workspace, model and service tier, with 1m, 1h or 1d buckets; data typically appears within five minutes of a request. It needs an Admin API key, or a personal or service account key that is not workspace-scoped8.

Hourly usage for one key, by model
curl "https://api.anthropic.com/v1/organizations/usage_report/messages?starting_at=$START&ending_at=$END&api_key_ids[]=$LEAKED_KEY_ID&group_by[]=model&bucket_width=1h" \
  -H "anthropic-version: 2023-06-01" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY"

Look for traffic outside the workload's hours, models it never calls, and batch or cache patterns you do not use. Two quirks: Console playground usage has a null api_key_id, and the default workspace appears as a null workspace_id8. Export what you find; you will want it for support.

4. Replace it, narrower than before

Create the new key on the same page with Create key, and store it in a secrets manager, not in version control1. Make it narrower than the one that leaked:

  • Give it an expiration. The Console offers 3 hours, 1 day, 7 days, 30 days, a custom duration or Never, and an organization can set a maximum expiration policy that removes Never. Expiration is fixed at creation; an expired key returns 401 authentication_error2.
  • Scope it to one workspace. Keys are tied to the workspace they are created in and cannot be moved9.
  • Use a service account for anything shared or automated. A shared personal key acts as one person and breaks when they leave; Anthropic prefers identity-backed keys over workspace keys for new integrations, and Workload Identity Federation over long-lived keys where the workload already has a platform identity2.

Then replace every copy of the old key: secret manager entries, CI secrets, .env files, developer machines and any third-party tool that held it.

5. Cap the workspace and the organization

A spend limit at Anthropic is the only ceiling that applies to a key used directly against Anthropic.

  • Workspace spend limit. Set a monthly limit on each workspace; it must be lower than the organization's, and you can add an email notification at an amount you choose9. You cannot set a spend limit on the default workspace10, which is a reason to keep production keys out of it.
  • Organization spend limit. On the Billing page, under Spend limits, set your own limit below your tier's cap. When usage reaches a limit you set, requests return 400 invalid_request_error; when the tier's cap is reached, 429 with enforced_spend_limit_reached until 00:00 UTC on the first of the next month10.
  • Workspace rate limits per model, which Anthropic describes as a safeguard "against unexpected usage due to leaked keys or errant scripts"3.

6. Rule out an admin credential

Admin API keys start with sk-ant-admin01-, can be created only by members with the admin role, and carry full access to every endpoint that accepts them, with no selectable scopes11. The Admin API manages members, workspaces, invites and API keys; it cannot create new API keys, but it can read, rename and change the status of existing ones7. That is why a disabled key is not enough if an admin credential is exposed.

If the leak came from somewhere that also held an admin key, or an admin's unscoped personal key, delete that credential too, then check members, invites, workspaces and keys created during the exposure window. Least privilege for provider admin keys covers how to hold one safely.

7. Contact Anthropic Support

If suspicious activity continues after revocation, or you have other concerns, contact the support team through the link in Anthropic's compromised-key article1. Anthropic's Commercial Terms make the customer "responsible for all activity under its account" and require it to "promptly notify Anthropic" if it believes the account has been compromised12. Send the key ID, workspace, time window in UTC and the usage export. Whether any charges are adjusted is Anthropic's decision; stolen API key charges explains what the terms say.

How INFRO handles a leaked Anthropic key

If your Anthropic key is connected to INFRO, replace the credential on the connection after you rotate it at Anthropic. INFRO seals provider keys with AES-256-GCM, never shows them again, and uses the new one from the next request; replacing it in INFRO does not revoke the old key at Anthropic (see Connect a provider). Your applications use INFRO gateway keys instead of the Anthropic key, so a leaked application credential is an INFRO key you can revoke or rotate with an overlap window, limit to IP ranges, providers and one environment, and cap with budgets checked before Anthropic is called. Key changes are recorded in the audit log.

INFRO's controls govern traffic that goes through INFRO. A copy of the Anthropic key itself, leaked from anywhere, including from a platform like INFRO that holds it, can be used directly against Anthropic, and no INFRO budget or allowlist sees that request. Steps 1, 5 and 7 happen at Anthropic for that reason. On the Business plan, with usage access on, reconciliation compares Anthropic's own usage per key with the traffic that passed through INFRO, which can show use of your key that bypassed the gateway.

Summary

Delete the key, then let its type tell you how far the leak reaches: personal keys act as a person, and unscoped ones can reach the Admin API. Read usage for the key alone, replace it with a workspace-scoped key that expires, cap the workspace and the organization at Anthropic, rule out an admin credential, and report what you found.

Questions readers ask

How do I revoke a Claude API key?
In the Claude Console, open the API keys page (platform.claude.com/settings/keys), click the three dots next to the key and choose Delete API key. Disable is also available and is reversible; Delete archives the key permanently.
Does Anthropic deactivate leaked API keys automatically?
For keys found in public GitHub repositories, yes: Anthropic is a GitHub secret scanning partner, GitHub notifies Anthropic, Anthropic deactivates the key and emails the affected user. Keys leaked anywhere else, such as a log file, a laptop or a breached third-party tool, are not covered.
Can a leaked Anthropic API key access more than the Messages API?
It depends on the key type. A personal key acts as its creator with that person's roles, and a personal or service account key that is not scoped to a workspace is accepted by the Admin API. A leaked key belonging to an organization admin can therefore manage keys, members and workspaces.
How do I limit damage from a future Anthropic key leak?
Give each workload its own workspace-scoped key with an expiration, set a workspace spend limit below the organization's, set an organization spend limit on the Billing page, prefer service accounts or Workload Identity Federation for production, and review usage per key.

From the team that builds it

Where this shows up in INFRO

INFRO is a control plane in front of the provider accounts you already hold. The capabilities below are the parts of it this article touches, each with the documentation that defines its behaviour.

  • Provider connections

    Available with a plan

    Connect provider accounts you already hold. Each credential is encrypted when saved, scoped to your organization and never shown again; applications use INFRO gateway keys instead.

    Read the documentation for Provider connections
  • Key limits and rotation

    Available with a plan

    Limit a gateway key to chosen providers or IP ranges, and rotate it with an overlap window so the old key keeps working while you deploy the new one.

    Read the documentation for Key limits and rotation
  • Budgets and spend ceilings

    Available with a plan

    A hard cap per organization, project, member, and key, with alerts at your own thresholds.

    Read the documentation for Budgets and spend ceilings
  • Spend anomaly and drift alerts

    Available with a plan

    Each scope's usual day is learned from its own history; a day that departs from it, a budget forecast to be exceeded, cost estimates drifting from the provider's own figures, unpriced traffic and failing connections become findings in the console. Routed to email on every plan, and to Slack and signed webhooks from the Startup plan.

    Read the documentation for Spend anomaly and drift alerts
  • Provider cost reconciliation

    Available with a plan

    Daily comparison of estimated spend against the cost reported by OpenAI's and Anthropic's own cost APIs, using a separate admin credential, with the likely cause of a persistent gap and a suggested rate you can apply. Included on the Business plan.

    Read the documentation for Provider cost reconciliation
  • Audit log

    Available with a plan

    Member, key, and policy changes recorded with actor and timestamp, viewable in the console.

    Read the documentation for Audit log

INFRO accounts are self-serve. Provider usage is billed to you by your providers; INFRO charges a software subscription and takes 0% of model spend. See plans.

Sources

Numbered in order of first citation. Each was opened and checked against the claim on the date shown.

  1. 1.What should I do if I suspect my API key has been compromised? (opens in a new tab) — Anthropic Help Center. Accessed Oct 21, 2026.
  2. 2.Authentication (opens in a new tab) — Anthropic. Accessed Oct 21, 2026.
  3. 3.API key best practices: keep your keys safe and secure (opens in a new tab) — Anthropic Help Center. Accessed Oct 21, 2026.
  4. 4.Supported secret scanning patterns (opens in a new tab) — GitHub. Accessed Oct 21, 2026.
  5. 5.Secret scanning blocks Anthropic keys by default, adds Salesforce (opens in a new tab) — GitHub. Accessed Oct 21, 2026.
  6. 6.OpenCode Console Breach May Have Exposed OpenAI, Anthropic, and Google API Keys (opens in a new tab) — The Hacker News. Accessed Oct 21, 2026.
  7. 7.Admin API (opens in a new tab) — Anthropic. Accessed Oct 21, 2026.
  8. 8.Usage and Cost API (opens in a new tab) — Anthropic. Accessed Oct 21, 2026.
  9. 9.Creating and managing workspaces in the Claude Console (opens in a new tab) — Anthropic Help Center. Accessed Oct 21, 2026.
  10. 10.Rate limits (opens in a new tab) — Anthropic. Accessed Oct 21, 2026.
  11. 11.Create an Admin API key (opens in a new tab) — Anthropic. Accessed Oct 21, 2026.
  12. 12.Commercial Terms of Service (opens in a new tab) — Anthropic. Accessed Oct 21, 2026.

About this article

Steps and names were checked against Anthropic's help center (compromised key, key best practices, workspaces) and Claude Platform documentation (authentication and key types, Admin API, Admin API keys, Usage and Cost API, rate and spend limits), GitHub's secret scanning pattern list and its 13 October 2026 changelog, Anthropic's Commercial Terms of Service and The Hacker News' OpenCode report, all opened on 2026-10-21. Where the post reasons from the documentation rather than quoting it, it says so. Written by the team that builds INFRO.

Last checked against its sources on . The next review is due by . No separate named reviewer is recorded for this article.

How articles are written, sourced and corrected is set out in the editorial standards.