"paste it in. My openclaw webui dashboard shows up but I can't chat."
That was February 2026 on r/openclaw. Someone had generated a Claude setup-token, pasted it into OpenClaw, and got a dashboard that loaded but an agent that wouldn't talk.
Seven months later, an OpenClaw issue put it more bluntly: "Anthropic now rejects setup tokens from third-party apps unless extra usage is purchased." The error on that Max account read "API Error: 400 Third-party apps now draw from your extra usage, not your plan limits." (The full OpenClaw story is in our OpenClaw and Anthropic subscription timeline.)
So what is this token actually for? And why does it work in one place and fail in another?
The short version:
claude setup-tokenprints a one-year OAuth token tied to your Claude subscription. Anthropic documents it for "CI pipelines, scripts, or other environments where interactive browser login isn't available": you set it asCLAUDE_CODE_OAUTH_TOKENand Claude Code uses your plan. It isn't an API key, it isn't saved anywhere, and it needs a paid plan. Pasting it into a third-party agent like OpenClaw or Hermes is the "intermediate … session tokens" case Anthropic's terms prohibit. Use an API key there instead.
What claude setup-token does, and what it doesn't
Anthropic's authentication docs describe it in one line: "For CI pipelines, scripts, or other environments where interactive browser login isn't available, generate a one-year OAuth token with claude setup-token."
The flow is the same as /login. A browser opens, you approve, and the token prints in your terminal. The docs add: "It does not save the token anywhere; copy it and set it as the CLAUDE_CODE_OAUTH_TOKEN environment variable wherever you want to authenticate."
Tokens start with sk-ant-oat01-. Anthropic's docs don't state that prefix, but it appears in GitHub issues and in OpenClaw's documentation.
Note what the docs don't say. They never call it "CI only". Scripts and headless machines count too.
Here's what it can't do:
- Start Remote Control sessions or fetch claude.ai connectors (locally configured MCP servers still work)
- Run in bare mode or with
CLAUDE_CODE_SIMPLE=1, which ignore it - Read your usage through
/api/oauth/usage, which returns 403 because the token lacks theuser:profilescope - Spend your Max or Ultra monthly API credit, because it isn't a Console key
It bills your subscription's plan limits, exactly like /login. That includes GitHub Actions: runs started by the Claude Code GitHub Action "count as Claude Code usage, so API credits don't cover them, even with -p."
If you're weighing this against a third-party agent like Hermes, our Hermes subscription status guide explains which route sits on which side of Anthropic's rule.
Who can create a Claude setup token
The docs said on 29 November that the token "requires a Pro, Max, Ultra, Team, or Enterprise plan." So not Free.
One admin detail is worth knowing. claude setup-token and /install-github-app "enforce only forceLoginMethod, so they can mint a token in a different organization." If your company relies on forceLoginOrgUUID to keep logins inside your organisation, this is a gap to plan around.
Using it correctly: CI, scripts and headless servers
Generate it on any machine with a browser:
claude setup-token
# approve in the browser, then copy the token from the screen
Then set it where Claude Code runs:
# macOS, Linux, WSL
export CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-...
claude -p "Summarise the failing tests in this repo"
# Windows PowerShell
$env:CLAUDE_CODE_OAUTH_TOKEN = "sk-ant-oat01-..."
Anthropic's environment-variable reference adds a useful detail: "Unless you run /login, Claude Code uses the token you set for the whole session. To replace an expired token, generate a new one and restart."
The gotcha that breaks CI scripts
Don't try $(claude setup-token) in a script. Claude Code issue #97350 explains why: the command "writes the token and its interactive UI to the same stdout," so the captured value needs cleaning up. Copy it from the screen instead.
Headless servers
On a VPS with no browser, run claude setup-token on your laptop and paste the token into the server's environment. That's the documented use.
If the command isn't found, install or update Claude Code first (npm install -g @anthropic-ai/claude-code or claude update). On zsh, check that the install folder is on your PATH.
GitHub Actions
Store the token as a repository secret named CLAUDE_CODE_OAUTH_TOKEN and pass it to the action's claude_code_oauth_token input.
Stay with me here, because this catches teams out. Anthropic's docs warn that an OAuth token "is tied to the subscription of the person who ran claude setup-token." For a secret shared across repositories, they recommend an API key instead.

