Skip to main content

Authentication errors

A 401 response carries one of the authentication-specific codes:

codeMeaning
missing_api_keyThe Authorization header was not present on the request.
invalid_api_keyThe key was malformed, expired, revoked, or of the wrong type (for example, a pat_… token sent to /v1/*).
api_key_env_mismatchThe key's prefix (sk_test_ / sk_live_) disagrees with the environment the key was issued for. See Wrong-environment keys below.
unauthorizedA generic authentication failure that does not map to one of the codes above.

A 403 response is an authorization failure, not authentication:

codeMeaning
ip_not_allowedThe caller's IP is not on the account's IP allowlist.
missing_scopeThe key does not carry the scope required for this operation.
forbiddenA generic authorization failure.
allowlist_check_failedA configured allowlist rejected the request (e.g. recipient domain).

Wrong-environment keys

The api_key_env_mismatch error fires when the prefix of the API key you sent (sk_test_ or sk_live_) does not match the environment that key was originally issued for. Common causes:

  • Copying a sandbox key (sk_test_…) into a production environment variable.
  • Copying a production key (sk_live_…) into a staging or test environment.
  • A deployment pipeline that promotes secrets across environments without updating them.

Suggested action: rotate to a key that belongs to the correct environment. You can generate new keys in the Permissio dashboard under Settings → API keys. Make sure each environment (sandbox, production) uses a key with the matching prefix.