---
title: "Claude API keys: how to get, scope, store, rotate, and revoke them"
description: "Claude API keys explained: get one in the Claude Console, choose a key type, scope it to a workspace, set an expiration, and rotate or revoke it safely."
summary: "A step-by-step guide to creating a Claude API key on platform.claude.com and sending a first request. It then covers personal and service account keys, workspace scoping, expiration, storage, zero-downtime rotation, leak response, common errors, and when to switch to Workload Identity Federation."
type: "guide"
canonical_url: "https://theaiengineering.com/articles/claude-api-keys"
markdown_url: "https://theaiengineering.com/articles/claude-api-keys.md"
topic: "AI engineering"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
published: "2026-11-23"
updated: "2026-11-23"
keywords: ["claude api keys","how to get claude api key","anthropic api key","claude code api key","where to find claude api key","claude api key free"]
citation: "The AI Engineering Editors. \"Claude API keys: how to get, scope, store, rotate, and revoke them.\" The AI Engineering, updated Nov 23, 2026. https://theaiengineering.com/articles/claude-api-keys"
---

# Claude API keys: how to get, scope, store, rotate, and revoke them

## TL;DR

- Claude API keys are static secrets that start with sk-ant-, are created on the API keys page of the Claude Console at platform.claude.com, and are shown in full only once.
- A personal key acts as its user and a service account key acts as a non-human identity, so both stop working when that identity is removed; workspace keys are a legacy type with no owner.
- A key scoped to one workspace always runs there, while a key without a workspace scope must send the anthropic-workspace-id header on every request or get a 400 error.
- Disable is reversible and Delete is permanent, so a zero-downtime rotation deploys the new key, confirms traffic, disables the old key, and deletes it last.
- Workload Identity Federation replaces static keys with short-lived tokens exchanged from an identity provider such as AWS, Google Cloud, Azure, GitHub Actions, or Kubernetes.