CLAUDE_CODE_OAUTH_TOKEN vs ANTHROPIC_API_KEY: which one wins
When several credentials are present, Claude Code picks one in a fixed order. Here's the full list from Anthropic's docs:
| Rank | Credential | What it's for |
|---|---|---|
| 1 | Cloud provider (CLAUDE_CODE_USE_BEDROCK, _VERTEX, _FOUNDRY) | Bedrock, Vertex or Foundry billing |
| 2 | ANTHROPIC_AUTH_TOKEN | Bearer token for an LLM gateway or proxy |
| 3 | ANTHROPIC_API_KEY | A Console API key |
| 4 | apiKeyHelper output | Rotating credentials from a vault |
| 5 | CLAUDE_CODE_OAUTH_TOKEN | Your setup-token |
| 6 | Anthropic profile or federation credentials | The ant CLI and Workload Identity Federation |
| 7 | /login | Your normal subscription sign-in |
Two lines from the docs explain most "why isn't my token being used?" questions. First: "In non-interactive mode (-p), the key is always used when present." Second: if you have a subscription but ANTHROPIC_API_KEY is also set, "Claude Code uses the API key once you approve it."
So if Claude Code seems to ignore your setup-token, an API key, auth token or apiKeyHelper is probably outranking it. Run unset ANTHROPIC_API_KEY and check /status.
| Setup-token | Console API key | |
|---|---|---|
| What it is | An OAuth token for your subscription | A pay-as-you-go key |
| Where you get it | claude setup-token | Claude Console |
| What it bills | Your plan limits | Per token, to the key owner |
| Lifetime | One year | Until you delete it |
| Precedence rank | 5 | 3 |
| Meant for | Your own CI, scripts, headless boxes | Anything, including tools you build |
| Third-party tools? | No | Yes, billed to the key owner |
One more trap: don't feed the setup-token through apiKeyHelper. Issue #97350 reports that every request then fails with 401 authentication_error: API key is invalid, while the same token works fine as CLAUDE_CODE_OAUTH_TOKEN.
If you're on Max or Ultra, the API-key column costs less than it looks: your monthly API credit can pay for it. Our guide to funding an agent's API key from your Max or Ultra credit shows how.

Expiry, renewal and revocation
The token lasts one year. Nothing warns you before it expires: one tool's issue tracker (igor #145) puts it plainly, "A seat's setup-token expires after a year and nothing warns before it does." Put a calendar reminder in when you create it.
Don't confuse this with your normal login. Interactive claude.ai logins have their own end dates, which claude auth status --text shows on a line starting Sign-in ends:.
Yes, you can revoke it
Some guides say a setup-token can't be revoked. That's wrong. Anthropic's help article on logging out of all active sessions lists "Claude Code, including tokens created with setup-token for continuous integration (CI)."
You have three routes:
- claude.ai Settings > Account > Log out of all sessions. This signs out everything, including setup-tokens.
- Settings > Claude Code, where Anthropic says you can "manage your authorization tokens" and "click the trash can icon" to remove one.
- Settings > Account > Active sessions, then the three-dot menu and "Terminate".
Here's what nobody tells you: deleting a GitHub secret does not revoke the token. Anthropic's GitHub Actions doc says so directly: "If you delete a secret, the credential it held stays valid."
The honest gap
Revoking is possible. Knowing which token you're revoking is harder.
Claude Code issue #99702 (open) says the Settings list "shows no identifying fragment of the token itself, not even the last 4 characters." Issue #106670 (open) asks whether minting a new token kills the old one, and has no answer yet.
So if a token leaks, log out of all sessions. That revokes every login on every machine. Then mint a fresh token.

Third-party tools: why it's blocked, and what to use instead
This is the part most people are actually searching for.
Anthropic's Claude Code legal page is specific. OAuth is "intended exclusively for purchasers of Claude … subscription plans and is designed to support ordinary use of Claude Code and other native Anthropic applications."
Developers "should use API key authentication." And they "may not collect, store, or intermediate Claude.ai credentials or session tokens," and that "sign-in to a Claude account must complete through Anthropic's own flow."
Handing your setup-token to OpenClaw, Hermes or any other agent tool puts that tool in the middle of your credentials. That's the case the sentence describes.
The help centre adds the billing side. Anthropic "reserves the right to draw use of such third-party tools from usage credits rather than subscription limits," and tools that "misrepresent their identity to Anthropic's servers" are prohibited.
What happens in practice
The evidence lines up with the policy:
- 9 January 2026: Anthropic blocked third-party use of Claude Code subscriptions (a 625-point Hacker News thread).
- 3 September 2026: OpenClaw issue #136991 shows a setup-token handed to OpenClaw returning "API Error: 400 Third-party apps now draw from your extra usage, not your plan limits." Our guide to the "Third-party apps now draw from your extra usage" error covers every variant.
- Today: Hermes' docs still show a "fallback / legacy"
ANTHROPIC_TOKENoverride that accepts a setup-token. We don't recommend it.
There's a newer wrinkle. Nous' DirectSDK plugin 0.5.0 (28 November) can take a setup-token as one of several pooled logins, which it passes to the unmodified Claude Code binary. Anthropic hasn't said how that sits against its "intermediate" line, so we'd stick to the options below.
The alternatives
A Console API key
Set it as ANTHROPIC_API_KEY in your agent. On Max or Ultra, it can be funded by your monthly API credit ($100 or $200). The credit guide linked in the precedence section shows how to claim it.
For Hermes, sign in to Claude Code yourself
The DirectSDK plugin drives your own signed-in Claude Code binary, which is the case the legal page says isn't prevented. It works today, metered as Agent SDK usage, and may be billed to usage credits. The Hermes status guide linked near the top explains which route sits on which side of the rule.
Run the job in Claude Code itself
If it's a one-off, the CLI on your own login is the simplest answer.
For OpenClaw specifically, the setup-token route and its history are in the OpenClaw timeline linked at the top.
We built BetterClaw so nobody has to paste a Claude.ai token anywhere. Agents run on your own API key from any of 28+ providers at zero markup, or on your ChatGPT Plus or Pro sign-in.

