HTTP 402 payment required
The status code that signals payment is required
MPP services return HTTP 402 Payment Required to indicate that a resource requires payment for access.
Overview
Respond with 402 when:
- A resource requires payment as a precondition for access
- The server can provide a
Paymentchallenge the client can fulfill - Payment is the primary barrier (not authentication or authorization, which would result in a
401and then potentially an incremental402)
HTTP/1.1 402 Payment Required
WWW-Authenticate: Payment id="abc123",
realm="mpp.dev",
method="tempo",
intent="charge",
request="eyJ..."Status code comparison
| Condition | Status Code |
|---|---|
| Resource requires payment | 402 |
| Client lacks authentication | 401 |
| Client authenticated but unauthorized | 403 |
| Resource doesn't exist | 404 |
MPP uses 402 consistently for all payment-related challenges, including when a credential fails validation. This differs from other HTTP authentication schemes that use 401 for failed credentials.
Token authentication
When a resource requires both token and payment authentication:
- Verify authentication credentials
- Return
401if token authentication fails - Return
402with aPaymentchallenge only after successful token authentication
This ordering prevents leaking payment requirements to unauthenticated clients.
Error responses
Failed payment attempts return 402 with a fresh challenge and a Problem Details body:
HTTP/1.1 402 Payment Required
Cache-Control: no-store
Content-Type: application/problem+json
WWW-Authenticate: Payment id="new456", ...
{
"type": "https://paymentauth.org/problems/verification-failed",
"title": "Payment Verification Failed",
"status": 402,
"detail": "Invalid payment proof."
}Error types include:
invalid-challenge—Unknown, expired, or already-used challengemalformed-credential—Invalid base64url or bad JSONmethod-unsupported—Method not accepted (400)payment-expired—Challenge or authorization expiredpayment-insufficient—Amount too lowpayment-required—Resource requires paymentverification-failed—Payment proof invalid