Omniscio

OmniscioGuidesInvalid auth token

Claude Code: invalid auth token or invalid request header

Last checked against Anthropic's documentation on November 23, 2026. By the Omniscio team. Updated .

What is the exact message?

The first part names where the bad value came from. Anthropic lists three forms:

Invalid auth token · Fix external auth token
Invalid ANTHROPIC_CUSTOM_HEADERS · Fix the environment variable
Invalid request header from the environment · Fix the environment variable

Each form can carry on after a second · with a description and the position of the character that cannot be sent:

Invalid auth token · Fix external auth token · Invalid Authorization header value from ANTHROPIC_AUTH_TOKEN: it contains a line break at character 41 (120 characters on 2 lines).

The counts are for your own value; yours will differ. Match on the wording, not the numbers.

What does it mean?

A value Claude Code was about to send as a request header contains a character that HTTP headers cannot carry: a line break, a NUL byte, or a character above U+00FF, meaning outside the range HTTP headers were defined for, such as a curly quote or a zero-width space.

Claude Code stops the request before anything is sent, so the API never saw the credential. Anthropic's usual cause is a credential pasted from a document or chat that carried an invisible character or a stray line break.

The first part of the message tells you where to look:

  • Invalid auth token: a bearer token from ANTHROPIC_AUTH_TOKEN or CLAUDE_CODE_OAUTH_TOKEN.
  • Invalid ANTHROPIC_CUSTOM_HEADERS: a header name or value you set in ANTHROPIC_CUSTOM_HEADERS. The description counts which Name: Value pair is at fault, such as distinct header 2 of 3 parsed from ANTHROPIC_CUSTOM_HEADERS, without repeating the name or value, since you chose both.
  • Invalid request header from the environment: a value Claude Code copies into a request header from another environment variable, such as CLAUDE_AGENT_SDK_CLIENT_APP. The description names the variable to fix.

Where the check runs matters. Claude Code runs it when it sends requests to the Claude API directly or through an LLM gateway. On a third-party cloud provider such as Amazon Bedrock, Claude Code does not run it before sending.

A bad ANTHROPIC_API_KEY caught by the same check is reported as Invalid API key, with the same trailing description. A bad saved /login credential is reported as Not logged in instead. An apiKeyHelper script's output never reaches this check: Claude Code validates it when the script runs.

Positions count characters starting at one. The description is built from fixed phrases and character counts, so it never includes the value itself. It names the offending character only when it is a well-known invisible or typographic character, such as a byte-order mark, a zero-width space, or a curly quote, and reports anything else as a non-ASCII character.

How do I fix it?

  1. Find where the value is set. The message names the variable or the setting, so that is the one to change. Claude Code reads these variables from your shell, your user settings, or managed settings, and the list is on Claude Code environment variables.
  2. Set it again from a clean source. Anthropic's step is to re-set the named variable or setting, retyping the characters around the reported position rather than pasting from the same source again. For a long token, copy it again from where it was issued, or paste it into a plain-text editor first, which shows a stray line break or an invisible character before it reaches Claude Code.
  3. For ANTHROPIC_CUSTOM_HEADERS, keep one Name: Value pair per line and rewrite the pair the message counts.
  4. Run /status to confirm which credential source is active.

The parenthetical tells you the shape of the problem: 120 characters on 2 lines in the example above means the value itself spans two lines. Setting it as one unbroken line is the fix for that form.

How do I know it is fixed?

  • The message no longer appears when you send a message, because the request now leaves with a valid header.
  • The request reaches the gateway or API you configured instead of stopping before it is sent.
  • If you changed a custom header, the gateway receives the header you meant it to.

Where these answers come from

Common questions

What does Invalid auth token mean in Claude Code?

A bearer token from ANTHROPIC_AUTH_TOKEN or CLAUDE_CODE_OAUTH_TOKEN contains a character an HTTP header cannot carry, so Claude Code stops the request before it is sent and names the variable to fix.

Which characters are refused?

A line break, a NUL byte, or a character above U+00FF such as a curly quote or a zero-width space. Anthropic's own explanation for how one gets in is a credential pasted from a document or chat.

Is Invalid auth token the same as Invalid API key?

No, but they come from the same check. A bad ANTHROPIC_API_KEY caught by it is reported as Invalid API key, with the same trailing description, while a bad saved /login credential is reported as Not logged in instead.

Does this check run on Bedrock?

No. Claude Code runs the check when it sends requests to the Claude API directly or through an LLM gateway, not before sending to a third-party cloud provider such as Amazon Bedrock.