Problem
The current x402 spec defines what a 402 response looks like when payment is required. It does not define any mechanism for communicating why payment is failing when a client repeatedly attempts and fails to pay.
Every 402 response looks identical regardless of whether it is:
A first request from a new client legitimately discovering payment requirements
A payment attempt where the invoice expired before settlement
A payment attempt where the wallet has insufficient funds
A broken agent that has made 8,000 requests over 18 days with zero successful payments
From the server's perspective these are completely different situations. From the protocol's perspective they are indistinguishable.
Real-world case
I run a production x402 oracle at myceliasignal.com — cryptographically signed price data, pay-per-query via USDC on Base. A client has been making 8,000+ daily requests for 18 days. It previously paid successfully. Something in its payment stack broke. It has received 144,000+ identical 402 responses. The operator has no idea. I have no way to tell them.
This is not an edge case. As agentic payment volume grows, broken payment logic will become a regular occurrence. The protocol currently has no vocabulary for it.
Full write-up with the proposed diagnostic codes: https://myceliasignal.com/blog/agentic-payment-error-standard/
Proposal
Add an optional diagnostic field to the 402 response body:
json{
"error": "Payment required",
"accepts": ["x402"],
"x402": { ... },
"diagnostic": {
"code": "PAYMENT_ATTEMPTS_EXCEEDED",
"attempts": 8432,
"since": "2026-03-10T00:00:00Z",
"message": "8,432 requests received with no valid payment in 18 days.",
"suggestion": "Check payment handler configuration. See https://docs.x402.org/troubleshooting",
"escalate": true
}
}
Proposed diagnostic codes:
CodeMeaningPAYMENT_REQUIREDStandard first-request 402, no prior attemptsINVOICE_EXPIREDPayment attempted but invoice expired before settlementPAYMENT_UNVERIFIEDPayment header present but signature invalidPAYMENT_ATTEMPTS_EXCEEDEDMany attempts with no successful paymentWALLET_INSUFFICIENT_FUNDSOn-chain balance too low to cover paymentOPERATOR_ALERTEscalate to human — autonomous resolution unlikely
The escalate: true flag signals that the agent should stop retrying and surface the issue to a human operator — log it, send an alert, open a ticket.
Out-of-band operator contact (stretch goal).
Even with diagnostics in the response, a broken agent may not read them. A complementary mechanism would allow API providers to reach the human operator directly — for example a standard X-Operator-Contact header that agents include with requests, enabling the server to notify the operator when their agent is consistently failing.
Implementation notes
Fully backward compatible — diagnostic is optional, existing clients ignore it
Server-side implementation is straightforward — track attempt counts per IP/credential, emit diagnostic codes after thresholds
Client SDKs should be updated to parse diagnostic.code and implement escalation logic for OPERATOR_ALERT
Happy to draft a spec PR if there's interest from maintainers.
/cc @coinbase/x402
Problem
The current x402 spec defines what a 402 response looks like when payment is required. It does not define any mechanism for communicating why payment is failing when a client repeatedly attempts and fails to pay.
Every 402 response looks identical regardless of whether it is:
A first request from a new client legitimately discovering payment requirements
A payment attempt where the invoice expired before settlement
A payment attempt where the wallet has insufficient funds
A broken agent that has made 8,000 requests over 18 days with zero successful payments
From the server's perspective these are completely different situations. From the protocol's perspective they are indistinguishable.
Real-world case
I run a production x402 oracle at myceliasignal.com — cryptographically signed price data, pay-per-query via USDC on Base. A client has been making 8,000+ daily requests for 18 days. It previously paid successfully. Something in its payment stack broke. It has received 144,000+ identical 402 responses. The operator has no idea. I have no way to tell them.
This is not an edge case. As agentic payment volume grows, broken payment logic will become a regular occurrence. The protocol currently has no vocabulary for it.
Full write-up with the proposed diagnostic codes: https://myceliasignal.com/blog/agentic-payment-error-standard/
Proposal
Add an optional diagnostic field to the 402 response body:
json{
"error": "Payment required",
"accepts": ["x402"],
"x402": { ... },
"diagnostic": {
"code": "PAYMENT_ATTEMPTS_EXCEEDED",
"attempts": 8432,
"since": "2026-03-10T00:00:00Z",
"message": "8,432 requests received with no valid payment in 18 days.",
"suggestion": "Check payment handler configuration. See https://docs.x402.org/troubleshooting",
"escalate": true
}
}
Proposed diagnostic codes:
CodeMeaningPAYMENT_REQUIREDStandard first-request 402, no prior attemptsINVOICE_EXPIREDPayment attempted but invoice expired before settlementPAYMENT_UNVERIFIEDPayment header present but signature invalidPAYMENT_ATTEMPTS_EXCEEDEDMany attempts with no successful paymentWALLET_INSUFFICIENT_FUNDSOn-chain balance too low to cover paymentOPERATOR_ALERTEscalate to human — autonomous resolution unlikely
The escalate: true flag signals that the agent should stop retrying and surface the issue to a human operator — log it, send an alert, open a ticket.
Out-of-band operator contact (stretch goal).
Even with diagnostics in the response, a broken agent may not read them. A complementary mechanism would allow API providers to reach the human operator directly — for example a standard X-Operator-Contact header that agents include with requests, enabling the server to notify the operator when their agent is consistently failing.
Implementation notes
Fully backward compatible — diagnostic is optional, existing clients ignore it
Server-side implementation is straightforward — track attempt counts per IP/credential, emit diagnostic codes after thresholds
Client SDKs should be updated to parse diagnostic.code and implement escalation logic for OPERATOR_ALERT
Happy to draft a spec PR if there's interest from maintainers.
/cc @coinbase/x402