X402 Protocol

Let AI agents pay your invoices

X402 is an open payment protocol that uses the HTTP 402 status code to let AI agents pay for resources autonomously. No checkout page, no human click, no API key exchange — just USDC on Base settling directly to your wallet.

No checkout needed USDC on Base Direct to your wallet
AI Agent → PayRequest
POST /api/v1/x402/yourhandle/pay
# No payment header yet
402 Payment Required
HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "x402Version": 2,
  "error": "payment_required",
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:8453",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "amount": "5000000",
    "payTo": "0xYourWalletAddress",
    "maxTimeoutSeconds": 30
  }]
}
200 OK — Settled
HTTP/1.1 200 OK
X-Payment-Response: base64(receipt)

{
  "success": true,
  "onchain_tx": "0xTxHash…",
  "payer": "0xAgentWalletAddress",
  "amount_usdc": 5.00
}
The protocol

HTTP 402 — the status code that was always meant for payments

The 402 Payment Required status code was reserved in HTTP/1.1 in 1996 but never standardized. X402 finally gives it a real implementation: a request, a payment requirement response, a signed authorization, and a settlement — all in a single round trip.

402
Payment Required
HTTP status code, defined 1996. Finally standardized.
How it works

Four steps, zero human clicks

An agent can discover your payment requirements, sign an off-chain authorization, and settle USDC to your wallet in one round trip. PayRequest handles verification and broadcast — you just receive the funds.

01

Agent discovers your endpoint

The agent reads your payments.txt manifest and finds your x402_payment_endpoint. Alternatively it calls the discovery JSON at x402_discovery_url to get the full payment requirements object.

02

Agent gets a 402 response

The agent POSTs without a payment header. PayRequest responds 402 with a JSON body: the exact USDC amount, your wallet address, supported network, and a timeout window.

03

Agent signs off-chain

The agent signs an ERC-3009 transferWithAuthorization message with its wallet. No gas, no on-chain transaction yet — just a cryptographic authorization.

04

PayRequest verifies and settles

The agent retries with an X-Payment header. PayRequest verifies the signature, broadcasts the USDC transfer on Base, and responds 200 with the on-chain transaction hash.

Invoice payments

Agents can pay specific invoices autonomously

Every invoice has a dedicated X402 endpoint. An agent that receives your invoice email can extract the invoice ID, pay via X402, and the invoice closes — all without a human touching the checkout.

Invoice payment endpoint
POST POST /api/v1/x402/yourhandle/invoice/{invoiceId}/pay

The 402 response contains the exact invoice amount. On success, the invoice is automatically marked as paid in PayRequest.

Settlement

Funds go directly to your wallet — PayRequest is just a relay

PayRequest verifies the agent's signature and broadcasts transferWithAuthorization on the USDC contract. Funds move from the agent's wallet directly to yours. No intermediary holds, no custodial risk, no overnight settlement wait.

< 2s
Settlement time on Base
~$0.001
Gas cost per transaction
0%
PayRequest cut on X402
ERC-3009
Authorization standard
Supported networks

Base, Base Sepolia, and Solana

NetworkTokenChain IDStatus
Base (mainnet)USDCeip155:8453Live
Base Sepolia (testnet)USDCeip155:84532Testnet
Solana (mainnet)USDCsolana:5eykt4...Live
For developers

Building an agent that pays PayRequest users?

The full protocol specification is compatible with the open X402 spec published by Coinbase. Any agent built against that spec works with PayRequest out of the box.

X402 open spec on GitHub
01

Discover

GET payrequest.me/{handle}/payments.txt or the JSON discovery endpoint for full payment requirements.

02

Get requirements

POST to the payment endpoint, expect a 402 response with amount, asset, network, and payTo address.

03

Sign

Use viem, ethers.js, or any EIP-712 library to sign TransferWithAuthorization.

04

Pay

Retry the POST with the X-Payment header containing your base64-encoded signature payload.

05

Confirm

200 response + X-Payment-Response header = settled. The on-chain TX hash is in the response body.

FAQ

Frequently asked questions

Is this the same X402 as Coinbase's?

Yes. PayRequest implements the open X402 spec published by Coinbase. Any agent built against that spec works with PayRequest. No Coinbase account is needed on your end.

Does the agent need gas?

Yes — a tiny amount of ETH on Base (roughly $0.001 per settlement). The agent's wallet needs ETH to pay for gas when the USDC transfer is broadcast. Base is extremely cheap.

What wallets can agents use?

Any EVM-compatible wallet that can sign EIP-712 typed data. Smart contract wallets (Safe, Coinbase Smart Wallet) are also supported since ERC-3009 handles those signatures.

What if verification fails?

If the signature is invalid, expired, or the amount is too low, PayRequest returns another 402 with a verification_error field explaining what went wrong. The agent can retry with a fresh signature.

Can I test on a testnet first?

Yes. Use Base Sepolia testnet USDC to test X402 payments before going live. The testnet endpoint is automatically used when your account is in test mode.

Do I need to enable this?

Connect your EVM wallet in Provider Settings and your X402 endpoints go live automatically. No separate feature flag to toggle.

POST /api/v1/x402/yourhandle/pay → 200 OK

Your invoices, paid by agents

Connect your EVM wallet to unlock X402 endpoints. AI agents can start paying your invoices autonomously — no checkout, no chasing, just USDC settling to your wallet.