Errors, with the documented text
All of these come from Anthropic's Claude Code errors page unless noted.
Revoked token (interactive)
OAuth token revoked · Please run /login
Anthropic: "A revoked token means you signed out everywhere or an admin removed access."
Expired token (interactive)
Please run /login · API Error: 401 OAuth token has expired ...
The docs add that if you authenticate with CLAUDE_CODE_OAUTH_TOKEN, "you see the same messages when that token expires or is revoked."
In -p mode and the Agent SDK
The error code is authentication_failed:
Failed to authenticate: OAuth token revoked. Please log in again or contact your administrator.
Failed to authenticate. API Error: 401 OAuth token has expired ...
The fix: Claude Code keeps sending the value you set after a 401, so "Generate a fresh token with claude setup-token and restart with it, or unset the variable and run /login."
Account or organisation problem, not expiry
API Error: 401 Invalid authentication credentials
Anthropic says this appears when a credential was recently revoked, an organisation removed your access, or the account was deactivated, "so an expired token isn't the cause."
Old scopes
OAuth token does not meet scope requirement: user:profile
Run /login to get a token with current scopes.
Through apiKeyHelper
401 authentication_error: API key is invalid (issue #97350). Use the environment variable instead.
In a third-party tool
API Error: 400 Third-party apps now draw from your extra usage, not your plan limits. This is what OpenClaw users saw. The error guide linked in the section above covers every variant and the fixes.
The token is fine. The destination is the problem.
Here's the honest takeaway.
claude setup-token is a genuinely useful tool. It lets your own scripts and pipelines use the plan you already pay for, with no browser in sight. The trouble only starts when it leaves your hands.
The rule of thumb is simple. If the thing running Claude is yours, the token fits. If it's someone else's app, give that app an API key.
If you want an agent without any of this, start free with BetterClaw. The free plan includes 1 agent and 100 credits a month with no card, and Starter is $19 a month for 2,000 credits (see full pricing).
Build it visually in our no-code AI agent builder on your own key at zero markup. We handle the infrastructure. You handle the interesting part.
Frequently Asked Questions
What is claude setup-token?
It's a Claude Code command that prints a one-year OAuth token tied to your Claude subscription. Anthropic documents it "for CI pipelines, scripts, or other environments where interactive browser login isn't available." You set it as CLAUDE_CODE_OAUTH_TOKEN, and Claude Code bills your plan limits.
What's the difference between CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_API_KEY?
The OAuth token uses your subscription's plan limits; the API key bills per token to the Console account that owns it. If both are set, the API key wins, and in -p mode "the key is always used when present." Only the API key is meant for third-party tools.
How do I revoke a Claude setup token?
Log out of all sessions in claude.ai Settings > Account, which Anthropic says covers "tokens created with setup-token," or remove it with the trash-can icon in Settings > Claude Code. The list doesn't show which token is which, so after a leak, logging out everywhere is safest. Deleting a GitHub secret does not revoke it.
How long does a Claude setup token last, and does it cost extra?
It lasts one year, with no warning before it expires. It doesn't cost extra: it draws on your existing plan limits, and it can't spend your Max or Ultra monthly API credit.
Can I use a Claude setup token with OpenClaw or Hermes?
Anthropic's terms say developers "may not collect, store, or intermediate Claude.ai credentials or session tokens," and OpenClaw users who tried it got a 400 asking them to buy extra usage. Use a Console API key in those tools instead, or, for Hermes, sign in to Claude Code yourself through the DirectSDK plugin.




