the payment layer for agents

What is x402?

x402 turns HTTP's long-dormant 402 Payment Required status into a real payment layer. A service can ask for payment; an agent can pay it — in stablecoins, per request, with no account.

The exchange

  1. Request

    The agent calls a resource like any other HTTP request — no payment yet.

    GET /resource
  2. 402 + price

    If the resource is paid, the service replies 402 Payment Required and states the price, asset, and where to pay.

    402 · price: $0.01 USDC
  3. Pay

    The agent signs an authorization to transfer the exact amount from its wallet, and resends the request with the payment attached.

    PAYMENT-SIGNATURE: …
  4. Settle + respond

    A facilitator verifies and settles the payment on-chain — sponsoring the gas — and the service returns the resource.

    200 OK

Why agents want it

No accounts, no API keys

An agent identifies and pays with its wallet. Nothing to sign up for, provision, or leak.

Pay for exactly what you use

Micro-payments in USDC, settled in the same round-trip. No subscriptions, no minimums.

Made for machines

It's just HTTP. An agent reads a price, signs a payment, and retries — no checkout, no human in the loop.

Open and multi-chain

An open standard — created by Coinbase, now stewarded by the x402 Foundation — with many independent facilitators across Base, Polygon, Solana, and more.

Getting started

Your agent needs two things: a funded wallet and an x402-aware HTTP client. Then it can pay any x402 endpoint — automatically.

import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.WALLET_KEY);
const pay = wrapFetchWithPayment(fetch, account);

// any 402 is handled for you — pay, then retry:
const res = await pay("https://api.example.com/paid");

The client watches for a 402, signs the payment, and retries. That's the whole integration.

Bigger than any one vendor

x402 is an open protocol with a growing ecosystem of facilitators, explorers, and services. We build on it and contribute to it — and we'll point you to the rest, even when it isn't us. The spec lives at x402.org.