x402 Protocol
The x402 protocol uses HTTP 402 Payment Required as a machine-to-machine payment mechanism. APIs that support x402 return a 402 response with payment requirements instead of requiring API keys or subscriptions. Unwall handles the entire payment flow — your agent just makes a request and gets data back.What Is x402?
Traditional API monetization requires signing up, generating API keys, and managing subscriptions. x402 replaces all of that with a single HTTP flow:- Client requests data from an API.
- API returns
402 Payment Requiredwith the price and payment address. - Client signs a USDC payment and retries the request.
- API verifies payment on-chain and returns the data.
How It Works
Your agent calls POST /v1/pay with a URL recipient
The agent provides the target API URL and a
max_amount_usdc safety cap.Unwall proxies the request to the target API
The initial request is sent to the URL exactly as if your agent called it directly.
If HTTP 402 is returned, Unwall parses the payment requirements
The 402 response contains the price, payment address, and token details in a structured format.
Unwall signs a USDC authorization
Using its platform signing key, Unwall creates an EIP-3009
transferWithAuthorization signature for the required USDC amount.The request is retried with the payment header
The original request is sent again with an
X-PAYMENT header containing the signed authorization.Safety Cap
Always setmax_amount_usdc to limit how much your agent can spend on a single x402 call. If the API’s price exceeds this cap, the payment is rejected and the request fails with an error — no funds are spent.
When No 402 Is Returned
If the target API responds with a normal HTTP response (200, 301, etc.) instead of 402, the response is passed through directly to your agent at no charge. No USDC is spent and no fee is applied. This means you can safely point the x402 endpoint at any URL. If the API does not use the x402 protocol, it works as a simple proxy.Code Examples
Response
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
recipient | string | Yes | Target API URL (must start with https://) |
max_amount_usdc | integer | Yes | Maximum USDC to pay in micro-USDC (1 USDC = 1,000,000) |
method | string | No | HTTP method: GET, POST, PUT, DELETE. Default: GET |
headers | object | No | Additional headers to forward to the target API |
body | string | No | Request body for POST/PUT requests |
description | string | No | Human-readable description for the transaction ledger |
idempotency_key | string | No | Unique key to prevent duplicate payments |
Fee
The tier-based platform fee applies on successful x402 payments:| Plan | Fee Rate |
|---|---|
| Free | 2% |
| Pro | 1.5% |
| Business | 1% |
PLATFORM_FEE transaction in the ledger.
Required Permission
Your API token must have thex402 permission to make x402 payments. Tokens with only pay permission cannot use the x402 rail.