API's Registrations For Agentic AI and Workflows

Registering for Claude and Creating Your API Key

Beginner Setup Anthropic / Claude API 20 minutes
Rupinder Singh
4 views
Create an Anthropic account, tour the Claude developer console at platform.claude.com, mint and safely store your first API key, and verify it with a live Messages API call.

What this lesson covers

Everything in this course runs on a Claude API key. In this lesson you create an Anthropic account, find your way around the developer console, mint your first API key, store it safely, and prove it works with a single request. Budget about 20 minutes.

Heads-up: the console has moved since this lecture was recorded.

  • console.anthropic.com now redirects to https://platform.claude.com. The old link still works, but bookmark the new one.
  • The documentation moved too: docs.anthropic.com and docs.claude.com both land on https://platform.claude.com/docs.
  • API keys now have an expiration setting chosen at creation time, and can be linked to a service account instead of a person.
  • Usage tiers are now named Start, Build, Scale, Custom.
  • Current models are claude-opus-5, claude-sonnet-5, claude-haiku-4-5-20251001 and claude-fable-5-1. Opus 5 is the recommended default.

Before you start

  • An email address you can receive verification mail on.
  • A terminal (macOS/Linux shell, or PowerShell/WSL on Windows).
  • A payment method. API usage is billed separately from a Claude.ai chat subscription — a Pro or Max plan does not include API credit.

The console is not the chat app. claude.ai is the consumer chat product. platform.claude.com is the developer platform where keys, usage, billing and the Workbench live. They use the same login but are billed separately.

Console tour (2 minutes)

Sign in at platform.claude.com. The landing screen offers Create prompt, Generate prompt and Get API key. The left-hand rail is where you will spend your time:

AreaWhat it is for
WorkbenchTest prompts against a model before writing any code; export the call as curl or SDK code.
UsageTokens and requests over time, filterable by model, key and workspace.
CostSpend broken down the same way.
LogsIndividual requests and responses — your first stop when something fails.
Batches / Files / EvalsBulk jobs, uploaded documents, and prompt test suites.
Settings → API keysCreate, disable, delete and audit keys.
Settings → Limits / BillingYour current usage tier, rate limits, spend caps and payment method.

Right-click the console logo (or use the help menu) for Documentation. The docs are organised into the Claude Developer Platform, Claude Code, Model Context Protocol and the API reference — this is the reference you will come back to all course long.

Lab 1 — Create the account and check your workspace

  1. Go to https://platform.claude.com and sign up (or sign in if you already have a Claude account).
  2. Verify your email and complete the organisation prompt. Every account gets an organisation and a Default Workspace.
  3. Open Settings → Billing and add a payment method or credits. Skip this and your first call returns 402 billing_error.
  4. Open Settings → Limits and note your tier (new accounts start on Start).

Done when: Settings → Billing shows an active payment method and Settings → Limits shows a tier.

Lab 2 — Create your first API key

  1. Go to Settings → API keys (or click Get API key on the landing screen), then Create key.
  2. Name: claude-api-course. Name keys after the thing that uses them — you will thank yourself when you have six.
  3. Workspace: leave it on Default Workspace for this course.
  4. Expiration: pick 30 days for a learning key. Options run from 3 hours to Never; expiry cannot be changed after creation, so a short-lived key means a leak dies on its own.
  5. Linked account: yourself. Service accounts are for shared or production workloads that must survive a person leaving.
  6. Click Add, then copy the key. It starts with sk-ant-api....

This is the only time the full key is shown. Copy it now. Never paste it into a screenshot, a chat, a git commit, or client-side code. If it leaks, delete it and create a new one — that is a 30-second job, not a crisis.

Done when: the key list shows claude-api-course, its workspace, its expiry date, and a masked key.

Lab 3 — Store the key safely

The SDKs read ANTHROPIC_API_KEY from the environment automatically, so you never have to hard-code it.

macOS / Linux — for the current shell:

export ANTHROPIC_API_KEY="sk-ant-api..."

To persist it, add that line to ~/.zshrc or ~/.bashrc, then source the file.

Windows PowerShell — current session, then persisted:

$env:ANTHROPIC_API_KEY = "sk-ant-api..."
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY","sk-ant-api...","User")

Per project, create a .env file and, in the same commit, a .gitignore that excludes it:

# .env
ANTHROPIC_API_KEY=sk-ant-api...

# .gitignore
.env

Done when: echo $ANTHROPIC_API_KEY (or echo $env:ANTHROPIC_API_KEY) prints your key, and git status does not list .env.

