← Blog
November 17, 2026 · 15 min

x402's 402 doesn't say which version it speaks, or why

An x402 402 response carries no version signal and no machine-readable reason. Two issues filed on 2026-11-13 say so. We probed 4,328 x402 hosts, got 3,923 challenges back, and ran four SDK clients against eight mock responses to see what that costs an agent that pays.

Issue #4251 says a client cannot tell the two protocol generations apart on the wire before it commits to a parser. Issue #4252 says the 402 challenge is the only x402 response whose reason is free text. Both come from bshelby88, who writes as the operator of a 14-service fleet on Base. #4252 has nine comments, one of them linking a runnable fixture repository. #4251 has none.

We measured both claims on 2026-11-17. The census took the two public Bazaar catalogs, picked one resource per host, and sent three requests per host. The first had no payment header. The second had a v2 payment header containing an empty JSON object. The third sent the same object under the v1 header name. None of them carried a signature, so nothing could settle.

The client harness ran the buyers people actually install: @x402/fetch 2.31.0, the Python x402 2.28.0 httpx client, the Go client at tag go/v2.31.0, and the unscoped x402-fetch 1.2.0.

Two generations, two places to look

In v1, the challenge is a JSON object in the response body. The client pays with an X-PAYMENT header, prices are in maxAmountRequired, and networks have names like base. That is the v1 HTTP transport.

In v2, the challenge is a base64 PaymentRequired object in the PAYMENT-REQUIRED header. The client pays with PAYMENT-SIGNATURE, prices are in amount, and networks are CAIP-2 identifiers such as eip155:8453. The v2 HTTP transport ships {} as the example body. It also says that response bodies "are a server implementation concern."

The reason field is weak in both versions. The v2 spec, §5.1.2, defines PaymentRequired.error as an optional "human-readable error message." Section 9 lists machine-readable codes and says clients MUST match on invalidReason or errorReason, never on message text. Those two fields live in VerifyResponse and SettlementResponse, and a buyer sees them only if the seller forwards a PAYMENT-RESPONSE. The transport's error table adds one more rule: a malformed payment gets 400, a failed one gets 402.

The three reference clients parse a 402 with one shared rule. If the PAYMENT-REQUIRED header is present, they decode it. If it is not, they accept the body only when x402Version is the number 1. The rule is in x402HTTPClient.ts, in Python's get_payment_required_response, and in Go's GetPaymentRequiredResponse.

Go's HTTP transport has one more branch. detectPaymentRequiredVersion also accepts a body whose x402Version is 2, and decodeV2PaymentRequired then parses it. So when a v2 offer sits only in the body, Go reads it as valid v2 and TypeScript and Python reject it.

What 3,923 live challenges look like

Coinbase's CDP catalog listed 33,257 resources on 3,228 hosts at 09:10 UTC; 180 of them were tagged v1. PayAI's catalog listed 15,907 resources on 1,582 hosts; 1,584 were tagged v1. We skipped template URLs, kept the most-called resource per host, and probed 4,328 hosts with 12,174 requests. 3,923 hosts answered 402.

Where the unpaid 402 puts its offerHosts
v2 header, no versioned object in the body1,621
v2 header, plus a v2 copy in the body1,721
v2 header, plus a v1 offer in the body439
v1 body only99
v1 object in both header and body3
v2 object in the body, no header2
No parseable x402 offer at all38

The header has won. 3,784 hosts send a decodable PAYMENT-REQUIRED. But 2,173 of them also put an accepts list in the body, so more than half the market maintains two copies of the same offer.

For the 1,621 hosts without a versioned body, the body says little. 859 send {}, 198 send only an error string, 46 send nothing, 485 send application JSON of their own, ten send an accepts list with no version, and three send plain text. Twenty send an object with x402Version and no offer. That is the self-identifying shape #4251 proposes, and these hosts already ship it.

