Skip to main content
apiguide.dev

HTTP 401 — Unauthorized

The request lacks valid authentication credentials. The client must authenticate.

Status CodeHTTP 401
CategoryClient Error (4xx)
API Error Subtypes2 error schemas
HTTP Headers2 headers

What does HTTP status code 401 mean?

The 401 Unauthorized status code indicates that the client must authenticate itself to receive the requested response.

When to use it in APIs

Use 401 when the client fails to provide an API key, bearer token, or session credentials, or when the credentials provided are invalid or expired. A 401 response must include a WWW-Authenticate header naming the authentication scheme the client should use (e.g. WWW-Authenticate: Bearer realm="api").

How it compares to other codes

  • 403 Forbidden: Use 403 when the client is authenticated but does not possess the permissions/scopes to access the resource.

Specific API Error Types for 401

Associated HTTP Headers

Related HTTP Status Codes