# x402 Payments

## Payments for AI agents and apps, both sides of the transaction

x402 lets software pay for HTTP APIs in stablecoin using the standard `402 Payment Required` response. Crypto APIs runs both halves as a managed, **non-custodial** service: your keys never leave your side — the client signs every payment locally, and the Crypto APIs facilitator settles it on-chain.

Give your agent a wallet and let it pay a 402-gated endpoint automatically, or add a per-request paywall to your own API in a few lines. Payments settle in USDC across supported networks, with spending guardrails on the buyer side and on-chain settlement on the merchant side.

- Non-custodial — sign locally
- Settles in USDC on-chain
- Buyer & merchant SDKs

## One protocol, both sides of the payment

Whether your software needs to pay for an API or charge for one, x402 handles it — non-custodially, with the Crypto APIs facilitator settling on-chain.

### Buy — pay for x402 endpoints

Give an agent or app a managed wallet and let it pay a 402-gated endpoint automatically. Your client authorizes the payment, signs it locally with its own key, and retries — Crypto APIs never holds the key.

- Register an agent wallet and authorize payments via one API
- Sign locally (EIP-712) — non-custodial, no `/sign` endpoint
- Per-transaction, daily and monthly spending limits
- Use the buyer SDK, the `x402_pay` MCP tool, or the agent plugin

### Sell — charge for your API

Add a per-request paywall to your API in a few lines. When an unpaid call arrives, your endpoint answers with a 402 challenge; the Crypto APIs facilitator verifies the buyer's signed payment and settles it on-chain with its own gas wallet — non-custodially.

- Drop-in middleware for Express, Hono and Next.js
- Verify and settle payments on-chain, per request
- Set your own price per endpoint, paid in USDC
- Zero-dependency, non-custodial merchant SDK

## Pay a 402 in one call

Point the `x402_pay` MCP tool (or the buyer SDK) at a paid endpoint and it fetches, pays the 402 automatically by signing locally, and returns the paid response.

```bash
# Install the buyer MCP server / SDK
npm i -g @cryptoapis-io/mcp-x402-pay

# Set your buyer credentials (kept out of logs)
export CRYPTOAPIS_API_KEY="…"
export X402_WALLET_ID="…"      # wallet record id from POST /wallets
export X402_PRIVATE_KEY="0x…"  # signs locally, never sent

# Now an agent can just: "fetch https://api.example.com/premium"
# → on 402, it authorizes, signs locally, retries, returns the paid data + tx
```

## Frequently asked questions

### What is x402?

x402 is an open protocol for paying for HTTP APIs with stablecoin, using the standard 402 Payment Required response. Crypto APIs runs both halves as a managed service: the buyer side (an agent or app pays a 402-gated endpoint) and the facilitator side (verifying and settling those payments on-chain).

### Is x402 on Crypto APIs custodial?

No. x402 on Crypto APIs is fully non-custodial. The buyer holds its own key and signs every payment locally; there is no `/sign` endpoint. The facilitator settles with its own gas wallet and can never move funds the buyer did not authorize.

### Which blockchains and assets does x402 support?

x402 payments settle in USDC stablecoin. The live networks are published per family by the merchant supported-assets endpoint; EVM networks such as Base are supported, with additional families rolling out.

## Related

- [/products/ai-compatibility](/products/ai-compatibility) — MCP servers and an n8n MCP client for AI agents.
- [x402 overview](https://developers.cryptoapis.io/v-2.2024-12-12-175/RESTapis/x402/x402-overview) — concepts and the non-custodial model in the developer docs.
- [x402 Buyer API reference](https://developers.cryptoapis.io/v-2.2024-12-12-175/RESTapis/x402/x402-buyer) — wallets, authorize, spending limits.
- [x402 Merchant & Facilitator API reference](https://developers.cryptoapis.io/v-2.2024-12-12-175/RESTapis/x402/x402-merchant-facilitator) — verify, settle, supported assets.
- [x402 SDKs & Tooling](https://developers.cryptoapis.io/v-2.2024-12-12-175/RESTapis/x402/x402-sdks-tooling) — buyer SDK, merchant SDK, MCP tool, offline signer.
- [Developer portal](https://developers.cryptoapis.io/) — full REST API reference.