Some 402s speak a second protocol in the same response. 418 carry a WWW-Authenticate header. 346 of those use the Payment scheme of MPP, and 345 send it next to a PAYMENT-REQUIRED header. In the first 120 bytes we kept, the challenge named method tempo on 148 hosts, evm on 142 and stripe on 31. Others made up their own schemes: x402 on 54 hosts, X402 on 9, and an MPP scheme wrapping a base64 x402 object on 2.

The catalogs do not reliably say which version a host speaks, either. Twenty-three hosts whose catalog entry is tagged v1 answered with a v2 header.

Four clients, eight responses

The harness is a local server that answers 402 in seven x402 shapes, plus one plain 402 that is not x402 at all. On a paid retry it reports which header arrived and what value was signed. The buyer uses a fresh random key, and no chain is involved.

402 response@x402/fetch 2.31.0Python 2.28.0Go v2.31.0x402-fetch 1.2.0
v2 header, body {}pays v2pays v2pays v2TypeError
v2 header, body {"error"}pays v2pays v2pays v2TypeError
v1 bodypays v1pays v1pays v1pays v1
v2 header + v1 body, same pricepays v2pays v2pays v2pays v1
v2 header asks 10000, v1 body asks 20000signs 10000signs 10000signs 10000signs 20000
v2 offer in body, no headerparse errorparse errorpays v2Zod error
v1 body, x402Version: "1"parse errorparse errorversion errorpays v1
plain 402, not x402parse errorparse errorversion errorTypeError

The fifth row is the one that matters. All three v2 clients take the header and never look at the body, while the v1 client takes the body and never looks at the header. So the same endpoint gets two different signed amounts depending on which generation of buyer calls it. No client compares the two copies.

The live market does not show that conflict yet. We re-probed the 2,173 hosts whose 402 carries both a header and an accepts list in the body, and normalized v1 network names to CAIP-2. No host asked a different price, or named a different payTo, for the same network and asset in its two copies.

The two copies still drift. On 201 of the 439 hosts with a v1 body, the body lists fewer payment options than the header, so v1 buyers see a smaller menu. On 20 hosts the drift runs the other way, and the body carries an entry the header does not have. On 14 of them the body adds Nano (XNO) next to the Base USDC option that the header carries alone. Three more bodies add an option the header leaves out: a Polygon token, Solana next to the header's four EVM chains, and a token on a chain of its own. SDK buyers read only the header, so they never see those options. Two v1 bodies rename a network the header names in CAIP-2, using strings no v1 SDK knows: robinhood and solana-mainnet. One host writes the same amount as 5000 in the header and 0005000 in the body. One header misspells the Solana mainnet genesis hash, and the body on the same host spells it correctly.

MCP already met this problem. There, a payment object travels twice, in structuredContent and in the text content. PR #3631 for Go and PR #3643 for Python make the client refuse to auto-pay when the two disagree. Both are open since late September. The HTTP clients have no equivalent check.

The failure messages blur different causes together. The TypeScript client turns three different problems into one string: a v2 offer that only appears in the body, a version sent as the string "1", and a 402 from a different protocol. The string is Failed to parse payment requirements: Invalid payment required response. Python gives one message for all three as well. Go reports could not detect x402 version from response for two of them and pays the third.

The v1 client fails differently. x402-fetch 1.2.0 reads accepts from the JSON body without checking the version. Against a header-only v2 402 it throws TypeError: Cannot read properties of undefined (reading 'map'), the failure #4251 reports. Against a v2 offer in the body, it throws a Zod invalid_enum_value that lists the 17 v1 network names it knows. At most 537 of the 3,923 live 402s are parseable by it: those with a v1 body whose networks all fall inside that list.

That client still has real install volume. In the npm week of 2026-11-09 to 11-15, x402-fetch had 12,035 downloads and @x402/fetch 263,980. The v1-era core package x402 had 648,670, against 586,525 for @x402/core. Of those 648,670, 581,480 were version 0.7.3, which accepts only x402Version 1 and sends only X-PAYMENT. Downloads are not users, because CI and mirrors inflate them. Even so, none of the unscoped packages is marked deprecated. Issue #3091, which asks for that, has been open since 2026-08-08.

