Claude Code · Sign-in
API Error: 401 Invalid authentication credentials
The API recognised your credential’s format but rejected the account or organisation behind it.
Message
The exact error
Please run /login · API Error: 401 Invalid authentication credentialsMeaning
What it means
This isn’t an expired token. Anthropic returns it when a credential was recently revoked, when your organisation was disabled or removed you, or when the account was deactivated. The credential may be your saved login or an ANTHROPIC_API_KEY, and the fix depends on which, so start by checking.
Causes
Common causes
- A revoked API key or login
- Your organisation disabled or removed your access
- A deactivated account
- A gateway set in
ANTHROPIC_BASE_URLrejecting its own credential
Fix
How to fix it
See which credential is active
Run
/status. An approvedANTHROPIC_API_KEYtakes priority over your login, so/loginwon’t replace it.If it’s an API key
Rotate the key in the Console, or fall back to your subscription by removing it.
macOS / Linux unset ANTHROPIC_API_KEYWindows PowerShell Remove-Item Env:ANTHROPIC_API_KEYIf it’s your login
Run
/loginonce. If the same error returns for the same account, ask your organisation’s admin to restore access.If you use a gateway
With
ANTHROPIC_BASE_URLset, the text after 401 is your gateway’s, and/loginwon’t change it; fix the credential the gateway expects.
Related