Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.monkepay.xyz/llms.txt

Use this file to discover all available pages before exploring further.

The handshake

Every x402 payment follows the same three-step flow: Step 1 — Agent makes a request without payment
GET /api/data HTTP/1.1
Host: api.yourcompany.com
Step 2 — Server returns 402 with payment requirements
HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "base-sepolia",
    "maxAmountRequired": "1000",       // atomic USDC units (1000 = $0.001)
    "payTo": "0xYourWalletAddress",
    "asset": "0x036CbD53842c5426634e7929541eC2318f3dCf7e",
    "resource": "https://api.yourcompany.com/api/data"
  }]
}
Step 3 — Agent pays and retries with proof
GET /api/data HTTP/1.1
Host: api.yourcompany.com
X-Payment: <base64-encoded payment payload>

HTTP/1.1 200 OK
X-Payment-Response: <base64-encoded settlement proof>
The agent never leaves the HTTP request/response cycle. Payment is embedded directly in the headers.

What MonkePay adds

x402 handles the wire protocol. MonkePay adds the operational layer on top:
  • Wallet management — MonkePay provisions and manages a CDP wallet for your account. You don’t need to run your own node or manage private keys.
  • Payment verification — MonkePay verifies on-chain that the payment actually happened before your handler runs.
  • Settlement — MonkePay settles the payment and credits your balance.
  • Dashboard — every payment is logged, filterable, and exportable.
  • Payouts — accumulated USDC is paid out to your configured wallet address.

The facilitator

x402 uses a facilitator to verify and settle payments. The facilitator is a trusted third party that:
  1. Verifies the payment payload is cryptographically valid
  2. Confirms the transaction exists on-chain
  3. Settles the payment to the recipient wallet
MonkePay uses Coinbase’s hosted facilitator. You don’t configure this — it’s handled by the SDK automatically.

Payment timing

A typical x402 payment round-trip on Base Sepolia:
StepTime
Agent receives 402~0ms
Agent signs and broadcasts transaction~200ms
Transaction confirmed on Base~1,000ms
MonkePay verifies and settles~200ms
Agent receives 200~1,400ms total
Base mainnet has similar finality. The total overhead per paid request is approximately 1-2 seconds on first call. Subsequent calls in per_request mode incur the same cost each time.

x402 resources