HTTP 401 Unauthorized vs 402 Payment Required
Both HTTP 401 (Unauthorized) and 402 (Payment Required) belong to the 4xx Client Error category. 401 indicates that the request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme. Meanwhile, 402 means that reserved for future use. Originally intended for digital payment systems, some APIs use it to indicate a billing or subscription issue.
Description
The request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme.
When You See It
When accessing a protected resource without credentials or with expired tokens.
How to Fix
Include valid authentication credentials (API key, Bearer token, Basic auth) in the Authorization header.
Description
Reserved for future use. Originally intended for digital payment systems, some APIs use it to indicate a billing or subscription issue.
When You See It
On some APIs when a subscription has expired or payment is needed.
How to Fix
Check your billing status, update payment method, or upgrade your subscription.
Key Differences
HTTP 401: The request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme.
HTTP 402: Reserved for future use. Originally intended for digital payment systems, some APIs use it to indicate a billing or subscription issue.
You encounter 401 when when accessing a protected resource without credentials or with expired tokens.
You encounter 402 when on some APIs when a subscription has expired or payment is needed.
When to Use Which
For 401 (Unauthorized): Include valid authentication credentials (API key, Bearer token, Basic auth) in the Authorization header. For 402 (Payment Required): Check your billing status, update payment method, or upgrade your subscription.