DEV Community

minia2a
minia2a

Posted on Edited on

We called 1,688 x402 endpoints with their own published examples. Here is what breaks.

We called 1,688 x402 endpoints with their own published examples. Here is what breaks.

An x402 endpoint answers with HTTP 402 and a JSON challenge that tells the buyer three things: the price, the payee, and — through a discovery extension — how to call it. For an AI agent that has never seen the API before, that challenge is the whole contract. It does not read your docs. It reads the 402.

So we audited our own catalog the same way a buyer's agent would: one request per endpoint, using the input its own 402 publishes, then compared the answer to the output shape the same 402 advertises.

Method

  • 1,688 active services in our catalog, one call each, input taken from the endpoint's own discovery example.
  • No payment where a signed-wallet trial covered the call; the check is about delivery, not billing.
  • The response was compared against the declared answer shape: does every advertised key exist, is the type what the example says, did the call return a real answer rather than a placeholder.
  • This measures the seller's own contract. It cannot measure whether the answer is useful — only whether the buyer gets what the listing promised.

What we found

1,609 of the 1,688 delivered a proper response against their own example. 72 accept no input and answer on an empty call. 3 were upstream rate-limited that day (a shared free API returning 429 — a capacity problem, not a contract problem).

Four were worse than broken: they published an example that their own handler rejects. A group of related prediction-market services had written a market identifier into their example that no longer had an order book. The handler treats "no order book" as a valid answer, so the buyer paid, the endpoint returned ok: true, and the payload said noBook. The buyer did not get an error; they got a receipt for nothing.

That class of failure — the contract being internally consistent but wrong about the world — is the one agents cannot detect by format checking.

The failure taxonomy

Across our own audit and a public scan of 42k endpoints (x402 Doctor, October 2026 — research link), the recurring causes are:

  • Resource mismatch (2,009 endpoints in that scan). The resource.url in the challenge is not the URL that was called: a relative path, another host, or http instead of https. Checkers refuse it, and the buyer is pointed at a door that is not the one they knocked on.
  • Listed but no 402 (1,042). The listed URL answers 404, 401, a login page, or 200 for free. Often the route is POST while the listing says GET.
  • Price drift. The 402 asks more than the listing says. An agent that checks first stops there; one that does not has already signed.
  • Examples that cannot run. Missing required fields, values that were valid last month, or a payload shape the handler changed.
  • Testnet-only offers. The challenge settles nowhere a mainnet agent can pay.

The scan's own headline was that 93% of endpoints were payable as listed — which sounds reassuring until you notice that "payable" only means the challenge is well-formed. Delivery is a second question.

What we changed on our side

We re-audited every service, not just the four that failed: examples with market identifiers are now re-probed before they are published again, and the output examples are checked key-by-key against a real response. We also capped the challenge header at 7.6 KB and raised our ingress header buffers to 16 KB in both directions, because the official client copies every extension from the 402 into the retry request — a fat challenge becomes a fat request, and an 8 KB header limit drops it silently.

Check your own endpoint in three commands

  1. curl -i https://your.api/route — the first answer must be 402, with a PAYMENT-REQUIRED header.
  2. Decode that header and confirm resource.url equals the URL you called, exists, and is https.
  3. Replay the input example from the same challenge against your handler. If that fails, every agent that found you through a directory will fail after paying.

Why this matters commercially

An agent's willingness to pay is built on evidence. A tracked record of "this endpoint, called with its own example, delivered" is the only kind of reputation that transfers between strangers. If you run an x402 endpoint and want a second pair of eyes before buyers arrive, our black-box payment check is $5 and the first one is free with no registration: https://minia2a.uk/service.html?id=x402-payment-audit (human page; the JSON endpoint is https://minia2a.uk/x402/x402-payment-audit)

Data: our catalog audit was run on 2026-11-29. Market statistics are from the public x402 Doctor scan of 17 October 2026; link above.

Update (2026-12-01): the recipe in our own CTA had the same class of bug

The check linked at the end of this post is x402-payment-audit, and its 402 says the first audit is free once per wallet. That challenge's nextSteps renders the signature expression with two missing + around the service id:

sign("minia2a trial:"+wallet+":"x402-payment-audit:"+ts)     <- not an expression
Enter fullscreen mode Exit fullscreen mode

Copy-paste it and you get a syntax error, or you sign a string with literal quote characters in it. This is the same failure the article describes: the contract is well-formed enough to look like one, and wrong at two characters.

The message that actually verifies is the plain string minia2a trial:<wallet>:<serviceId>:<ts>, with the full service id x402-payment-audit (not the URL slug, not a quoted id). Verified from outside on 2026-12-01 — first call returns a real report, second call on the same wallet is 402:

import time, urllib.request
from eth_account import Account
from eth_account.messages import encode_defunct

acct = Account.create()                       # any fresh wallet
ts = str(int(time.time()))
msg = f"minia2a trial:{acct.address}:x402-payment-audit:{ts}"
sig = Account.sign_message(encode_defunct(text=msg), acct.key).signature.hex()
sig = sig if sig.startswith("0x") else "0x" + sig

url = ("https://minia2a.uk/x402/x402-payment-audit"
       f"?url=https://minia2a.uk/x402/math&wallet={acct.address}")
req = urllib.request.Request(url, headers={
    "X-Wallet-Signature": sig,
    "X-Trial-Timestamp": ts,
    "X-Agent-ID": "agent:your-stable-id",
})
print(urllib.request.urlopen(req, timeout=90).read().decode()[:300])
# 200 {"ok":true,"result":{"verdict":"safe", ...}}
# second call, same wallet: 402 Payment required
Enter fullscreen mode Exit fullscreen mode

One more thing worth knowing before you build against it: the 200 carries no X-Trial-Remaining header, so the only signal that the free audit is spent is the 402 on the next call. If you need a countdown, that is a gap on our side, not a feature you should infer.

The fix is a two-line change to the Go string that renders the challenge. Until it ships, the snippet above is the working copy — and the honest version of this article's thesis is that we found ours the same way we found the others' examples: by calling the endpoint with the recipe it published.

Top comments (0)