The reason a client cannot branch on

On first contact, the 3,923 hosts used 173 distinct error values. Payment required appeared on 2,680, and 333 sent no error at all. PAYMENT-SIGNATURE header is required, the spec's own example text, appeared on 227. payment_required appeared on 222 and X-PAYMENT header is required on 114. None of these is a defined code, because the spec defines none for the challenge.

Then we sent a v2 payment header containing {}. That is valid base64 and a valid JSON object, but not a payment.

962 hosts answered with the same status and the same error fields as the unpaid request. A client that sent a broken payment cannot tell it from never having paid. The obvious next step is to sign again, and the double-sign audit showed how readily the fetch client's retry path already does that.

1,464 hosts returned the string Unsupported x402 version: undefined, 1,459 of them inside a 402. The string comes from the TypeScript SDK. Its findMatchingRequirements throws it from its default branch. processHTTPRequest catches it and copies the message into PaymentRequired.error. Section 9 has a code for exactly this case, invalid_x402_version, and only 5 hosts used it.

Only 107 hosts answered with any §9 code: invalid_payload on 100, invalid_x402_version on 5, and one each of invalid_payment_requirements and unsupported_scheme. The responses that did differ from first contact carried 628 distinct error strings.

Status codes did not settle it either. 3,241 hosts answered the empty payment with 402, 517 with 400, 58 with 500, 40 with 429 and 26 with 502. The transport table says 400. But only 9 of the 517 hosts that sent 400 attached a PAYMENT-REQUIRED header, so the rest withdrew the offer along with the rejection.

The reference servers disagree here too. Go answers a PAYMENT-SIGNATURE it cannot decode into a versioned payload with 400 and {"error":"invalid_payload"}, and no header (server.go). Python treats a header that fails to decode or validate as no payment at all (_extract_payment), so it sends the first-contact 402. We confirmed that the 2.28.0 decoder raises on {}. TypeScript answers our decodable-but-empty object with a 402 carrying the exception text, and treats a header that is not base64 JSON as no payment. That makes three reference servers with three answers to one malformed payment.

Fourteen hosts went further and returned a PAYMENT-RESPONSE for a payload with no authorization in it. Their errorReason values include invalid_payload, invalid_x402_version, unsupported_x402_version and the French version_invalide, and some are whole sentences. Four of them put a VerifyResponse shape, isValid and invalidReason, where a SettlementResponse belongs.

The v1 header probe tells the same story from the other side. 2,544 hosts answered an X-PAYMENT header exactly as if nothing had been sent. On 114 of the 439 hosts that advertise a v1 offer in the body, a malformed X-PAYMENT got the first-contact response. An empty payload cannot show whether those hosts would honor a valid v1 payment. What it does show is that a v1 buyer who gets it wrong is told nothing new.

What the two issues ask for

#4251 proposes three things. The first is a minimal JSON body on every v2 402, such as {"x402Version":2,"error":"see PAYMENT-REQUIRED header"}, about 60 bytes. The second is a single version-signal rule, either that body or an X402-VERSION response header. The third is a client algorithm in the transport doc: header first, body as fallback, and an explicit failure when neither parses. Our numbers fit the first proposal. Twenty hosts already do it, and 859 send {}.

#4252 proposes an optional errorReason on PaymentRequired, carrying §9 codes plus new challenge-stage codes. The examples are missing_payment, malformed_payment, unsupported_scheme_on_resource, unsupported_network_on_resource and resource_unavailable. error would remain the human-readable companion.

The thread has already found two traps. The first is that the unpaid first call and a bounced paid call return the same object. So the code set needs an explicit first-contact value, and clients need a rule that an absent errorReason means "no information," never "no error." The second is a name collision. errorReason already exists in SettlementResponse, so a single 402 could carry it twice, once in PAYMENT-RESPONSE and once in PAYMENT-REQUIRED. The proposal needs a precedence rule: the receipt describes the payment, and the challenge describes the offer.

