Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

Claude API Key: Where to Get It, Keep It Safe and Revoke It

You create a Claude API key in the Claude Console, on the API keys page, with the Create key button, and you delete one from the three-dot menu next to it. As of October 2026 Anthropic says a key works like a credit card number: if someone else gets hold of it, they run up charges on your account.

The catch: your Claude subscription doesn't cover API use

Lots of people pay for Claude Pro or Max, create an API key and assume their plan covers it. It doesn't. Anthropic says a paid Claude subscription (Pro, Max, Team or Enterprise) doesn't include API usage, which is billed separately through the Console. The exception is that Max and Team plans include monthly API credits.

So the key you create isn't tied to your chat subscription. Once any included credits are used, the API is its own bill, and that's exactly why a leaked key matters. For how the API itself works, see my explainer on what the Claude API is, and for the plan side, see how Claude's plans compare.

How keys leak, and who's watching

Anthropic names the most frequent cause of leaks: plaintext keys committed to public GitHub repositories, or typed into third-party tools. Neither needs a hacker. It's usually a rushed commit or pasting a key into a tool you haven't vetted. Typing a key into a third-party tool is the quieter version of the same mistake: once it's in someone else's system, you can't see where it goes or who else can read it.

There's one safety net worth knowing about. Anthropic partners with GitHub's secret scanning programme, and GitHub scans public repositories for exposed Claude API keys. That's a backstop, not a plan. The scanning covers public repositories, so a key pasted into a shared document or a chat message sits outside it, and the habits below still matter.

How to create and store a key safely

  1. Sign in to the Claude Console and open the API keys page.
  2. Click Create key and copy it once, straight into a secrets manager.
  3. Set spend limits or auto-reload thresholds on the Billing page.
  4. In your app, load the key from an environment variable, never the raw key in code.
  5. If it ever leaks, open the three-dot menu next to the key, choose Delete API key, then create a new one.

Anthropic's own Python example loads the key from an environment variable called ANTHROPIC_API_KEY using python-dotenv, rather than writing it into the script. That's the pattern to copy, whatever language you use.

The safety rules Anthropic lists

RuleWhat to do, per Anthropic as of October 2026
Never in codeKeep keys in environment variables or encrypted secrets, and add .env files to .gitignore
Never sharedDon't share a key with anyone
RotateRotate on a schedule; every 90 days is the example Anthropic gives
Separate keysUse different keys for development, testing and production
ScanScan your repositories for secrets, for example with Gitleaks
Scale upMove to a key management system as you grow

Gitleaks is the example Anthropic names for scanning. Run a scanner like it before you push code, so a key gets caught on your machine instead of after it reaches a repository.

The separate keys rule pays off the day something goes wrong. If your test key leaks, you delete it and production keeps running. With one key everywhere, a single leak means taking everything down while you swap it.

Spend guards that limit the damage

Even careful people leak keys. What decides how bad it gets is the ceiling you set beforehand. Anthropic splits this by the type of organisation you have in the Console.

  • Custom rate limit organisations: set spend limits on the Billing page and workspace rate limits on the Rate limits page.
  • Standard rate limit organisations: configure auto-reload thresholds on the Billing page. Anthropic says to treat the auto-reload limit as a guard against spend from a leaked key.

Then check the Logs page and the Usage page in the Console regularly. A sudden jump in usage you don't recognise is often the first sign a key is out in the wild.

What to do the moment you suspect a leak

Anthropic's instruction is short: revoke the key immediately in the Console, create a new one, and store it in a secrets manager rather than in version control. Don't wait to confirm the leak first. Deleting a key costs you a few minutes of updating your app; leaving a leaked key live can cost a lot more.

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

My verdict on handling a Claude API key

I'd treat a Claude API key exactly like the credit card number Anthropic compares it to. Create it in the Console, keep it in an environment variable or a secrets manager, set a spend ceiling on day one, and use separate keys for testing and live work. I'd never paste it into a tool I haven't checked or commit it anywhere, even a private repo. And if you're paying for Pro or Max, don't assume that covers the API: beyond any included credits, it's billed separately.

Frequently asked questions

Where do I find my Claude API key?

In the Claude Console, on the API keys page. You can create a new key there, and Anthropic advises copying it straight into a secrets manager.

Does my Claude Pro or Max subscription include API usage?

No. As of October 2026 API usage is billed separately through the Console. Max and Team plans include monthly API credits.

How do I revoke a Claude API key?

In the Console, open the three-dot menu next to the key and choose Delete API key, then create a new one.

How often should I rotate my Claude API key?

Anthropic recommends rotating on a schedule and gives every 90 days as an example.

What happens if my Claude API key leaks?

Whoever has it can run up charges on your account. Revoke it in the Console straight away, create a new one and store it in a secrets manager.

Does GitHub catch leaked Claude API keys?

Anthropic partners with GitHub's secret scanning programme, which scans public repositories for exposed Claude API keys. Keys shared anywhere else aren't covered by that scan.

Where should I store my Claude API key?

In an environment variable or encrypted secrets, with .env files added to .gitignore, and in a key management system as you scale.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.