This endpoint is deprecated. Use POST /v1/pay with a URL recipient instead.
Proxies an HTTP request to a target API. If the API returns HTTP 402 Payment Required, the backend automatically signs an EIP-3009 USDC authorization, retries the request with the x402 payment header, and returns the API response.
Requires a bearer token with the x402 permission.
Request Body
Target API URL. Max 2048 characters.
HTTP method for the request. One of GET, POST, PUT, DELETE.
Additional HTTP headers to include in the request to the target API.
Request body for POST or PUT requests.
Maximum micro-USDC to pay (safety cap). 1 USDC = 1,000,000 micro-USDC. Must be greater than 0 and at most 100,000,000 (100 USDC).
Response
HTTP status code returned by the target API.
Response headers from the target API.
Response body from the target API.
Actual micro-USDC charged. 0 if the target API did not require payment.
Platform fee in micro-USDC.
On-chain settlement transaction hash. null if no payment was required.
Whether the payment was settled on-chain.
How It Works
- The backend makes the initial request to the target URL.
- If the API returns
HTTP 402 Payment Required, the response body contains the x402 payment requirements.
- The backend signs an EIP-3009 USDC authorization using the project’s x402 wallet key.
- The request is retried with an
X-PAYMENT header containing the signed payment.
- The x402 facilitator verifies and settles the payment on-chain.
- The API response is returned to the agent.
- The USDC amount and platform fee are recorded in the project’s ledger.
If the target API does not return 402 (returns 200 directly), the response is passed through without any payment.
Examples
curl -X POST https://api.unwall.xyz/v1/x402/pay \
-H "Authorization: Bearer aw_live_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"url": "https://api.example.com/v1/premium-data",
"method": "GET",
"max_amount_usdc": 500000
}'
{
"status_code": 200,
"headers": {
"content-type": "application/json"
},
"body": "{\"data\": [{\"id\": 1, \"value\": \"premium result\"}]}",
"payment_amount": 100000,
"fee_amount": 1500,
"tx_hash": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef1234567890abcdef1234567890",
"settled": true
}
Errors
| Status | Cause |
|---|
400 | max_amount_usdc exceeded by the API’s payment requirement |
400 | Insufficient USDC balance |
403 | Token lacks x402 permission |
502 | Target API or x402 facilitator returned an error |
The max_amount_usdc is a safety cap. If the target API requests more USDC than your max, the payment is rejected and the request fails with a 400 error. Always set a reasonable max for the API you are calling.