Skip to content
ShipSafeStack

Checklist

Leaked Anthropic key? What to do right now

Short answer. Treat the key as copied. On the Claude Console API keys page, disable or delete it, create a replacement, put that value only in the server environment, and redeploy. Then read Usage and Cost. Rewriting git history does not retire a key that already left the repo.

Updated 28 Nov 2026

This is a practical checklist, not a guarantee. It is not a penetration test, a compliance audit, or proof that an app is safe to launch.

An Anthropic API key is a credential for the Claude API. Anthropic's authentication page says keys are static secrets you create in the Claude Console and send as a bearer token. A key in a commit, a chat, or a client bundle can keep spending until you disable or delete it. This page is the first sitting after a leak. It is a checklist, not a statement that the account is fine.

The same shape for other credentials is Leaked OpenAI API key?, Leaked a GitHub token?, Leaked Stripe secret key?, and Leaked AWS access key?.

Disable or delete the key

Do this before you clean git. GitHub's leaked-secret tutorial says removing a secret from the codebase does not stop someone who already copied it.

1. Open the API keys page in the Claude Console: platform.claude.com/settings/keys. 2. Disable the leaked key, or delete it. Anthropic says Disable is reversible: the key's status becomes inactive, and Re-enable sets it back to active. Delete is permanent: the key is archived and still listed with status archived. Expired keys can only be deleted. For a key that is already in a public repo or a browser bundle, delete it. 3. Create a replacement with Create key. Name it, pick an expiration, and set who it acts as. Anthropic says a personal key acts as you. A shared or automated workload, such as CI or a production server, should use a service account an organization admin creates, not a personal key passed around. Workspace keys still work and are legacy. Prefer an identity-backed key for a new integration. 4. Copy the new key into the host's secret store. The authentication page shows the prefix sk-ant-api. An Admin API key is a different secret (sk-ant-admin01- on Claude Console). That one manages the organization. It does not belong in the app either.

Expiration is chosen when you create the key: 3 hours, 1 day, 7 days, 30 days, a custom duration, or Never. You cannot change it later. If the organization has a maximum lifetime, Never is not offered. A short lifetime limits how long a later leak stays usable. Anthropic emails the creator before a longer-lived key expires.

The same page says you can turn on IP allowlisting so a key only works from addresses you name. That does not replace deleting a key that is already public.

Put the new key on the host

The variable Anthropic's examples use is ANTHROPIC_API_KEY. It belongs on the server that calls the API, not in a name the framework inlines for the browser. On Next.js that prefix is NEXT_PUBLIC_. On Vite it is VITE_. Those values ship in the bundle. The wider pass is API keys in the frontend.

On Vercel, edit the environment variable and redeploy. Vercel's environment variables page says a change applies only to new deployments. The deployment already running keeps the value it was built with. Other hosts are the same: the new key is unused until the next deploy that reads it.

Then search the repo, the chat, and the built JavaScript for sk-ant-. Remove the old value. The commit that deletes the line is the cleanup. It is not the revoke.

Read usage, then set a limit

Anthropic's usage and cost analytics page says a Claude Console organization can see the same kind of breakdown on the Console's Usage and Cost pages: by workspace, API key, model, and the user or service account behind the request. The API that returns those numbers is not available on a claude.ai Team plan, and an individual Console account needs an organization before that API works. If the pages are there, compare the last few days with the traffic you expected. If they are not, do not guess at a total. The key you disabled has already stopped. Creating the organization does not undo spend that already happened.

Workspace spend limits are separate from deleting the key. Anthropic's workspaces page says you set a monthly spend limit in the Claude Console at Spend limits: under Workspace limits, pick the workspace, then Set limit or Adjust limit. A workspace limit can sit under the organization limit. It cannot raise it. Organization limits still apply. If Anthropic bills you directly, you can add an email when spend reaches an amount you choose. A spend limit on the Default Workspace does not count or stop some usage there, including the Console playground, Claude Managed Agents sessions, and Claude Code or Claude Desktop when a member signs in with a Console account and uses that workspace.

