Skip to main content
POST
x402 Pay
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

string
required
Target API URL. Max 2048 characters.
string
default:"GET"
HTTP method for the request. One of GET, POST, PUT, DELETE.
object
Additional HTTP headers to include in the request to the target API.
string
Request body for POST or PUT requests.
integer
required
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

integer
required
HTTP status code returned by the target API.
object
required
Response headers from the target API.
string
required
Response body from the target API.
integer
required
Actual micro-USDC charged. 0 if the target API did not require payment.
integer
required
Platform fee in micro-USDC.
string | null
required
On-chain settlement transaction hash. null if no payment was required.
boolean
required
Whether the payment was settled on-chain.

How It Works

  1. The backend makes the initial request to the target URL.
  2. If the API returns HTTP 402 Payment Required, the response body contains the x402 payment requirements.
  3. The backend signs an EIP-3009 USDC authorization using the project’s x402 wallet key.
  4. The request is retried with an X-PAYMENT header containing the signed payment.
  5. The x402 facilitator verifies and settles the payment on-chain.
  6. The API response is returned to the agent.
  7. 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

Response (200 OK)

Errors

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.