Key takeaways
- Claude API keys are created on the API keys page of the Claude Console at platform.claude.com/settings/keys.
- The full key starts with sk-ant- and is shown only once, so it has to be copied and stored at creation.
- Anthropic recommends a personal key for your own work and a service account key for shared workloads.
To get a Claude API key, sign in to the Claude Console at platform.claude.com, open the API keys page, click Create key, and copy the key right away. The Console shows the full key only once. This guide follows Anthropic's own instructions for getting your Claude API key, as of October 28, 2026.
It is for anyone who wants to call Claude from code, a script or a tool that asks for an Anthropic API key. At the end you will have a key saved as an environment variable that the official SDKs pick up on their own.
What you need first
You need a Claude Console account. If you don't have one, you can create it at the same sign-in page. A Claude chat subscription and the Console are separate things: the API key comes from the Console.
How to get your Claude API key
- Sign in to the Claude Console. Go to platform.claude.com and sign in, or create an account.
- Open the API keys page. Go to
platform.claude.com/settings/keys. - Create a key. Click Create key. Name the key and pick an expiration. Set Linked account to yourself. You can also choose a workspace to limit the key to.
- Copy and store the key. The full key starts with
sk-ant-and is shown once, when you create it. Put it in a secrets manager. If you lose it, you can't view it again. Create a new one.
If the Create key button is greyed out, your role in the organization may not allow creating keys. Ask an organization admin to change your role, or to create a service account key for your workload.
Pick the right key type
Anthropic describes three types of key:
| Key type | Acts as | Best for | Stops working when |
|---|---|---|---|
| Personal key | You, with your roles and permissions | Your own development and scripts | You lose access to the organization |
| Service account key | A service account | CI pipelines, production services, agents | The service account is archived |
| Workspace key (legacy) | No one, it belongs to a workspace | Existing integrations only | It expires, is disabled or deleted, or its workspace is archived |
Anthropic's advice is to use a personal key for your own work and a service account key for anything shared. Workspace keys still work, but the docs call them legacy and say to prefer the other two.
How to set the key as an environment variable
The official client SDKs read the ANTHROPIC_API_KEY variable automatically. In a terminal:
export ANTHROPIC_API_KEY="your-api-key-here"
Replace the placeholder with your own key, and keep it out of source code and version control. For direct HTTP requests, Anthropic's authentication page says to send the key as Authorization: Bearer <key>. The older x-api-key header is still supported.
How to choose an expiration
When you create a key, you choose how long it lives: 3 hours, 1 day, 7 days, 30 days, a custom duration, or Never. Anthropic says to use Never only for keys you keep in a secrets manager and rotate yourself. If your organization sets a maximum, the Console limits the choices and Never is not available.
Expiration is set at creation and can't be changed later. An expired key returns a 401 authentication_error, and it can't be reactivated. Create a new one instead.
How to test your Claude API key
Anthropic's quickstart makes a first request with cURL. With the variable set, this is the call it shows:
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1000,
"messages": [
{"role": "user", "content": "Say hello in one sentence."}
]
}'
A JSON reply with a content field means the key works. The model name is the one used in the quickstart on October 28; check the models overview if it has changed. The quickstart also shows the same call in Python, TypeScript and several other languages, and with the ant command-line tool.
Common problems
- You lost the key. The Console can't show it again, and the Admin API can't recover it either. Create a new key and delete the old one.
- A 400 error about a workspace. If your key isn't scoped to a workspace, every request must include an
anthropic-workspace-idheader. Scoping the key to one workspace when you create it avoids this. You can find a workspace's ID in the ID column on the Workspaces page. - A 401 error. The key may have expired. Check the expiration column on the API keys page.
- You think a key leaked. Anthropic says to disable or delete it. Disable can be undone with Re-enable. Delete is permanent.
Where to go next
Once the key works, the Messages API guide covers conversations and system prompts. For production, Anthropic's authentication page recommends Workload Identity Federation, which swaps long-lived keys for short-lived tokens.
Frequently asked questions
Where do I find my Claude API key?
Existing keys are listed on the API keys page of the Claude Console. The Console does not show the full value of an existing key, so if you lost it, create a new one.
How do I set the ANTHROPIC_API_KEY environment variable?
Run export ANTHROPIC_API_KEY="your-api-key-here" in your terminal with your own key. Anthropic's client SDKs read this variable automatically.
Can I see my Claude API key again after creating it?
No. The Console shows the full key only once, at creation. Create a new key if you lose it.
Why is the Create key button disabled?
Your role in the organization may not allow creating keys. Anthropic says to ask an organization admin to change your role or to create a service account key.
Sources
- Get your Claude API keyAnthropic
- AuthenticationAnthropic
- Get started with ClaudeAnthropic


