What Is x402? How the HTTP 402 Payment Protocol Works, With a Real 402 Offer Decoded

- x402 = HTTP 402 made usable. RFC 9110 still says 402 is "reserved for future use"; x402 defines the headers and JSON that make it a real payment step.
- Four moves: request,
402withPAYMENT-REQUIRED, retry withPAYMENT-SIGNATURE,200withPAYMENT-RESPONSE. A facilitator does/verifyand/settleso the API never touches a chain node. - v2 (December 2025) renamed the v1
X-PAYMENTheader, moved networks to CAIP-2 IDs (eip155:8453,solana:5eykt4...) and added extensions such asbazaarfor discovery. - Stripe x402 settles USDC on Base into a Stripe balance through the Coinbase Developer Platform facilitator; MPP (Tempo and Stripe) and L402 (Lightning) are the other HTTP 402 designs.
- On X, x402 is loud: 529.9 original posts a day in our sample, about 151x the rate of L402; 63.2% mention agents, but only 0.2% name Bazaar.
- TwitterAPI.io accepts x402 on three GET read endpoints (USDC on Base or Solana, no API key): $0.006 per request for a page of up to 20 tweets, $0.005 per profile request; with a key it is $0.15 per 1,000 tweets returned.
"x402" shows up in agent framework docs, in Stripe's machine-payments guide, in Cloudflare's Agents SDK and in a fast-moving stream of posts on X, often with little explanation of what actually crosses the wire. This page is the protocol explainer: what x402 is, the exact request and response sequence, what a facilitator does, what Bazaar and v2 are, and how x402 differs from the other HTTP 402 designs, MPP and L402. Every protocol detail was checked against the x402 Foundation repository and specification, Stripe's and Cloudflare's own pages, and the facilitators' live /supported endpoints.
If you need the wider map of agent payments (checkout protocols such as ACP and UCP, Google's AP2 mandates, Visa and Mastercard agent programs), read our agentic payments comparison linked below; this page does not repeat it and goes deeper on x402 alone. Two things here are not on other explainers: a real 402 challenge from a live production API (ours) decoded field by field, and a study of 1,259 posts on X showing what the x402 conversation actually covers.
529.9 vs 3.5 (about 151x)
What is x402? The HTTP 402 status code, finally put to work
HTTP has had a status code for payment since the 1990s and never a way to use it. The current HTTP semantics standard, RFC 9110, still defines it in one line: "The 402 (Payment Required) status code is reserved for future use." Paywalls and APIs therefore built payment outside HTTP: an account, a subscription, an API key tied to a card. That works for humans and fails for software agents, which cannot fill in a signup form, pass an email check or enter a card.
x402 fills the gap with a small, chain-agnostic contract. The x402 Foundation repository describes it as "an open standard for internet native payments" that "aims to support all networks (both crypto & fiat) and forms of value (stablecoins, tokens, fiat)", and x402.org calls it "an open, neutral standard for internet-native payments". In practice almost every live deployment moves USDC on Base or Solana, because a stablecoin transfer can be authorized with one signature and settled for a fraction of a cent, which is what makes a $0.005 API call economical.
Who is behind it. Coinbase's developer platform introduced x402 in May 2025. On September 23, 2025 Cloudflare announced it was "partnering with Coinbase to create the x402 Foundation", proposed a deferred payment scheme for agent payments that do not need immediate settlement, and added x402 support to its Agents SDK and MCP servers (Cloudflare blog). The reference code now lives at github.com/x402-foundation/x402 (Apache-2.0); the repository's own readme no longer mentions Coinbase, though Coinbase still runs a major facilitator. The x402.org site lists Alchemy, AWS, Cloudflare, Messari, Nansen, Quicknode, Stripe, Vercel and World under "Trusted by" and states that x402 "has processed millions of transactions"; it publishes no exact figure, so we do not quote one.
What you install. The reference SDKs are on npm under the @x402 scope (@x402/core, @x402/evm, @x402/svm, the client wrappers @x402/fetch and @x402/axios, server middleware @x402/express, @x402/hono, @x402/next, and @x402/mcp for paid MCP tools), on PyPI as x402, and in Go as github.com/x402-foundation/x402/go/v2. When we checked, @x402/fetch was at version 2.30.0 and the PyPI package at 2.27.0, both on the v2 protocol.
How the x402 payment flow works, step by step
The v2 specification names three parties: the resource server (the API that wants payment), the client (any application or agent; it holds a wallet) and the facilitator ("a service that handles payment verification and blockchain settlement"). The core cycle is four messages, and the default authorization flow verifies before the API does any work and settles after it.
1. Request. The client calls the endpoint as it would any API, with no credentials.
2. 402 challenge. The server returns 402 and a PAYMENT-REQUIRED header: base64-encoded JSON with x402Version, a resource block (URL, description, MIME type) and an accepts[] array. Each accepts entry is one way to pay: scheme (for example exact), network in CAIP-2 form, asset (the token contract), amount in the token's smallest unit, payTo (the recipient address) and maxTimeoutSeconds.
3. Sign and retry. The client picks one entry it can pay, signs a payload (on EVM chains an EIP-3009 transferWithAuthorization for USDC, which needs no gas from the payer) and repeats the request with a base64 PAYMENT-SIGNATURE header.
4. Verify, serve, settle. The server, or a facilitator on its behalf, checks the signature, amount and time window (POST /verify), runs the request, broadcasts the transfer (POST /settle) and returns 200 with the data plus a PAYMENT-RESPONSE header carrying the settlement result: success, the transaction hash, the network and the payer. A failed payment comes back as 402 with a PAYMENT-RESPONSE that carries an errorReason such as insufficient_funds.
Schemes decide how money moves. The repository defines exact ("transfers a specific amount"), upto ("authorizes up to a maximum per request; the seller settles the actual usage, up to that cap") and batch-settlement (EVM only: escrow plus off-chain vouchers that the seller redeems in batches); the spec's scheme folder also lists auth-capture. Replay protection comes from the token standard: each EIP-3009 authorization carries a unique 32-byte nonce and an explicit valid-before time, and the contract rejects a reused nonce.
A real x402 402 challenge, decoded field by field
Most explainers show the spec's example payload with a testnet address. Here is a live production challenge instead. TwitterAPI.io accepts x402 on three GET read endpoints, so an unpaid request to one of them returns a real offer. We sent a plain curl with no key and no payment to https://api.twitterapi.io/x402/twitter/user/info?userName=x402 and got HTTP/2 402, the body {"error":"Payment required"}, cache-control: no-store, and a payment-required header of about 2,700 base64 characters. Decoded, it reads as follows (addresses shortened).
The resource.description is written for an agent to read: "Fixed price per request. Limited to 20 requests per second per paying wallet. No API key or account needed." The search endpoint /x402/twitter/tweet/advanced_search answers the same way with amount 6000 (0.006 USDC) and a description that adds "for up to 20 results; an empty result is still charged". That one header tells a wallet-equipped agent everything it needs: the price, both networks, the token contract, the recipient, the time limit and the input schema, with no documentation lookup.
We did not complete a paid call for this page (we used no wallet), so the trace stops at the challenge. A client library such as @x402/fetch or the Python x402 package handles steps 3 and 4: it reads accepts[], signs with the configured wallet, retries, and exposes the PAYMENT-RESPONSE receipt.
# No API key, no wallet: just ask, and read the 402 offer.
curl -s -D headers.txt -o body.json \
"https://api.twitterapi.io/x402/twitter/user/info?userName=x402"
head -1 headers.txt # HTTP/2 402
cat body.json # {"error":"Payment required"}
# The offer is base64 JSON in the payment-required header.
grep -i '^payment-required:' headers.txt | cut -d' ' -f2 | tr -d '\r' \
| base64 -d | python3 -m json.tool
# -> "x402Version": 2,
# "accepts": [
# {"scheme": "exact", "network": "eip155:8453",
# "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
# "amount": "5000", "maxTimeoutSeconds": 300, ...},
# {"scheme": "exact", "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
# "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "amount": "5000", ...}
# ],
# "extensions": {"bazaar": {"info": {"input": {"type": "http", "method": "GET", ...}}}}x402 facilitators and the Bazaar: who settles, and how agents find paid APIs
A facilitator is optional in principle; a resource server with its own chain node and signer can verify and settle itself. In practice nearly every x402 seller uses one, because the facilitator absorbs the chain-specific work: checking signatures, simulating the transfer, paying gas (or, on Solana, acting as feePayer), broadcasting and waiting for confirmation. The interface is three HTTP endpoints in the spec: POST /verify, POST /settle and GET /supported, which lists the scheme and network pairs, the extensions and the signer addresses a facilitator handles.
Because /supported is public, you can see exactly what a facilitator will do before you depend on it. We read two of them this year.
Two practical rules follow. First, the public x402.org facilitator is a testnet tool; the repository readme says it plainly: "Do not assume the public x402.org facilitator is the default production path for mainnet EVM routes." Second, pick the facilitator by the networks and schemes you need and by whether it indexes your endpoint for discovery. TwitterAPI.io's x402 endpoints, for example, settle through PayAI, which lists both Base and Solana mainnet and the bazaar extension, which is what the Bazaar paragraphs below rely on.
The x402 Bazaar: how agents discover paid APIs. A payment protocol does not help an agent that cannot find anything to buy. The v2 specification adds a Discovery API, "a discovery mechanism that allows clients to find and explore available x402-enabled resources. This enables the creation of marketplaces (known as 'Bazaars')". A facilitator that implements it exposes GET /discovery/resources (filterable by type, scheme, network and extensions) and GET /discovery/search; each listed resource carries its URL, type, x402Version, the accepts[] price list and a lastUpdated timestamp.
Listings are fed by the bazaar extension. The spec says it "enables resource discovery and cataloging for x402-enabled endpoints and MCP tools": the seller puts an info block (HTTP method or MCP tool name, input parameters, output example) and a JSON schema for it into the 402 response, and a facilitator that sees the extension can index the endpoint. That is the block at the end of the live offer decoded in the previous section: method GET, query parameter userName described as "X username without @", and an example output. An agent can therefore search a Bazaar for "twitter" or "social-data" (the offer's tags), read the price, and call the endpoint with no prior integration.
"x402 marketplace" searches usually mean one of these catalogs. Besides facilitator-run Bazaars, the x402 repository readme points to community directories: x402scan.com, agentic.market, pay.sh, app.ampersend.ai/discover and x402-list.com. Treat any directory as a lead, not a guarantee: always read the live 402 from the endpoint itself before an agent spends, since the price in the challenge is the one that applies.
x402 v2: what changed from v1
The specification's version history lists v0.1 (initial draft, August 2025), v0.2 (a transport-agnostic redesign, October 2025) and v2.0 on December 9, 2025: "CAIP-2 networks, restructured PaymentPayload/Required, ResourceInfo separation, extensions support". The differences you meet in code are below; we compared the v1 and v2 spec files in the repository.
CAIP-2 is the change that matters most for multi-chain work: a network is namespace:reference, so EVM chains are eip155:<chainId>, Solana is solana:<genesis hash>, and the spec encourages non-blockchain rails to follow the same shape (it gives ach:us and sepa:eu as examples). Facilitators can serve both versions at once: PayAI's /supported lists v1 pairs under the old network names next to v2 pairs under CAIP-2 IDs, so an old client keeps working while sellers move to v2.
Stripe x402, Cloudflare x402, and x402 vs MPP vs L402
Stripe x402. Stripe's machine payments docs ("Allow agents to pay-per-call using MPP and x402") present the Machine Payments Protocol (MPP) as the primary path and add that "Stripe also supports stablecoin payments over the x402 protocol". For x402 the rail is USDC on Base. In Stripe's x402 guide your server returns a 402 with a Stripe deposit address as payTo; mainnet payments "settle through the Coinbase Developer Platform (CDP) facilitator", and you then record the onchain transaction as a PaymentIntent so it lands in your Stripe balance and reporting. Stripe lists a 0.01 USDC minimum for stablecoin payments and stablecoin acceptance for businesses in all US states except New York. For testing it points to the public x402.org/facilitator on Base Sepolia.
Cloudflare x402. Cloudflare's contribution is distribution: the x402 Foundation it co-founded with Coinbase, x402 payments from its Agents SDK, paid tools on MCP servers, and a proposed deferred scheme for its pay per crawl beta, where a crawler is billed later instead of settling each fetch onchain.
x402 vs MPP vs L402. All three answer an unpaid request with 402; they differ in where the challenge sits and what money moves. MPP is "co-authored by Tempo and Stripe" (mpp.dev) and puts its challenge in a standard HTTP auth scheme defined by an IETF individual draft; its docs describe metered sessions and say one endpoint can "serve native MPP and x402 clients". L402, from the Lightning Network ecosystem (docs.lightning.engineering), returns 402 with a WWW-Authenticate header carrying a bearer token, recommended as a macaroon, plus a Lightning invoice; the client pays and presents the token with the payment preimage. Lightning Labs' Aperture is a reverse proxy that implements it.
Which one an agent meets is mostly a seller decision. If you sell an API and your buyers hold USDC wallets, x402 has the widest SDK and facilitator coverage; if your buyers pay by card through Stripe, MPP's card path fits; if they hold bitcoin on Lightning, L402. For checkout, mandate and card-network protocols, see the agentic payments comparison.
When x402 beats prepaid credits: an agent that buys X data
Here is the concrete case we can price exactly, because we sell it both ways. TwitterAPI.io accepts x402 on three GET read endpoints, paid in USDC on Base or Solana, no API key or account: /x402/twitter/tweet/advanced_search and /x402/twitter/user/last_tweets at $0.006 per request (one page of up to 20 tweets), and /x402/twitter/user/info at $0.005 per request. The price is per request and an empty result is still charged; the facilitator is PayAI; there is no MPP or ACP. The same data with an API key and prepaid credits is $0.15 per 1,000 tweets returned and $0.18 per 1,000 profiles.
Take an agent that checks 50 accounts and reads 10 pages of search results (200 posts) for a research brief.
The official X API figures use the docs.x.com pricing rate card: $0.010 per user read and $0.005 per post read. Per 1,000 tweets that is $5 against our $0.15 with a key, about 33x.
So x402 costs more per record than credits, and that is the trade it is designed for. Use x402 when the agent is ephemeral or third-party and should not hold an account key, when a run makes a handful of calls, when you want each spend to be an onchain receipt tied to a wallet with its own budget, or when an agent found the endpoint through a Bazaar and has no integration at all. Use an API key when the job is recurring or large: new accounts that pass the automatic bot check get up to $1 of free credits (at most 100,000 credits, no card, one per person or network, expiring after 31 days), purchased credits never expire, you pay only for the data returned, and the key also works with our hosted MCP server at https://mcp.twitterapi.io/mcp with the header Authorization: Bearer <your key>. Reads need no X account either way.
Rate limits differ too. The x402 offer states 20 requests per second per paying wallet; a key starts at 0.2 requests per second before the first payment and rises to 20 once paid, 50 on Scale and 500 on Business. The full plan list is on the pricing page.
What X says about x402: our study
To see what the x402 conversation actually covers, we collected 1,259 original posts (retweets excluded) in 2026 with /twitter/tweet/advanced_search: the newest 400 posts for x402, the 99 posts X ranks as Top for it, and up to 120 of the newest posts for each long-tail topic people search. Posts per day is the sample size divided by the hours it spans.
x402 is the HTTP 402 conversation. The bare term ran at 529.9 posts a day, about 151x the rate of L402 (3.5). Among the subtopics, facilitators get the most talk (35.9 a day), well ahead of Bazaar (4.1) and v2 (4.3), even though both shipped in the spec.
It is about agents and stablecoins, not tokens. 63.2% of the newest x402 posts mention agents, 25.2% mention USDC or stablecoins and 24.0% mention APIs; 9.2% carry a $cashtag. Base is named in 14.8% and Solana in 10.5%; every other chain we tracked stays under 3%. PayAI (6.8%) is named slightly more often than Coinbase or CDP (5.5%), and Stripe in 3.5%.
The stream and the highlights differ. Top posts reach a median of 49 likes and 3,066 views against 1 like and 37.5 views in the Latest stream, and they lean more technical: facilitators 10.1% vs 5.8%, MCP 12.1% vs 8.2%, Solana 17.2% vs 10.5%. The stream is busy but concentrated: the 10 most active authors wrote 21.5% of the newest 400 posts, and 40.0% were replies.
Each long-tail topic has its own neighbors. 46.7% of Bazaar posts name Coinbase or CDP and 40.8% name Base. Posts on x402 with Stripe name Google or AP2 in 31.2% and Coinbase in 31.2%, a sign that Stripe's x402 support is discussed as part of the wider agent-payment race. Cloudflare posts name Base in 46.2%. L402 posts almost never name a stablecoin chain (Base and Solana both 0.0%).

What the x402 stream names, and how we collected this
For a builder the takeaway is practical. If you sell an x402 endpoint, the people who will notice it are talking about agents, USDC and facilitators, mostly on Base and Solana; MCP comes up in roughly one Top post in eight, which matches the spec's choice to let bazaar index MCP tools as well as HTTP endpoints. A saved search on x402 facilitator or x402 bazaar gives a far smaller, more technical feed than the bare term.
How we collected this. Question: what does the x402 conversation on X cover, and how much attention does each long-tail topic get? Data: /twitter/tweet/advanced_search with retweets excluded for nine queries (x402 Latest and Top, then x402 facilitator, x402 bazaar, x402 v2, L402, x402 MPP, x402 stripe, x402 cloudflare, Latest). Window: the newest posts for each query at collection time in 2026 (Top: the posts X ranks highest, spanning about 410 days). Sample: 1,259 posts from 63 requests. Method: case-insensitive keyword rules (Base counts only as the capitalized word or @base, so "user base" does not match), listed in analyze.py. At our prepaid rate the collection cost $0.189; the same posts through our x402 search endpoint would have been $0.378 (63 requests at $0.006), and on the official X API rate card $6.29.
What the sample cannot show. Post counts measure attention, not adoption: they say nothing about payment volume, revenue or which facilitator settles the most. Rates come from the newest posts, so a launch or a token event inflates them. A two-word query such as x402 facilitator also matches posts where one word sits in a link or handle, and short tokens such as SOL and ETH can appear in unrelated contexts. Privacy: aggregates only; search results come from private individuals, so raw pages were not kept, the committed sample holds de-identified rows (no IDs, links, text or handles), and no individual account is named.

import base64, json, os, requests
BASE = "https://api.twitterapi.io"
# 1) The x402 route: no API key. An unpaid request returns the 402 offer.
r = requests.get(f"{BASE}/x402/twitter/tweet/advanced_search", timeout=30,
params={"query": "x402 facilitator -is:retweet", "queryType": "Latest"})
print("status:", r.status_code) # 402
offer = json.loads(base64.b64decode(r.headers["PAYMENT-REQUIRED"]))
print("x402Version:", offer["x402Version"])
for opt in offer["accepts"]:
usdc = int(opt["amount"]) / 1_000_000 # USDC has 6 decimals
print(f" {opt['scheme']} on {opt['network']}: {usdc} USDC to {opt['payTo'][:10]}...")
# A wallet-equipped client (the x402 Python or @x402/fetch SDK) would now sign one
# accepts entry and retry with a PAYMENT-SIGNATURE header. $0.006 per request.
# 2) The same data with an API key and prepaid credits: $0.15 per 1,000 tweets returned.
H = {"X-API-Key": os.environ["TWITTERAPI_IO_API_KEY"]}
cursor, seen = "", 0
for _ in range(3): # up to 3 pages of 20
r = requests.get(f"{BASE}/twitter/tweet/advanced_search", headers=H, timeout=30,
params={"query": "x402 facilitator -is:retweet",
"queryType": "Latest", "cursor": cursor})
r.raise_for_status()
body = r.json()
for t in body.get("tweets", []):
seen += 1
print(t["createdAt"], t["likeCount"], t["author"]["userName"], t["text"][:70].replace("\n", " "))
if not body.get("has_next_page"):
break
cursor = body["next_cursor"]
print("posts read:", seen)
Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.
Questions readers ask
What is x402 in simple terms?
x402 is a way to pay for a web request inside HTTP itself. The server answers an unpaid request with status 402 and a header stating the price; the client signs a stablecoin payment, retries the same request with that signature, and receives the data plus a receipt. No account, API key or card form is needed, which is why it is aimed at AI agents and other software clients.
Is x402 a cryptocurrency or a token?
No. x402 is a protocol, not a coin. It moves existing assets, in practice mostly USDC on Base and Solana. Tickers that borrow the name are unrelated to the specification; in our sample of the newest x402 posts on X, 9.2% carried a $cashtag of some kind.
Who created x402 and who maintains it now?
Coinbase introduced x402 in May 2025. In September 2025 Cloudflare and Coinbase announced the x402 Foundation, and the reference repository is now github.com/x402-foundation/x402 under the Apache-2.0 license, with SDKs for TypeScript, Python and Go.
What is an x402 facilitator and do I need one?
A facilitator is a service that verifies x402 payment signatures and settles them onchain through /verify and /settle endpoints, so your API never runs a chain node. You can self-host the role, but most sellers use one. Check its public /supported endpoint for the networks and schemes it handles; the public x402.org facilitator lists only test networks.
What is the x402 Bazaar?
The Bazaar is x402's discovery layer. Sellers add a bazaar extension (input parameters and an output example) to their 402 response, facilitators index it, and agents query /discovery/resources or /discovery/search to find paid APIs and MCP tools with their prices.
What changed in x402 v2?
v2 (December 2025) moved the client header from X-PAYMENT to PAYMENT-SIGNATURE, put the challenge in a base64 PAYMENT-REQUIRED header, switched network names to CAIP-2 IDs such as eip155:8453, separated the resource description, and added extensions such as bazaar. Facilitators such as PayAI serve v1 and v2 side by side.
Does Stripe support x402?
Yes, for stablecoins. Stripe's machine payments docs support x402 with USDC on Base, settled through the Coinbase Developer Platform facilitator and recorded as a PaymentIntent in your Stripe balance. Stripe presents MPP as its primary machine-payments path; MPP it co-authored with Tempo and which also accepts cards.
What is the difference between x402 and L402?
Both use HTTP 402. L402 returns a WWW-Authenticate header with a bearer token (recommended as a macaroon) and a Lightning invoice, and the client proves payment with the invoice preimage, so it moves bitcoin. x402 returns a PAYMENT-REQUIRED JSON offer and settles signed stablecoin transfers through a facilitator. On X, x402 ran at about 151x the post rate of L402 in our sample.
Continue
- x402 Foundation repository: readme, SDK packages, schemes, facilitator guidance (Apache-2.0)
- x402 v2 specification: payment flow, types, facilitator API, Discovery API, CAIP-2 networks, version history
- Cloudflare blog: x402 Foundation with Coinbase, Agents SDK and MCP support, deferred scheme
- Stripe docs: accept x402 payments (USDC on Base, CDP facilitator, PaymentIntent)
- RFC 9110 HTTP Semantics: 402 Payment Required is reserved for future use
- Lightning Labs docs: L402 protocol and the Aperture proxy
- X (Twitter) API hub: endpoints, pricing and guides
- Agentic payment protocols compared: ACP, AP2, x402, MPP and card programs
- What an MCP server is and how agents call paid tools
- How to build an AI agent that reads X data
- Official X API pricing and cost breakdown
- TwitterAPI.io hosted MCP server setup
- TwitterAPI.io pricing: pay per tweet returned
- 01Warp Pricing in 2026: Plans, Dollar Usage, Add-ons and the Real Monthly Bill
- 02Roo Code vs Cline in 2026: After the Shutdown, Which One to Run
- 03Windsurf (now Devin Desktop) vs Cursor in 2026: plans, agents, MCP and what X users say
- 04Gemini CLI vs Claude Code in 2026: Access, Quotas, MCP and Pricing for Twitter (X) Data Agents
- 05Manus Pricing in 2026: Plans, Credits per Task, and What People on Twitter (X) Say It Costs
- 06xurl: the X API CLI for Twitter (X) — Install, Auth, Commands and What Each Read Costs
- 07How to Use Cursor with the Twitter (X) API
- 08How to Search Tweets by Date via API — A Developer's Guide
Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.
Stop reading. Start building.
Starter credits cover real testing on real data. Google sign-in, no card, no application queue.
Get an API keyAlready building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.