Fix 401 Unauthorized: API Key is required or Invalid API key

Why the Shakewell Wallet API returns 401 Unauthorized, the difference between a missing and an invalid API key, and how to fix both in minutes.

Last updated 2026-11-05

Every public API route needs an API key. A 401 means the key was not found, or it was found and rejected.

HTTP 401
{ "error": "Unauthorized", "message": "API Key is required." }
HTTP 401
{ "error": "Unauthorized", "message": "Invalid API key." }

Causes

  • API Key is required.: no Authorization: Bearer or X-API-Key header reached the server. Proxies, redirects and HTTP clients that drop headers on redirect are common culprits.
  • Invalid API key.: the key was mistyped, truncated, revoked, deactivated or has expired. The key is hashed on arrival, so a stray space or newline makes it invalid.
  • The key belongs to a different environment or account than you think.

Fix

  1. Print the exact header your code sends and check it starts with Bearer sk_.
  2. Trim whitespace and newlines from the key when you load it from an environment variable.
  3. Open Settings, Account settings, API keys and confirm the key is active. If in doubt, create a new key and replace it.