HTTP 401 — Unauthorized

Authentication is required and has failed or has not been provided

When to use it

Use status 401 when this is the correct HTTP response semantic: Authentication is required and has failed or has not been provided

Request and response example

GET /account HTTP/1.1
Host: api.example.com

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer

Related status codes

400, 402, 403, 404

References

MDN · RFC 9110