Pay-per-call APIs for autonomous agents.
No account. No checkout. No API key dance. Your agent hits a gated endpoint, receives a 402 Payment Required, signs a USDC payment on Solana, and retries. That's the entire integration.
No account, ever
Agents can't sign up for a SaaS dashboard. With x402 the payment is the auth — nothing to register.
One line of code
Wrap fetch with an x402 client. The 402 → pay → retry loop resolves automatically; your code sees a 200.
Stablecoin native
Settled in USDC on Solana — fast, cheap, deterministic finality built for high-frequency machine commerce.
The 402 handshake
Five steps. We handle the middle three.
- 01
Agent requests a gated endpoint with no payment.
- 02
theopay.xyz returns 402 + amount, asset, chain & payTo.
- 03
Agent signs a USDC payment on Solana.
- 04
We verify the payment on-chain.
- 05
We forward to origin and return the response.
# 1. Fetch an X post through a gated endpoint, no payment
curl -i "https://theopay.xyz/x/fetch-x-post?id=1789012345678901234"
HTTP/1.1 402 Payment Required
Content-Type: application/json
{
"x402": {
"amount": "1000", // 0.001 USDC (6 decimals)
"asset": "USDC",
"chain": "solana",
"payTo": "Theo…TreasuryAddr",
"resource": "/x/fetch-x-post"
}
}# 2. Pay, then retry with the payment-authorization header
curl -i "https://theopay.xyz/x/fetch-x-post?id=1789012345678901234" \
-H "X-PAYMENT: <signed-solana-payment-authorization>"
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "1789012345678901234",
"author": "@levelsio",
"text": "shipped a new feature today 🚀",
"likes": 4210,
"created_at": "2026-06-15T09:12:00Z"
}One-line integration
Wrap fetch. Done.
Use any x402-aware client. It intercepts the 402, signs the payment with your agent's wallet, and retries transparently — so your code just sees a normal 200.
No wallet yet? theopay.xyz can provision an embedded Solana wallet tied to your operator account.
Full protocol docsimport { wrapFetchWithPayment } from "x402-fetch";
import { createSolanaWallet } from "x402-fetch/solana";
// Your agent's wallet (or one provisioned for it).
const wallet = createSolanaWallet(process.env.AGENT_SOLANA_KEY!);
// Drop-in fetch that auto-resolves 402s: pays, then retries.
const fetchWithPay = wrapFetchWithPayment(fetch, wallet);
const res = await fetchWithPay(
"https://theopay.xyz/x/fetch-x-post?id=1789012345678901234"
);
const post = await res.json(); // → { author: "@levelsio", text: "…", … }$ Pricing, headers, and facilitator details follow the Coinbase x402 spec. Always verify against the current x402 documentation — package names and the exact handshake evolve.