Rate limits are a different control, under Rate limits in the Console, per workspace and model. They cap requests or tokens per minute. They are not a substitute for deleting the leaked key.

Scope the replacement key to the workspace that should pay for it. A key scoped to one workspace only runs there. A key that is not scoped to a workspace needs the anthropic-workspace-id header on each request, and the user or service account must already have access to that workspace.

Where it leaked, and git history

Look in the places a generated app usually puts a key: a committed .env, a NEXT_PUBLIC_ or VITE_ name, a chat transcript, a log line, and a client bundle. GitHub's supported patterns list Anthropic API keys, admin API keys, service account API keys, and user API keys, with partner notification, user alerts, and push protection. Secret scanning on a public repository can alert you. A private repository may not. Push protection for your user is on by default and blocks supported secrets on pushes to public repositories. Repository push protection is a separate switch. Someone with write access can bypass it. A bypass is not a reason to leave the key in the commit.

GitHub's removing sensitive data page says to revoke or rotate first. After the key is dead, rewriting history may not be worth it. If you still rewrite, that page says a force-push does not erase clones, forks, or commits people can still fetch by SHA. A teammate who pulls and pushes the old history puts the key back. GitHub Support removes cached copies only when rotating the credential is not enough, and only for data they treat as sensitive. Coordinate with anyone who forked the repo. The same limit is in Leaked a GitHub token?.

Keep the next key off the client

Call Claude from a server route or an edge function. The browser receives the model's answer, not ANTHROPIC_API_KEY.

  • Store the key in the host's environment or a secrets manager. Anthropic says to rotate keys on a schedule. A short expiration, set at creation, is the limit you cannot add later.
  • Do not paste the key into a builder chat. How generated code keeps committing secrets is how to keep API keys out of AI-generated code.
  • For a workload that already has an identity provider, Anthropic documents Workload Identity Federation. The workload exchanges a short-lived token from that provider. There is no sk-ant-api string to copy into the app. That setup is in the authentication page. It is optional. Deleting the leaked key is not.
  • Claude Code runs in a terminal and can see whatever that shell has loaded. Do not leave a production ANTHROPIC_API_KEY in that environment while an agent edits the repo. The short list is Ship a Claude Code app.

Then run a free passive check on the public URL. It can see a key that shipped in a script. It does not read your Claude Console. The worksheets are the checklist pack and the pre-launch checklist.

FAQ

I deleted the key from the file. Is the Anthropic key dead?

No. Disable or delete it on the API keys page. A copy in git history, a fork, a chat, or the host's current deployment keeps working until the Console shows the key inactive or archived. Removing the line is the cleanup after that.

Does a workspace spend limit stop a leaked key?

It caps monthly spend for that workspace, under the organization limit. Anthropic says a limit on the Default Workspace does not count or stop some Console, Claude Code, and Claude Desktop usage there. The organization limit still applies. Deleting the key is what stops that key. A spend email does not.

Will GitHub secret scanning catch an Anthropic key?

GitHub's pattern list includes Anthropic API keys, admin keys, service account keys, and user API keys, with push protection. Scanning runs on public repositories. Push protection for your user blocks a push of those patterns to a public repository and is on by default. A private repository is not that automatic. Enable repository secret scanning and push protection where your plan includes them, and still revoke a key that already landed.

Can the key live in NEXT_PUBLIC_ANTHROPIC_API_KEY or VITE_ANTHROPIC_API_KEY?

No. Those prefixes are inlined into the browser bundle. Anthropic's examples keep the key in ANTHROPIC_API_KEY on the machine that calls the API. Call Claude from server code. The client should not receive the key.

Sources

Checked 26 Nov 2026.

Informational only. This page describes checks and vendor documentation. It is not a security audit, a penetration test, or a certification, and it is not a guarantee.

Newsletter

A short weekly note on new tools and security checklists. No spam, unsubscribe anytime.