X402 Autonomous Payments
X402 is an open payment protocol that uses the HTTP402 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
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.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.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.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.Pay a specific invoice
Agents can pay a specific outstanding invoice by hitting: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
| Endpoint | Method | Description |
|---|---|---|
/yourhandle/payments.txt | GET | Human + machine readable manifest |
/api/v1/x402/yourhandle | GET | JSON discovery: wallets, accepted networks, payment URL |
/api/v1/x402/yourhandle/pay | POST | X402 payment endpoint |
/api/v1/x402/yourhandle/invoice/{id}/pay | POST | Pay a specific invoice |
Supported networks
| Network | Token | Chain ID |
|---|---|---|
| Base (mainnet) | USDC | eip155:8453 |
| Base Sepolia (testnet) | USDC | eip155:84532 |
| Solana (mainnet) | USDC | solana:5eykt4... |
Settlement
PayRequest settles payments by callingtransferWithAuthorization 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.
For developers building agents
If you’re building an AI agent that needs to pay PayRequest users autonomously:- Discover —
GET https://payrequest.me/{handle}/payments.txtor the JSON discovery endpoint - Get requirements —
POSTto the payment endpoint, expect a402response - Sign — Use
viem,ethers.js, or any EIP-712 library to signTransferWithAuthorization - Pay — Retry the
POSTwith theX-Paymentheader - Confirm —
200response +X-Payment-Responseheader = settled
X402 spec on GitHub
Complete request/response format, header schemas, and network reference.
Frequently asked questions
Does this require gas fees?
Does this require gas fees?
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?
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.
Can I set a minimum payment amount?
Can I set a minimum payment amount?
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.
What if verification fails?
What if verification fails?
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.Is this the same X402 as Coinbase's?
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.