Skip to main content

X402 Autonomous Payments

X402 is an open payment protocol that uses the HTTP 402 Payment Required status code to let AI agents pay for resources autonomously — no checkout page, no human click, no API key exchange. Your PayRequest page is already X402-compatible. Agents that speak the protocol can discover your payment requirements, sign an authorization off-chain, and settle USDC directly to your wallet in one round trip.
X402 requires your EVM wallet to be connected in Provider Settings. The agent pays to that address directly — PayRequest never holds the funds.

How it works

1

Agent discovers your payment 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.
2

Agent gets payment requirements (402)

The agent sends a POST to your payment endpoint without a payment header. PayRequest responds with HTTP 402 Payment Required and a JSON body describing exactly what to pay:
amount is in USDC atomic units (6 decimals): 1000 = $0.001.
3

Agent signs the payment off-chain

The agent signs an ERC-3009 transferWithAuthorization message with its wallet — no gas, no on-chain transaction yet. This is just a cryptographic signature authorizing the USDC transfer.
4

Agent retries with X-Payment header

The agent sends the same request again, this time including:
5

PayRequest verifies and settles

PayRequest verifies the signature, then broadcasts transferWithAuthorization on Base — moving USDC from the agent’s wallet directly to yours. No intermediary. The transaction is final within seconds.
6

Agent receives confirmation (200)

PayRequest responds 200 OK with:
Plus an X-Payment-Response header with the settlement receipt.

Pay a specific invoice

Agents can pay a specific outstanding invoice by hitting:
The 402 response will include the exact invoice amount as the required payment. On success, the invoice is automatically marked as paid in PayRequest. This is the primary use case: an AI agent receives an invoice email, extracts the invoice ID, pays it autonomously via X402, and the invoice closes — all without a human touching the checkout.

Discovery endpoints

Supported networks

Settlement

PayRequest settles payments by calling transferWithAuthorization on the USDC contract. This moves funds directly from the agent’s wallet to yours — PayRequest acts as a broadcast relay, not a custodian. Settlement uses the Base public RPC by default. No Coinbase CDP account is required.
You can use Base Sepolia testnet USDC to test X402 payments before going live. Set X402_TESTNET=true in your environment to switch endpoints to testnet.

For developers building agents

If you’re building an AI agent that needs to pay PayRequest users autonomously:
  1. DiscoverGET https://payrequest.me/{handle}/payments.txt or the JSON discovery endpoint
  2. Get requirementsPOST to the payment endpoint, expect a 402 response
  3. Sign — Use viem, ethers.js, or any EIP-712 library to sign TransferWithAuthorization
  4. Pay — Retry the POST with the X-Payment header
  5. Confirm200 response + X-Payment-Response header = settled
The full protocol specification is at:

X402 spec on GitHub

Complete request/response format, header schemas, and network reference.

Frequently asked questions

No — not for the agent. The agent only signs an off-chain ERC-3009 authorization; it never needs ETH or any gas balance. PayRequest’s own wallet broadcasts the transferWithAuthorization transaction on Base and pays the (tiny, roughly $0.001) gas cost itself. Agent developers don’t need to fund a wallet with ETH to use X402.
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.
The default per-call amount is $0.001 USDC. For invoice payments, the amount is always the invoice total. Custom minimum amounts per-user are on the roadmap.
If the signature is invalid, expired, or the amount is too low, PayRequest returns another 402 with the verification_error field explaining what went wrong. The agent can retry with a fresh signature.
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.