Our data adds one fact to that thread. The TypeScript server already puts a §9 code in error when verification fails, since it copies invalidReason. When matching fails, it puts free text in the same field. So code-valued error fields are already in the wild, in a field the spec types as prose. Neither issue had a linked pull request when we checked.

What it means for LLM4Agents

We probed our own endpoint the same way. The unpaid 402 from api.llm4agents.com/v1/chat/completions carries a v2 header, the body {}, and error: "Payment required", for both streaming and non-streaming requests. A {} payment gets a 402 with Unsupported x402 version: undefined. A header that is not base64, or an X-PAYMENT header, gets a response identical to first contact.

That puts us among the 859 hosts with an empty body, the 1,464 that expose the SDK's exception text, and the 2,544 that answer a v1 header as if nothing was sent. An x402-fetch 1.2.0 buyer gets a TypeError from us. We re-checked today: a browser page still cannot read our header, because the 402 sends Access-Control-Allow-Origin: * without an expose list. That gap was already disclosed in the CORS audit.

For SDK buyers, none of this matters. All three v2 clients parse our 402 and pay it. The cost falls on the buyers that rely least on an SDK. An LLM agent calling us through a generic HTTP tool sees the status and the body, and our body is {}: no price, no version, no reason. An agent whose payment fails gets an exception message that can change with any SDK release. Our audience is autonomous agents, many of them model-driven rather than SDK-driven, so the body is part of our interface whether the spec counts it or not.

There is a quieter risk too. Once we add a body copy, we will have two copies of the offer. The census shows how they drift: smaller menus, extra options, renamed networks, different digit strings. The fifth row of the harness table shows what a buyer signs when they disagree. This connects to the 402-versus-429 problem: an agent can only choose between pay, wait and stop if the response tells it which case it is in.

Staying on the frontier

First, make our 402 body self-describing, built from the same object as the header. Encode PaymentRequired once, put the base64 in the header, and put either the full JSON or {x402Version, error} in the body. Never keep two builders. Add a test that decodes the header and compares it field by field with the body. The 20 hosts with diverging menus show what two builders produce.

Second, put codes, not exception text, in error. Map a missing or unknown version to invalid_x402_version, and an undecodable header to invalid_payload. Return 400 for a malformed payment, as the transport table says, but keep PAYMENT-REQUIRED on that 400 so the agent still has the offer. Only 9 of the 517 hosts that answered 400 kept the header.

Third, decide about v1 on purpose. We do not plan to serve it. That means an X-PAYMENT should get a 400 with invalid_x402_version rather than a fresh challenge, so a v1 buyer learns that it is speaking the wrong version and does not simply sign again.

Fourth, ship the CORS expose fix from October. A challenge that lives only in a header is invisible to browser clients without it, and the self-describing body from the first step is the fallback for every client that cannot read headers.

Fifth, write the buyer-side rule into the agent guidance we publish. If two copies of an offer disagree, do not pay. A missing reason means unknown, not "no error." A 402 after a signed attempt is not, on its own, an invitation to sign again. That mirrors what #3631 and #3643 do for MCP.

Sixth, contribute the numbers. #4251 and #4252 are four days old. The census gives them counts the threads do not have yet: 1,464 hosts that expose the TypeScript default-branch string where invalid_x402_version exists, 962 hosts that answer a malformed payment as if nothing was sent, 517 that answer 400 but drop the offer on 508 of them, and the live drift between header and body copies. The TypeScript fix, a coded error from findMatchingRequirements, is small enough to propose alongside.

Paid endpoints that say what they want.

LLM4Agents is an OpenAI-compatible gateway where autonomous agents pay per call in stablecoins over x402, with one offer per route and no second copy to drift.

Register an agent