x402 API
API documentation for x402 autonomous payment integration (USD top-ups on Base)
Overview
x402 credit purchases use open HTTP endpoints (no API key). Agents buy execution balance with USDC on Base. Users can also top up from thirdfy.com/credits or Thirdfy Console.
Narrative guide: x402 for outside agents. One-file HTTP spec: llms-full.txt.
Discovery Endpoint
Returns active top-up SKUs from x402_skus with USD labels (topup_usd_10, topup_usd_25, topup_usd_50, and custom bounds).
Purchase Endpoint
Or custom amount:
Legacy credits_* SKUs are retired. Use topup_usd_* only.
Payment Flow (default v2 facilitator)
Step 1: Receive the challenge
The first POST with a valid sku or usdAmount and no payment proof returns HTTP 402.
Read the PAYMENT-REQUIRED response header (base64-encoded JSON). It includes x402 v2 accepts[] with:
network:eip155:8453amount: USDC base units (6 decimals)payTo: Thirdfy payment wallet
Step 2: Sign EIP-3009
Sign TransferWithAuthorization for USDC on Base using the advertised amount and payTo.
Step 3: Retry with payment signature
On success the API returns HTTP 200 and a PAYMENT-RESPONSE header with settlement details.
Legacy fallback (txHash claim)
Use when your wallet cannot sign EIP-3009 (some autonomous agent runtimes).
- Request a challenge for the selected SKU (do not rely on an empty body to pick an amount).
- Send a direct USDC transfer on Base to
payTo. - Retry with the transaction hash:
If the transaction is not indexed yet, the API may return 202 PAYMENT_SETTLEMENT_PENDING. Retry with the same txHash.
Payment Details
- Currency: USDC on Base
- Network: Base (Chain ID 8453)
- Display: Users see USD balance; credits are the internal ledger unit
- Fees: No protocol fees on the listed top-up price
Error codes (common)
| HTTP | error | Meaning |
|---|---|---|
| 402 | PAYMENT_REQUIRED | Send payment proof |
| 404 | SKU_NOT_FOUND | Unknown or inactive SKU |
| 400 | INVALID_SKU_FORMAT | SKU must be topup_usd_* |
| 400 | PAYER_ADDRESS_MISMATCH | Wallet does not match payer |
| 400 | PAYMENT_ALREADY_CLAIMED | Proof already used for another user |
| 202 | PAYMENT_SETTLEMENT_PENDING | txHash not indexed; retry |