401 Unauthorized

The request lacks valid authentication credentials for the target resource.

Status

HTTP/1.1 401 Unauthorized

Details

Despite the name, 401 means unauthenticated. The server does not know who you are, or the credentials you sent were rejected. Every 401 must include a WWW-Authenticate header naming at least one authentication scheme the client can use, which is what lets a browser show a login prompt or a client pick the right token type.

The distinction from 403 is worth holding on to: 401 means try again with credentials, 403 means credentials will not help. Retrying a 401 with the same token is pointless.

Headers

Common causes

How to fix it

As the client

As the server

Examples

GET /api/v2/order HTTP/1.1
Host: api.example.com
Authorization: Bearer expired_token

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api", error="invalid_token"
Content-Type: application/json; charset=utf-8

{"error":"invalid_token","detail":"Token expired at 2026-08-01T00:00:00Z"}

Notes for proxy users

401 comes from the destination site, not from the proxy. The proxy equivalent is 407 Proxy Authentication Required. If you are debugging credentials and see both, fix the 407 first: the request never reached the site.

Specifications

RFC 9110 §15.5.2

See also