The HTTP 401 status code means the server did not apply a request because the request lacks valid authentication credentials for the resource it asked for, according to RFC 9110, Section 15.5.2, the IETF document titled HTTP Semantics. In the words of the standard, "The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource."
When a server sends a 401
Section 11.4 of RFC 9110 says an origin server should send a 401 when a request for a protected resource omits credentials, contains invalid credentials such as a bad password, or contains only partial credentials, as happens when an authentication scheme needs more than one round trip. A 401 belongs to the 4xx class, which RFC 9110, Section 15.5 describes as the class of status codes indicating that the client seems to have erred.
What a 401 response must include
A server that generates a 401 response must send a WWW-Authenticate header field containing at least one challenge that applies to the target resource, under RFC 9110, Section 15.5.2. Section 11.3 explains that an origin server uses a 401 response to challenge the authorization of a user agent. A user agent then authenticates by sending an Authorization header field with its credentials, as described in Section 11.6.2.