Agnic
API Reference

X402 Payments

X402 payment signing and proxying

POST/api/x402/fetch

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.**
Auth:ApiTokenOAuth2

query parameters

NameTypeDescription
url*string<uri>Target URL to fetch
example: "https://api.example.com/data"
method"GET" | "POST" | "PUT" | "DELETE" | "PATCH"
default: "GET"
HTTP method to use
maxValueintegerMaximum payment in atomic units (e.g., 100000 = $0.10 USDC)
example: 100000
timeoutinteger
default: 30000
Request timeout in milliseconds

Request body

Request body to forward to the target URL

object
Example request
{
  "prompt": "Generate a summary"
}

Responses

200Successful response from target URL
object
400Bad request
FieldTypeDescription
errorstring
error_descriptionstring
messagestring
401Unauthorized - invalid or missing authentication
object — circular
402Payment required but exceeded maxValue limit
object — circular
500Internal server error
object — circular

Example (cURL)

curl -X POST 'https://api.agnic.ai/api/x402/fetch?url=https%3A%2F%2Fapi.example.com%2Fdata' \
  -H 'X-Agnic-Token: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"Generate a summary"}'
POST/api/sign-payment

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.
Auth:ApiTokenOAuth2

Request body *

FieldTypeDescription
paymentRequirements*object
Full 402 response from X402 API or manual payment requirements
show nested schema
FieldTypeDescription
acceptsobject[]
show nested schema
array of
FieldTypeDescription
scheme"exact" | "upto"
network"base" | "base-sepolia" | "solana" | "solana-devnet"
maxAmountRequiredstring
Amount in atomic units
maxTimeoutSecondsinteger
resourcestring<uri>
descriptionstring
mimeTypestring
assetstring
USDC contract/mint address
payTostring
Recipient wallet address
extraobject
requestData*object
show nested schema
FieldTypeDescription
url*string<uri>
methodstring
Example request
{
  "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"
  }
}

Responses

200Payment signed successfully
FieldTypeDescription
successboolean
paymentHeaderstring
Base64-encoded X402 payment proof for X-Payment header
paymentProofobject
Decoded payment object for inspection
show nested schema
object — Decoded payment object for inspection
amountPaidnumber
Amount in USD
networkstring
userWalletstring
signingWalletstring
scheme"exact" | "upto"
paidFromCreditboolean
400Bad request
FieldTypeDescription
errorstring
error_descriptionstring
messagestring
401Unauthorized - invalid or missing authentication
object — circular
402Payment exceeds spending limits
object — circular

Example (cURL)

curl -X POST 'https://api.agnic.ai/api/sign-payment' \
  -H 'X-Agnic-Token: YOUR_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"}}'