Claude API 401 Invalid x-api-key

Share
Workaround available API Updated November 14, 2026Based on 3 user reportsHow we research

Quick answer

A 401 authentication_error means the key is missing, mistyped or revoked. Check the key in the Console and how your app sends it.

Most likely fix: Verify the key

How to fix it

Try these in order — the most common fix is first.

  1. 1. Verify the key

    1. Open the Console API keys page and confirm the key is active
    2. Create a new key if unsure
    Did this fix it?
  2. 2. Check how it is sent

    1. Send it in the x-api-key header
    2. Check for stray quotes or newlines in env variables
    Did this fix it?
  3. 3. Look for stale values

    1. Search shell config and project .env files for an old ANTHROPIC_API_KEY
    Did this fix it?

Symptoms

HTTP 401 authentication_error, 'invalid x-api-key'.

Why it happens

  • Typo or whitespace in key
  • Key revoked or deleted
  • Wrong env variable or stale key in .env

This guide also covers

  • claude api 401
  • invalid x-api-key

Still not working?

If Anthropic Claude keeps failing, you're not alone. See every Anthropic Claude problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

Other Anthropic Claude errors

All 11 Anthropic Claude errors and fixes →