x402: the complete guide

x402 is an open payment standard that revives the dormant HTTP 402 "Payment Required" status code so software — especially AI agents — can pay for an API call inline, per request, with no signup and no API key. This guide explains how it works and shows you a real call you can run right now against a live endpoint.

What x402 is

When an HTTP client requests a paid resource without payment, the server answers 402 with a machine-readable envelope describing exactly how to pay: the amount, the asset (USDC), the destination, and the settlement network. The client signs a payment authorization, retries the request with that signature attached, and receives the data plus a pointer to the on-chain settlement. No account, no key, no invoice — the payment rides along with the request.

That makes x402 a natural fit for autonomous agents: an agent can discover a resource, see its price, decide, pay, and consume it in a single tool-use loop, with funds drawn from a wallet you control.

The flow in three steps

Every x402 call is the same probe → sign → retry loop:

See it work — no signup

Every page in this guide ends with an example that hits a real, live 2s endpoint. The fastest taste is a free trial call (one per endpoint per hour, returns real data with no payment):

cURL — free trialbash
# Free trial call — real data, no payment, no signup (1/endpoint/hour):
curl "https://2s.io/api/weather/zip?zip=94103&trial=1"

Why 2s for x402

Most x402 tutorials demo against a toy "echo" endpoint. 2s is a live catalog of hundreds of keyless, real-data endpoints — weather, patents, sanctions screening, SEC filings, geocoding, CVEs, and more — all payable by x402. So the examples here return real data, and the same payment flow works across the entire catalog.

Where to go next

Pick your path: copy-paste a working call, wire up your language, or browse the catalog.

All guides

How-to
x402 example A copy-paste x402 API example that returns real data against a live, keyless endpoint — shown in cURL, TypeScript, and Python.
x402 with cURL How to call and test an x402 API with cURL: see the 402 envelope, run a free trial call, and understand the PAYMENT-SIGNATURE retry — against a live endpoint..
x402 quickstart A step-by-step x402 tutorial: fund a wallet, install an SDK, make a free trial call, then a paid call — all against live, keyless endpoints.
Languages
x402 in Python How to call an x402 API in Python: install 2sio, fund a wallet, and make a real paid call to a live endpoint — plus a free trial call.
x402 in TypeScript / Node How to call an x402 API in TypeScript or Node.js: install @2sio/sdk, fund a wallet, and make a real paid call with fetch-style ergonomics.
x402 MCP server Add the @2sio/mcp server to Claude Desktop or any MCP host and your agent can call hundreds of x402 endpoints as tools, paying per call from your wallet..
x402 in Next.js How to call x402 APIs from a Next.js app: use @2sio/sdk in a route handler or server action with your wallet key server-side.
x402 with LangChain Use langchain-twosio to give a LangChain agent x402-payable API tools.
Ecosystem
x402 API list A directory of live x402 APIs for AI agents: weather, patents, OFAC sanctions, SEC filings, geocoding, CVEs and more — all keyless, pay-per-call, real data..
Comparison
x402 vs Stripe x402 vs Stripe compared: signup and keys vs none, card rails vs stablecoin, human checkout vs inline machine payment.
x402 vs API keys x402 vs API keys and subscriptions: no signup, no key rotation, no quota tiers — pay per call in USDC.
Agentic payment protocols A neutral comparison of agent payment protocols: x402 (HTTP 402 + stablecoin), L402 (Lightning + macaroons), and intent-based schemes like AP2/ACP.
Reference
x402 networks (Base & Solana) x402 settlement rails explained: USDC on Base via EIP-3009, or USDC on Solana via SPL transfer.
x402 facilitator What an x402 facilitator does: verifies the signed payment authorization, submits it on-chain, and pays gas.
x402 wallet setup How to set up a wallet for x402: get an EVM (Base) or Solana wallet, fund it with a little USDC, and put the key in an env var.
HTTP 402 explained What the HTTP 402 Payment Required status code is, why it sat unused for decades, and how x402 finally puts it to work with a machine-readable payment envelope..

Call a live x402 API right now — no signup.

Browse the full endpoint directory, grab the quickstart, or read the llms.txt manifest. Every endpoint is keyless and pay-per-call.

FAQ

What is x402 in simple terms?
x402 is a way to pay for an API call as part of the request itself. The server replies 402 with how much to pay and where; your client signs a stablecoin payment and retries; you get the data. No account or API key is involved.
Do I need an account or API key to use x402?
No. That is the point of x402 — payment replaces authentication. You only need a crypto wallet funded with a little USDC. On 2s every endpoint is keyless and pay-per-call.
What does an x402 call cost?
Whatever the endpoint quotes in its 402 envelope, charged per call in USDC. On 2s most calls are a fraction of a cent. There are no minimums or monthly fees.
Is x402 only for AI agents?
No, but agents are the best fit because they can read the 402 envelope and pay programmatically. Any HTTP client — a script, a backend, a browser app with a wallet — can use it.
How is x402 different from a normal paywall?
A paywall expects a human to sign up and enter a card. x402 is machine-native: the price and payment instructions are structured data in the 402 response, and payment is a signed on-chain authorization, so software can pay without human steps.

Related

Topics: x402 · what is x402 · x402 protocol · x402 payment protocol · x402 explained · http 402 · 402 payment required · x402 standard · x402 api · pay per call api