AgnicPay

X402 Payments

X402 payment signing and proxying

Transparent X402 Payment Proxy

Fetch any URL with automatic X402 payment handling. If the target URL returns a 402 Payment Required response, AgnicPay automatically signs the payment and retries the request. You get the actual API response back.

This is the recommended endpoint for most use cases.

POST
/api/x402/fetch

Authorization

X-Agnic-Token<token>

API token from your dashboard

In: header

Authorization
Required
Bearer <token>

OAuth2 access token

In: header

Request Body

application/jsonOptional

Request body to forward to the target URL

[key: string]any

Query Parameters

url
Required
string

Target URL to fetch

Format: "uri"
methodstring

HTTP method to use

Default: "GET"Value in: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"
maxValueinteger

Maximum payment in atomic units (e.g., 100000 = $0.10 USDC)

timeoutinteger

Request timeout in milliseconds

Default: 30000Maximum: 60000
curl -X POST "https://api.agnic.ai/api/x402/fetch?url=http%3A%2F%2Fexample.com&method=GET&maxValue=0&timeout=30000" \
  -H "X-Agnic-Token: <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Generate a summary"
  }'

Successful response from target URL

{}

Sign X402 Payment Proof

Sign an X402 payment proof for manual payment handling. Supports both "exact" (EIP-3009 TransferWithAuthorization) and "upto" (EIP-2612 Permit) payment schemes.

The easiest approach is to pass the full 402 response from the X402 API directly as the paymentRequirements field.

POST
/api/sign-payment

Authorization

X-Agnic-Token<token>

API token from your dashboard

In: header

Authorization
Required
Bearer <token>

OAuth2 access token

In: header

Request Body

application/jsonRequired
paymentRequirements
Required
object

Full 402 response from X402 API or manual payment requirements

requestData
Required
object
curl -X POST "https://api.agnic.ai/api/sign-payment" \
  -H "X-Agnic-Token: <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "paymentRequirements": {
      "accepts": [
        {
          "scheme": "exact",
          "network": "base-sepolia",
          "maxAmountRequired": "250000",
          "maxTimeoutSeconds": 300,
          "resource": "https://api.example.com/endpoint",
          "description": "Payment for API access",
          "mimeType": "application/json",
          "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
          "payTo": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb7",
          "extra": {
            "name": "USD Coin",
            "version": "2"
          }
        }
      ]
    },
    "requestData": {
      "url": "https://api.example.com/endpoint",
      "method": "POST"
    }
  }'

Payment signed successfully

{
  "success": true,
  "paymentHeader": "string",
  "paymentProof": {},
  "amountPaid": 0,
  "network": "string",
  "userWallet": "string",
  "signingWallet": "string",
  "scheme": "exact",
  "paidFromCredit": true
}