Lab 4 — Prove the key works

One request against the Messages API at https://api.anthropic.com:

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-5",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Reply with the words: key works."}]
  }'

Three headers matter: x-api-key carries your credential, anthropic-version pins the API version so future changes cannot break you, and content-type must be application/json.

Prefer Python? pip install anthropic, then:

import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY from the environment

message = client.messages.create(
    model="claude-opus-5",
    max_tokens=64,
    messages=[{"role": "user", "content": "Reply with the words: key works."}],
)
print(message.content[0].text)

Done when: you get a JSON response containing "type": "text" and the model's reply, and the call appears under Logs and Usage in the console within a minute or two.

Lab 5 — Rotate and revoke (do this once now)

Practise the recovery drill before you need it:

  1. Create a second key named throwaway-test with a 3 hour expiry.
  2. Swap ANTHROPIC_API_KEY to it and re-run the curl from Lab 4 — still works.
  3. In the console, Disable it, re-run the call, and confirm you now get 401 authentication_error.
  4. Re-enable it, confirm the call works again, then Delete it and switch back to claude-api-course.

That is the whole rotation procedure in production too: create new → deploy new → confirm traffic is healthy → delete old. Disable is reversible; delete is not.

Troubleshooting

SymptomErrorFix
Key rejected401 authentication_errorKey malformed, deleted, disabled or expired. Check for a trailing newline or quotes in the env var; expired keys cannot be reactivated — create a new one.
No payment method402 billing_errorAdd or fix payment details under Settings → Billing.
Key valid but blocked403 permission_errorThe key is scoped to a workspace that lacks access to the resource. Check the key's workspace.
Bad request, or spend limit hit400 invalid_request_errorUsually malformed JSON or a missing max_tokens. Also returned when you hit a spend limit you set yourself.
Too many requests429 rate_limit_errorRate limit or monthly tier spend cap. Back off and retry; check Settings → Limits.
Transient failure500 / 529 overloaded_errorRetry with exponential backoff. The official SDKs already do this twice by default.
$ANTHROPIC_API_KEY is emptyThe export applied to a different shell. Re-export, or add it to your shell profile and open a new terminal.

Every error response carries a request_id. Quote it when contacting support — it is how a failure gets traced.

Knowledge check

Q1. Where do you create an API key today?
Settings → API keys at platform.claude.com/settings/keys. console.anthropic.com redirects there.

Q2. You closed the tab without copying the key. What now?
Nothing to recover — the full value is shown once. Delete the key and create a new one.

Q3. Which three headers does a raw Messages API call need?
x-api-key, anthropic-version and content-type: application/json.

Q4. Why set an expiry on a learning key?
It caps the blast radius if the key leaks, and expiry cannot be changed later — so choosing it at creation is the only chance you get.

Q5. Your call returns 402. Is the key wrong?
No — 402 is a billing problem. A wrong key returns 401.

Q6. What is the difference between Disable and Delete?
Disable is reversible (re-enable restores the key). Delete is permanent; the key is archived and can never be used again.

FAQ

Does my Claude Pro or Max subscription include API usage?
No. Chat subscriptions and API usage are billed separately. You need billing set up on the developer platform.

Is there a free tier?
Assume not for planning purposes — set up billing and keep your first experiments small. Use claude-haiku-4-5-20251001 and a low max_tokens while learning; it costs a fraction of Opus.

How do I stop a runaway bill?
Set a spend limit under Settings → Billing. Exceeding it fails requests with 400 rather than charging you.

One key or many?
Many. One key per application and environment, so you can revoke a leaked key without taking down everything else, and read per-key usage in the console.

Can I use the key from a browser or mobile app?
Never. Anything shipped to a user's device can be read by that user. Put the key on a server and have your client call your server. Later lessons in this section follow exactly that pattern in Next.js, Node.js, PHP and n8n.

What is a workspace for?
Separating projects or teams. Keys can be scoped to one workspace, and usage, cost and spend limits are tracked per workspace. Default Workspace is fine for this course.

What is an Admin API key?
A different kind of key (prefix sk-ant-admin) used only to manage the organisation — members, workspaces, invites and keys — programmatically. It cannot call the Messages API, and only org admins can create one.

Which model should I start with?
claude-opus-5 is the recommended default. Swap in claude-sonnet-5 for a speed/intelligence balance or claude-haiku-4-5-20251001 when latency and cost matter most.

Resources

Next

Keep the key in your environment — the next lesson, Calling the Claude API with cURL and REST Basics, picks up from the request you just made.