Claude API keys

How to get a Claude API key (Anthropic API key)

To get a Claude API key, also called an Anthropic API key, sign in to the Claude Console, open the API keys page at platform.claude.com/settings/keys and click Create key. The Console shows the full key, which starts with sk-ant-, only once, so copy it into a secrets manager right away.

Calls are paid from prepaid credits, and each usage tier carries a monthly spend cap: $500 on Start, $1,000 on Build. Set your own lower limit, or a workspace limit, before the key goes into an app.

Create a Claude API key, step by step

  1. Sign in to the Claude Console, or create an account.
  2. Open the API keys page (platform.claude.com/settings/keys).
  3. Click Create key, name the key and pick an expiration.
  4. Set Linked account to yourself for a personal key, or to a service account for a key a workload uses. You can also scope the key to one workspace.
  5. Copy the key and store it in a secrets manager. You can't view it again.

Then set it as an environment variable. The Claude SDK reads ANTHROPIC_API_KEY on its own:

export ANTHROPIC_API_KEY="your-key-here"

If Create key is disabled, your role doesn't allow creating keys there. Ask an organization admin to change your role, or to create a service account key for your workload.

A key that isn't scoped to a workspace needs the anthropic-workspace-id header on every Claude API request. Scoping the key to a workspace when you create it saves you that header.

Personal, service account, workspace or Admin key

You pick the key type when you create it, and it decides what the key can do and when it stops working.

Key typeBelongs toWorks withUse it for
Personal keyYou. It stops working if you leave the organizationClaude APIYour own development
Service account keyA service accountClaude APICI pipelines, production services and agents
Workspace key (legacy)The workspace it was created in, with no ownerClaude APIOlder setups. Prefer the two above
Admin keyThe organization. Only admins create oneAdmin API, usage and cost reports, rate limitsOrganization management and reporting

Use a personal key for your own development and a service account key for anything shared. Workspace keys keep working after their creator leaves, which is exactly why Anthropic prefers the other two.

Admin keys start with sk-ant-admin01-. Organization members with the admin role create them on the Admin keys page. They have no selectable scopes: every Admin key has full access to all endpoints that accept Admin keys. The Admin API isn't available for individual accounts, so you need an organization first.

Expiration

Every key gets an expiration when you create it: 3 hours, 1 day, 7 days, 30 days, a custom duration, or Never. You can't change it later. An expired key returns 401 authentication_error and can't be reactivated, so pick Never only for keys you keep in a secrets manager and rotate yourself.

Where your key lives, and why you can't see it again

All keys are listed on the API keys page in the Claude Console, with their expiration. The full secret is shown only at creation. If you lose a key, create a new one. The Admin API can't recover a lost key either; it only ever returns a partially redacted hint.

Disable on the API keys page is reversible: Re-enable brings the key back. Delete is permanent.

Key not working? A 401 authentication_error means the key is malformed, revoked or expired. A 403 permission_error means the key can't use that resource, so check your organization's access and workspace settings.

Billing: prepaid credits

Creating a key is free. Calls are billed through prepaid usage credits, which someone with the Admin or Billing role buys on the Billing page (platform.claude.com/settings/billing). You're billed only for successful calls; failed requests aren't charged. Credits expire one year after purchase and are non-refundable.

If you run out of credits, you can't call the API until you add more. Auto-reload buys credits automatically when the balance drops below a threshold you set. Claude Max, Ultra and Team plans include monthly API credits once you link a Console organization to the plan.

How credits work in detail is in Claude API credits, and prices per model are in Claude API pricing.

Cap what the key can spend

Anthropic's spend limits sit on the organization and on workspaces. Each usage tier has a monthly spend cap: $500 on Start, $1,000 on Build and $200,000 on Scale. New organizations may start in an Evaluation tier with lower limits. At the cap, usage pauses until 00:00 UTC on the first day of the next month, and requests return a 429.

You can set your own lower limit on the Billing page. Once usage reaches it, requests return HTTP 400 with invalid_request_error.

To cap one app, give its key its own workspace and set a workspace spend limit: open Workspaces, select the workspace and click Spend limits. The Default Workspace can't have one. Full steps are in How to set a Claude API spending limit.

Keep the key out of code, git and browsers

  • Store it in a secrets manager and pass it to your app as an environment variable.
  • Using a .env file locally? Add it to .gitignore.
  • Call Claude from your back end, never from browser code. Anyone who uses a web page can read a key in that page's code.
  • Use separate keys for development, testing and production, so a leak only means disabling one of them.
  • Rotate on a schedule, for example every 90 days, and give keys an expiration.

Anthropic is part of GitHub's secret scanning partner program. If a Claude API key shows up in a public GitHub repository, Anthropic automatically deactivates it. Anywhere else, it's on you: disable or delete the key right away and check what it spent. The first hour after a key leaks covers the rest.

Watch what the key spends

A monthly cap stops spend at a ceiling. Costbrake reads Anthropic's usage and cost reports and also alerts on a spike: an hour that costs more than 3x your usual hour and at least $5 more.

It needs an Admin key from Settings, Admin keys, created by an organization admin. Anthropic has no read-only Admin key, so store it like any admin credential. On Pro and Team, Costbrake checks every 5 minutes, and every minute during a spike. Free checks hourly. Setup steps are on the Anthropic integration page.

Pro and Team can add brakes: disable one API key, or disable every active key in a workspace (up to 60 per brake), so requests with them fail right away. Undo sets exactly those keys back to active. A brake never fires on its own: an admin clicks it and confirms. Plans are on the pricing page, and new workspaces get a 14-day Pro trial with no card.

Questions and answers

Is a Claude API key free?

Creating a key is free, but Claude API usage is billed through prepaid usage credits. When the credits run out you can't call the API until you add more. Claude Max, Ultra and Team plans include monthly API credits once you link a Claude Console organization to the plan.

Where do I find my Anthropic API key again?

You can't see the full key again. The Claude Console shows it once, at creation, and the Admin API only returns a redacted hint. Create a new key on the API keys page, switch your app to it, then disable or delete the old one.

Why is my Claude API key not working?

A 401 authentication_error means the key is malformed, revoked or expired, and expired keys can't be reactivated. A 403 permission_error means the key can't use that resource, so check workspace settings. A key that isn't scoped to a workspace also needs the anthropic-workspace-id header on every request.

How do I limit what an Anthropic API key can spend?

Put the key in its own workspace and set a monthly spend limit on that workspace in the Claude Console, under Workspaces, then Spend limits. You can also set an organization limit below your tier's cap on the Billing page. The Default Workspace can't have a spend limit.

What happens if my Claude API key leaks?

If it lands in a public GitHub repository, Anthropic deactivates it automatically through GitHub secret scanning. Anywhere else, disable or delete it yourself on the API keys page, create a replacement, and check usage for spend you don't recognize.

Sources

Updated