A Claude API key is a static secret, starting with `sk-ant-`, that authenticates requests to the Claude API and draws on the credits of the organization that created it. Claude API keys, which Anthropic also calls Anthropic API keys, are created in the Claude Console at `platform.claude.com`, and the old `console.anthropic.com` address now redirects there. This guide covers getting a key and then the choices that limit what a leaked key can do: key type, workspace scope, expiration, storage, rotation, and revocation. It belongs to the [AI engineering fundamentals](https://theaiengineering.com/topics/ai-engineering) hub.

## What is a Claude API key?

A Claude API key is a secret credential from the Claude Console that a program sends with every Claude API request to identify the organization, workspace, and identity behind it. Each key belongs to one organization, its usage is billed to that organization, and the Console never displays the full secret after creation.

Claude API keys are one of four credentials that reach Claude:

| Credential | Where it comes from | What it authenticates | Format or billing |
|---|---|---|---|
| Claude API key | API keys page in the Claude Console | Messages and the other Claude API endpoints | Starts with `sk-ant-api`; usage is billed to the Console organization |
| Admin API key | Admin keys page, created by organization admins | Admin API, usage and cost reports, Rate Limits API | Starts with `sk-ant-admin01-` in Console organizations |
| Claude plan login | A Pro, Max, Ultra, Team, or Enterprise plan | Claude apps and Claude Code sign-in | Billed separately from the API |
| Cloud provider credentials | AWS, Google Cloud, or Microsoft Azure | Claude on Amazon Bedrock, Google Cloud, and Microsoft Foundry | The cloud provider's IAM and billing |

Anthropic's [API overview](https://platform.claude.com/docs/en/api/overview) states that requests through a cloud platform authenticate with that provider's IAM system, not with a Console key, so this guide covers the first row only.

## How to get a Claude API key

You get a Claude API key by signing in to the Claude Console, making sure the organization has credits, and clicking **Create key** on the API keys page. Creating the key is free, but every request is billed, usually from prepaid credits, and the Console shows the full secret only once, so copy it straight into a secrets manager. The steps, as of November 2026:

1. **Sign in.** Go to [platform.claude.com](https://platform.claude.com/) and sign in, or create a Console account.
2. **Add credits.** API calls and the playground stop working at a zero balance, so a user with the Admin or Billing role buys credits first on the Billing page (`platform.claude.com/settings/billing`), as [Anthropic's billing article](https://support.claude.com/en/articles/8977456-how-do-i-pay-for-my-claude-api-usage) explains. Purchased credits expire one year after purchase.
3. **Open the API keys page** at `platform.claude.com/settings/keys` and click **Create key**.
4. **Configure the key.** Enter a name, select an expiration, and set **Linked account** to yourself (a personal key) or to a service account (a service account key). Optionally, pick a workspace to scope it to.
5. **Copy the secret.** The full key starts with `sk-ant-` and appears once. Store it in a secrets manager right away.

If **Create key** is disabled, your role does not allow key creation there. Organization developers and admins can manage keys, as can the Workspace Developer and Workspace Limited Developer roles inside a workspace, while the organization user role can only use the playground. Ask an admin to change your role or to create a service account key, as [Anthropic's key guide](https://platform.claude.com/docs/en/get-api-key) suggests.

### Make a test request

Set the key as an environment variable and send a small request. The official SDKs read `ANTHROPIC_API_KEY` automatically, and direct HTTP requests send the key as a bearer token:

```bash
export ANTHROPIC_API_KEY="sk-ant-api03-..."

curl https://api.anthropic.com/v1/messages \
  -H "Authorization: Bearer $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-haiku-5-5",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Reply with OK."}]
  }'
```

A JSON response with a `content` array confirms the key works. [Claude Haiku 5.5](https://theaiengineering.com/releases/2026/10#claude-haiku-5-5), the fastest and lowest-priced model in Anthropic's November 2026 lineup, keeps the test cheap, and the [Anthropic release history](https://theaiengineering.com/releases/anthropic) lists the others. The legacy `x-api-key` header also still works in place of `Authorization`.

## Choose the right key type

Use a personal key for your own development and scripts, and a service account key for anything shared, such as CI pipelines, production services, and [AI agents](https://theaiengineering.com/glossary/ai-agent). Both types are identity-backed: each acts as a user or service account the organization manages and stops working when that identity is removed. Skip workspace keys, a legacy type, for new integrations.

| Key type | Acts as | Stops working when | Use it for |
|---|---|---|---|
| Personal key | You, with your roles and permissions | You lose access to the organization; the key is archived when you are removed | Your own development and scripts |
| Service account key | A service account that an organization admin creates | The service account is archived | CI, production services, and agents |
| Workspace key (legacy) | No one; it belongs to the workspace it was created in | It expires, is disabled or deleted, or its workspace is archived | Existing integrations you plan to migrate |

The difference shows up during offboarding. A shared personal key breaks the integration when its owner leaves, and a workspace key keeps working for anyone who copied it, while a service account key outlives its creator and stops only when an admin archives the service account. [Anthropic's authentication docs](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) add that a single-workspace key also stops working when its owner loses access to that workspace.

To retire a workspace key, have an organization admin create a service account on the Service accounts page (`platform.claude.com/settings/service-accounts`), create a key for the integration's workspace, deploy it, confirm that requests succeed, and delete the old key.

## Scope Claude API keys to workspaces

Scope each key to a single workspace, and give development, staging, and production their own workspaces. A key created for one workspace always runs there, so its requests can omit the workspace ID. A key without a workspace scope must send an `anthropic-workspace-id` header on every request, or the Claude API returns a 400 `invalid_request_error`.

A [workspace](https://platform.claude.com/docs/en/manage-claude/workspaces) groups members, service accounts, API keys, and limits inside one organization. Every organization has a Default Workspace that cannot be renamed, archived, or deleted, and only organization admins can create more. Workspace IDs start with `wrkspc_` and appear in the ID column of the Workspaces page.

For a key without a workspace scope, set the header once on the SDK client:

```python
from anthropic import Anthropic

client = Anthropic(  # reads ANTHROPIC_API_KEY
    default_headers={"anthropic-workspace-id": "wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ"},
)
```

Successful responses carry an `anthropic-workspace-id` header naming the workspace each request counted against.

Workspaces also cap what a leaked key can spend. Set a monthly spend limit per workspace on the Spend limits page, and per-model [rate limits](https://theaiengineering.com/glossary/rate-limiting) in requests, input [tokens](https://theaiengineering.com/glossary/tokens), and output tokens per minute on the Rate limits page. Workspace limits can sit below the organization's limits but cannot raise them.

Check two side effects before reorganizing:

- Archiving a workspace archives every API key created for it within seconds, and the archive cannot be undone.
- [Prompt caches](https://theaiengineering.com/glossary/prompt-caching) are isolated by workspace on the Claude API, so splitting one workload across workspaces also splits its cache.

## Set an expiration on every key

Pick the shortest expiration the job allows when you create a key, because the expiration cannot be changed afterward. The Console offers presets of 3 hours, 1 day, 7 days, or 30 days, a custom duration, or Never, which Anthropic intends for keys stored in a secrets manager and rotated on your own schedule.

An organization's maximum expiration policy caps presets and custom durations and removes Never. Anthropic emails the creator 7 days before expiry for keys with a lifetime of at least 14 days, and 1 day before for keys of at least 7 days. An expired key returns `401 authentication_error` and can only be deleted, not reactivated, as the [key expiration docs](https://platform.claude.com/docs/en/manage-claude/authentication#key-expiration) explain.

| Use case | Suggested expiration | Warning email |
|---|---|---|
| Workshop, demo, or contractor test | 3 hours or 1 day | None |
| Personal development key | 7 or 30 days | 1 day ahead (7 days) or 7 days ahead (30 days) |
| CI pipeline that cannot use federation | 30 days, rotated by the pipeline | 7 days ahead |
| Production service in a secrets manager | Never, with scheduled rotation | Not applicable |

These are this guide's suggestions, not Anthropic defaults.

## Store and use Claude API keys safely

Keep Claude API keys out of source code. Load each key from the `ANTHROPIC_API_KEY` environment variable during development and from encrypted secret storage in the cloud, call Claude only from your back end, and give every person and workload its own key, so one key can be revoked without breaking the others.

[Anthropic's key safety article](https://support.claude.com/en/articles/9767949-api-key-best-practices-keeping-your-keys-safe-and-secure) adds these rules:

- **Use the environment variable.** The official SDKs read `ANTHROPIC_API_KEY`, so the key stays out of code.
- **Git-ignore `.env` files.** List local `.env` files in `.gitignore`, and use the cloud provider's secret manager in deployments.
- **Keep keys personal.** Give each person their own key, and never paste one into email, forums, or support tickets, including tickets to Anthropic.
- **Vet third-party tools.** A key uploaded to a web IDE or CI platform gives that tool's developer access to your Console account, so store it there only as an encrypted secret.
- **Scan for secrets.** Run secret scanning, with a tool such as Gitleaks, in source control and CI before code reaches the main branch.

Anthropic also takes part in GitHub's secret scanning partner program. When GitHub detects a Claude API key in a public repository, Anthropic deactivates the key automatically and emails the affected user.

Never ship a key in browser code, where anyone using the page can read it; the front end should call your back end, which holds the key. The API rejects cross-origin browser requests without the `anthropic-dangerous-direct-browser-access: true` header, and organizations with zero data retention or the Compliance API enabled cannot call it from a browser at all.

Teams with many services can put an [AI gateway](https://theaiengineering.com/articles/what-is-an-ai-gateway) in front of Claude, so the gateway holds the provider key and each application gets its own [virtual key](https://theaiengineering.com/glossary/virtual-key). Keys also leak through agents: a key pasted into a prompt, a tool result, or a log line is exposed to every system that reads that text, a risk the [MCP security guide](https://theaiengineering.com/articles/mcp-security) covers for tool servers.

## Rotate a Claude API key without downtime

Rotate a key by running the replacement alongside the old key until traffic has moved, then retiring the old key in two steps: disable it, and delete it after a quiet period. Anthropic's key safety article recommends rotating on a consistent schedule and gives every 90 days as an example.

1. Create the new key with the same type, workspace, and linked account, plus an expiration.
2. Store it in your secrets manager under the name your service reads, usually `ANTHROPIC_API_KEY`.
3. Deploy, then confirm on the Console's Logs and Usage pages that requests succeed.
4. Disable the old key. Disable is reversible, so **Re-enable** restores it if a forgotten job still depended on it.
5. Delete the old key once no authentication errors appear. Delete is permanent, and the Admin API lists the key as `archived`.

**Figure 1: Zero-downtime rotation. The old key stays valid until the new key is confirmed in production.**

Sequence for rotating a Claude API key: create and store a new key, deploy it, confirm traffic in the Console, then disable and delete the old key.

Steps:

1. Engineer → Claude Platform: Create new key
2. Claude Platform → Engineer: Secret, shown once
3. Engineer → Secrets manager: Store new key
4. Service → Secrets manager: Read on deploy
5. Service → Claude Platform: Requests, new key
6. Engineer → Claude Platform: Check Logs, Usage
7. Engineer → Claude Platform: Disable old key
8. Engineer → Claude Platform: Delete old key

### Audit keys with the Admin API

The [Admin API](https://platform.claude.com/docs/en/manage-claude/admin-api) reads and updates existing keys across an organization, but it cannot create them. List API Keys returns each key's `status`, its `expires_at` timestamp (`null` when the key never expires), its `scope`, and its `principal`, which is `null` for a legacy workspace key. Update API Key renames a key or sets its status to `active`, `inactive`, or `archived`.

```bash
# Active keys with no expiration, a common audit target
curl "https://api.anthropic.com/v1/organizations/api_keys?status=active&limit=100" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  -H "anthropic-version: 2026-10-21" \
  | jq -r '.data[] | select(.expires_at == null) | "\(.id) \(.name) \(.partial_key_hint)"'

# Disable one key (reversible with status "active")
curl "https://api.anthropic.com/v1/organizations/api_keys/$API_KEY_ID" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -H "content-type: application/json" \
  -d '{"status": "inactive"}'
```

The Admin API accepts an Admin API key, an `org:admin` OAuth token, or a personal or service account key without a workspace scope; workspace keys do not work there. Only organization admins can create Admin API keys, and an individual Console account must set up an organization first. No endpoint returns a key's secret, only a partially redacted hint such as `sk-ant-api03-R2D...igAA`.

## Revoke a Claude API key after a leak

Revoke a key on the API keys page of the Console. **Disable** stops the key and can be undone, while **Delete** archives it permanently. If a key may have leaked, delete it right away, create and deploy a replacement, and then review the Logs and Usage pages for requests you do not recognize.

**Figure 2: Claude API key statuses as the Admin API reports them. Only Disable can be undone, and Delete is permanent from any status.**

Claude API key statuses: an active key becomes inactive when disabled or expired when its expiration passes, and deleting a key from any status archives it permanently.

Components:

- **Active**: Requests succeed
- **Inactive**: Disabled in the Console Re-enable restores it
- **Archived**: Deleted, permanent Still listed by Admin API
- **Expired**: Requests return 401 Can only be deleted

Connections:

- Active → Inactive: Disable
- Inactive → Archived: Delete
- Active → Expired: expires_at passes
- Expired → Archived: Delete

[Anthropic's steps for a compromised key](https://support.claude.com/en/articles/8384961-what-should-i-do-if-i-suspect-my-api-key-has-been-compromised) are short:

1. On the API keys page, open the menu (three horizontal dots) next to the key and select **Delete API key**.
2. Click **Create key**, store the replacement in a secrets manager, and redeploy the affected services.
3. Review the Logs (`platform.claude.com/logs`) and Usage pages for unfamiliar traffic.
4. Contact Anthropic support if suspicious activity continues.

When exposure is uncertain, Disable stops the key at once and can still be undone. After the incident, limit what the next leaked key could do:

- **Spend limit.** Set your own monthly limit below your tier's cap on the Spend limits page. Once usage reaches it, requests return HTTP 400 instead of accumulating charges, as the [spend limit docs](https://platform.claude.com/docs/en/api/rate-limits#setting-your-own-spend-limit) describe.
- **IP allowlisting.** [IP allowlisting](https://platform.claude.com/docs/en/manage-claude/ip-allowlist), in beta as of November 2026, lets an organization admin or owner list the public IP ranges allowed to call the API. Requests from anywhere else get a 403 `permission_error`, so a stolen key fails outside your network. Changes take up to 15 minutes, so list every server, CI runner, VPN, and office network first.

## Claude API key errors and fixes

Most key problems surface as a 401, 403, 400, 404, or 429 response, and the error type and message usually name the cause: a bad or expired key, a missing permission or blocked IP address, a missing workspace header, an unreachable workspace, or a limit. [Anthropic's error reference](https://platform.claude.com/docs/en/api/errors) lists every code.

| Status and type | Key-related cause | Fix |
|---|---|---|
| 401 `authentication_error` | The key is malformed, disabled, deleted, or expired | Check the stored value; create and deploy a new key |
| 403 `permission_error` | The key lacks access to the resource, or the IP address is outside the allowlist | Check workspace access and the allowlist |
| 400 `invalid_request_error` | The key has no workspace scope and the header is missing, or your own spend limit is reached | Add `anthropic-workspace-id`, or raise the limit |
| 404 `not_found_error` | The workspace ID does not exist, or the key's identity has no access to it | Check the ID and the account's workspace membership |
| 429 `rate_limit_error` | A rate limit, or the tier's monthly spend cap | Wait for `retry-after`; for the cap, request a tier increase |

A spend-cap 429 carries no `retry-after` header and has the `error_code` `enforced_spend_limit_reached`, and retries fail until the next month starts at 00:00 UTC or the tier is raised. As of November 2026, the Start, Build, and Scale tiers cap monthly spend at $500, $1,000, and $200,000. Logging status codes per service, part of [LLM observability](https://theaiengineering.com/articles/llm-observability), surfaces a revoked or expired key before users report it.

## How to use a Claude API key with Claude Code

Claude Code uses an API key when `ANTHROPIC_API_KEY` is set and you approve it at the prompt, and that key takes priority over a Pro, Max, Ultra, Team, or Enterprise subscription login. To go back to the subscription, run `unset ANTHROPIC_API_KEY`, then run `/status` to confirm which credential is active.

[Claude Code's authentication docs](https://code.claude.com/docs/en/authentication) give the full precedence order when several credentials are present:

1. Cloud provider credentials, when `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX`, or `CLAUDE_CODE_USE_FOUNDRY` is set
2. `ANTHROPIC_AUTH_TOKEN`, sent as a bearer token, for LLM gateways and proxies
3. `ANTHROPIC_API_KEY`, sent as the `X-Api-Key` header
4. The output of an `apiKeyHelper` script, for rotating or vault-issued credentials
5. `CLAUDE_CODE_OAUTH_TOKEN`, a long-lived token from `claude setup-token`
6. Anthropic profile and federation credentials
7. The subscription login from `/login`

In interactive mode, Claude Code asks once whether to use the key and remembers the answer, which the "Use custom API key" toggle in `/config` changes; with `-p`, the key is always used. A key from a disabled or expired organization therefore breaks sessions even for subscribers.

Signing in with a Console account instead mints a per-user API key in the organization's Claude Code workspace, and that key stops working when the member is removed. The [Claude Code vs Cursor comparison](https://theaiengineering.com/articles/claude-code-vs-cursor) covers plan pricing, and the [AI coding agents guide](https://theaiengineering.com/articles/ai-coding-agents) covers team rollout.

## When to replace static API keys

Move a production workload to Workload Identity Federation once it runs somewhere with a platform identity, such as AWS, Google Cloud, Azure, GitHub Actions, or Kubernetes. Federation exchanges that identity for short-lived Claude API tokens with the same API access as a key, so there is no `sk-ant-api` string to distribute or rotate.

With [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation), the workload exchanges its identity provider's token at `POST /v1/oauth/token` for a short-lived access token that the SDK refreshes automatically. Setup needs a service account, a federation issuer, and a federation rule in the Console. Federation is only as strong as the identity provider's configuration, so protect any static credential that can mint its tokens.

Two other cases avoid static keys:

- **Local development.** Anthropic's [quickstart](https://platform.claude.com/docs/en/get-started) recommends signing in with the `ant` CLI through `ant auth login`, after which the SDKs and CLI pick up the credential automatically.
- **iOS and macOS apps.** App Attest issues each genuine installation of a registered app a token that is scoped to a workspace, expires after 1 hour, and authorizes only Messages API calls.

## Where to go next

With Claude API keys scoped and on a rotation schedule, the next step is building with them. The guide to [building an AI agent](https://theaiengineering.com/articles/how-to-build-an-ai-agent) puts a key to work in a Python agent loop, the [AI engineer roadmap](https://theaiengineering.com/articles/ai-engineer-roadmap) places model APIs in a wider learning path, and the [model providers directory](https://theaiengineering.com/platforms/model-providers) compares Anthropic with the other labs that offer model APIs.

## Frequently asked questions

### Is a Claude API key free?

Creating a Claude API key costs nothing, but using it does. Claude API requests usually draw on prepaid usage credits that a user with the Admin or Billing role buys on the Console's Billing page, and an organization with no credits cannot call the API or use the playground. Claude Max, Ultra, and Team plans include monthly API credits once a Console organization is linked to the plan.

### Where do I find my Claude API key?

Claude API keys are listed on the API keys page of the Claude Console at platform.claude.com/settings/keys, and the old console.anthropic.com address redirects there. The page shows each key's name and expiration but never the full secret, which the Console displays only once, at creation. If the secret is lost, create a new key, deploy it, and delete the old one.

### Can I view or copy my Claude API key again?

No. The Claude Console shows the full key, which starts with sk-ant-, only once, when it is created. Afterward neither the Console nor the Admin API can reveal it; the Admin API returns only a partially redacted hint that helps identify the key. Copy each new key straight into a secrets manager, and replace any key whose secret has been lost.

### Does a Claude Pro or Max subscription include API access?

A Claude subscription and the Claude API are billed separately: paid plans cover the Claude apps, and API usage runs on Console credits. Of the paid plans, Anthropic lists Max, Ultra, and Team as including monthly API credits, claimed by linking a Claude Console organization to the plan. Those credits expire at the end of each billing cycle and cannot be spent in Claude Code or the Claude apps.

### Are Claude API keys the same as Anthropic API keys?

Yes. Anthropic's documentation uses both names for the same credential: a secret starting with sk-ant- that is created in the Claude Console and authenticates requests to the Claude API. The Console moved from console.anthropic.com to platform.claude.com, while the API itself is still served from api.anthropic.com. Admin API keys, which start with sk-ant-admin01- in Console organizations, are a separate credential for organization management.

### Do Claude API keys work with Amazon Bedrock or Google Cloud?

They are separate credentials. Claude on Amazon Bedrock, Google Cloud, and Microsoft Foundry authenticates through the cloud provider's IAM system and bills through the cloud account, while a Claude Console key authenticates the first-party Claude API. Console controls follow the same split: Anthropic's IP allowlist, for example, does not apply to Claude on Amazon Bedrock, Google Cloud, or Microsoft Foundry.

## Terms in this guide

- [AI agent](https://theaiengineering.com/glossary/ai-agent): An AI agent is a software system in which a large language model runs in a loop, calling tools, reading their results, and repeating until the task is complete or a stop condition is reached.
- [Rate limiting](https://theaiengineering.com/glossary/rate-limiting): Rate limiting is the enforcement of a maximum number of requests or tokens a client may send to an API within a time window, with excess requests rejected, usually with HTTP 429.
- [Tokens](https://theaiengineering.com/glossary/tokens): Tokens are the units of text a language model processes, typically whole words, word fragments, punctuation, or bytes, each mapped to an integer ID from the model's fixed vocabulary.
- [Prompt caching](https://theaiengineering.com/glossary/prompt-caching): Prompt caching is an LLM API and inference-server feature that stores the computed attention state for a repeated prompt prefix, so later requests sharing that prefix skip reprocessing it.
- [AI gateway](https://theaiengineering.com/glossary/ai-gateway): An AI gateway is a proxy layer between applications and model providers that exposes one API for many models and centralizes routing, failover, access control, cost tracking, caching, and logging.
- [Virtual key](https://theaiengineering.com/glossary/virtual-key): A virtual key is an API key issued by an AI gateway that maps a caller to its allowed models, budget, and rate limits, while the gateway keeps the real provider credentials.

## Related guides

- [How to build an AI agent: a step-by-step guide in Python](https://theaiengineering.com/articles/how-to-build-an-ai-agent): Learn how to build an AI agent from scratch in Python: when you need one, tool schemas, the agent loop, stop conditions, guardrails, evals, and tracing.
- [Claude Code vs Cursor: how the two coding agents differ](https://theaiengineering.com/articles/claude-code-vs-cursor): Claude Code vs Cursor compared: terminal agent vs AI editor, models, subagents, hooks, rules files, code review, CI use, pricing, and enterprise controls.
- [What is an AI gateway? How it works and when you need one](https://theaiengineering.com/articles/what-is-an-ai-gateway): An AI gateway is a proxy between your apps and model providers. Learn how it works, its core features, AI gateway vs API gateway, and open source options.
- [AI engineer roadmap: skills, projects, and resources by stage](https://theaiengineering.com/articles/ai-engineer-roadmap): A practical AI engineer roadmap in seven stages, each with the skills to learn, a project to ship, and resources worth the time, from Python to production.

Part of the [AI engineering](https://theaiengineering.com/topics/ai-engineering) topic hub.

## Cite this guide

The AI Engineering Editors. "Claude API keys: how to get, scope, store, rotate, and revoke them." The AI Engineering, updated Nov 23, 2026. https://theaiengineering.com/articles/claude-api-keys

- Title: Claude API keys: how to get, scope, store, rotate, and revoke them
- Author: The AI Engineering Editors
- Publisher: The AI Engineering
- Published: 2026-11-23
- Updated: 2026-11-23
- URL: https://theaiengineering.com/articles/claude-api-keys
- Markdown: https://theaiengineering.com/articles/claude-api-keys.md

To cite one section, link to its anchor:

- [What is a Claude API key?](https://theaiengineering.com/articles/claude-api-keys#what-is-a-claude-api-key)
- [How to get a Claude API key](https://theaiengineering.com/articles/claude-api-keys#how-to-get-a-claude-api-key)
- [Choose the right key type](https://theaiengineering.com/articles/claude-api-keys#choose-the-right-key-type)
- [Scope Claude API keys to workspaces](https://theaiengineering.com/articles/claude-api-keys#scope-claude-api-keys-to-workspaces)
- [Set an expiration on every key](https://theaiengineering.com/articles/claude-api-keys#set-an-expiration-on-every-key)
- [Store and use Claude API keys safely](https://theaiengineering.com/articles/claude-api-keys#store-and-use-claude-api-keys-safely)
- [Rotate a Claude API key without downtime](https://theaiengineering.com/articles/claude-api-keys#rotate-a-claude-api-key-without-downtime)
- [Revoke a Claude API key after a leak](https://theaiengineering.com/articles/claude-api-keys#revoke-a-claude-api-key-after-a-leak)
- [Claude API key errors and fixes](https://theaiengineering.com/articles/claude-api-keys#claude-api-key-errors-and-fixes)
- [How to use a Claude API key with Claude Code](https://theaiengineering.com/articles/claude-api-keys#how-to-use-a-claude-api-key-with-claude-code)
- [When to replace static API keys](https://theaiengineering.com/articles/claude-api-keys#when-to-replace-static-api-keys)
- [Where to go next](https://theaiengineering.com/articles/claude-api-keys#where-to-go-next)
- [Frequently asked questions](https://theaiengineering.com/articles/claude-api-keys#faq)
