x402 Overview
x402 on Crypto APIs
x402 is an open protocol for paying for HTTP resources with stablecoin, using the standard 402 Payment Required response. Crypto APIs runs the buyer and facilitator halves of x402 as a managed, non-custodial service on ai.cryptoapis.io/x402/* — your keys never leave your side.
The three players
- Buyer — an app or AI agent that wants to call a paid endpoint. It holds its own key and signs every payment locally. Crypto APIs derives and monitors the buyer wallet address and enforces spending policy, but never holds the key (there is no
/signendpoint). - Merchant — an API that charges per request. It answers an unpaid call with
402 Payment Requiredand aPaymentRequirementschallenge, then hands the buyer's signed payment to a facilitator. - Facilitator — verifies the signed payment and settles it on-chain with its own gas wallet. Crypto APIs runs a facilitator; a merchant may also point at any other x402 facilitator.
The flow
- The buyer calls the merchant endpoint →
402 Payment Requiredwith aPaymentRequirementschallenge. - The buyer calls
POST /x402/buyer/authorize→ Crypto APIs returns the exact signing payload (an EIP-712TransferWithAuthorizationon EVM, or the equivalent per family). - The buyer signs the payload locally and retries the merchant call with the signed payment.
- The merchant calls the facilitator
POST /verifythenPOST /settle; the facilitator settles on-chain and the merchant returns the paid response.
Non-custodial by design
Every payment is signed by the key holder. On EVM the payment is an EIP-3009 transferWithAuthorization meta-transaction — the facilitator pays gas but can never move funds it wasn't authorized for. The same principle holds across every supported family.
Assets & networks
x402 payments settle in USDC (6-decimal stablecoin). Live networks are published per-family by the merchant GET /supported endpoint; a network listed with an empty signer set is announced but not yet operational.
Getting started
- Buyers — use the
@cryptoapis-io/x402-buyer-sdkor thex402_payMCP tool / agent plugin to pay 402-gated endpoints automatically. - Merchants — use the
@cryptoapis-io/x402-merchant-sdkto add a paywall to your API in a few lines.
See the x402 Buyer and x402 Merchant & Facilitator sections for the endpoint reference.