Skip to content

Paying for a call

Superspice endpoints are standard x402 (version 2) — any stock x402 client can pay them with no Superspice-specific code. If your framework speaks x402 (Coinbase’s SDKs and AgentKit do, among others), you can skip straight to pointing it at an endpoint.

A wallet on Base holding USDC. That’s all: payments are signed authorizations, so you don’t hold ETH or pay gas, and there’s no account, API key, or signup anywhere in the flow.

1. Request the endpoint.

Terminal window
curl -i https://gw.superspice.xyz/g/superspice-demo/api/data/price-feed

2. Read the terms. The response is 402 Payment Required. The body is empty ({}); the terms ride the payment-required response header as base64-encoded JSON: the exact amount in USDC base units (your fee-inclusive total — what you sign is what you pay), the asset and network, the payTo address, and a validity window. Full field-by-field breakdown: The 402 response.

3. Sign and retry. Your x402 client signs a USDC payment authorization for the quoted amount and retries the same request with the signed payload in the PAYMENT-SIGNATURE header (the legacy X-PAYMENT header is also accepted).

4. Get the response. Superspice verifies the payment, forwards the call to the seller’s origin, and delivers the response with a PAYMENT-RESPONSE header carrying your settlement receipt — including the on-chain transaction. End to end this takes about a second.

Settlement is delivery-gated: the money settles only after the response is delivered. If the seller’s origin fails, you aren’t charged. And if a payment settles but the response never reaches you (a dropped connection at the worst moment), re-send the same signed payment header shortly after: it acts as a receipt, and the gateway re-serves that delivery once without charging again (GET endpoints).

Per-call works fine forever, but if you’re calling an endpoint more than a handful of times, one payment funding many calls is faster and cheaper in round-trips — see Prepaid credit & sessions. On endpoints priced under $1 the first payment is a small prepaid bundle automatically, and the 402 tells you so up front.