Getting HTTP 402 back and your agent can't complete the payment? Debugging x402
x402 is what lets an autonomous agent pay for an API without a human, a card, or an account — the server answers with HTTP 402 Payment Required, the agent pays from its wallet, and retries. When it works it's seamless. When an agent gets stuck, it's almost always at one of three predictable points.
How the flow is supposed to go
- Your agent POSTs the request with no payment. The server returns HTTP 402 with an
acceptsarray — one entry per supported chain, each withnetwork,payTo, the USDCasset(contract/mint), and on EVM the EIP-712 domain — plus afacilitatorURL. - Your agent picks a chain it can pay on, and signs the payment for that chain.
- It retries the same request with the signed payment attached in the
PAYMENT-SIGNATUREheader (X-PAYMENTis also accepted), and gets200plus the result and a receipt.
Where agents get stuck
The golden rule: read the live 402's accepts and facilitator every time, pick a chain you can pay on, sign the scheme that chain requires, and attach the signed payment on the retry. An empty or unreadable request is never charged, so you can probe safely.
Solana and EVM, side by side
- EVM (Base and other EVM networks): sign an EIP-3009
transferWithAuthorizationfor the USDC contract named inaccepts, base64 it, retry with it attached. - Solana: build the partial transaction with the facilitator as fee payer (only USDC needed from you), sign, retry with it attached.
One wallet app can hold both chains, but they're different addresses — your agent pays on whichever chain it actually holds USDC.
Debugging it
If your agent keeps bouncing off the 402, the fastest check is whether it's parsing the accepts array and attaching the signature on retry. Snapback's own x402 endpoint follows this exact flow — see the docs for the live request/response shapes, and the x402 deep-dive for the end-to-end walkthrough.
Machine-readable guide: https://snapback.sh/llms.txt · Tool discovery: https://snapback.sh/.well-known/mcp.json · MCP endpoint: https://api.snapback.sh/mcp. Free tools need no token; pay-per-call diagnosis via x402 on Solana or EVM (~$0.0032 USDC).