x402 Primitives Catalog
The full-stack pay-per-call API for crypto infrastructure. Every endpoint is x402-native — agents and developers pay USDC per request on Base. No API keys, no accounts, no subscriptions.
// Install the x402 client npm install x402-client // Make a paid API call — payment is automatic import { createClient } from "x402-client"; const client = createClient({ baseUrl: "https://gateway.spraay.app", privateKey: process.env.EVM_PRIVATE_KEY, // Wallet with USDC on Base }); // Fetch live ETH price — pays $0.005 USDC automatically const prices = await client.get("/api/v1/prices"); console.log(prices); // { ETH: 2847.50, ... } // Batch send USDC to 50 wallets — pays $0.02 USDC const tx = await client.post("/api/v1/batch", { token: "USDC", recipients: [{ address: "0x...", amount: "10.00" }, /* ... */] });
Identity & Access
2 endpointsParameters
- wallet_address string — Address to verify
- level string — "basic" | "enhanced" | "kyb"
- chain string — Target chain (default: "base")
Example
const result = await client.post( "/api/v1/kyc/verify", { wallet_address: "0xAb5...", level: "basic" } ); // { verified: true, score: 92, // flags: [], expires: "2025-..." }
Parameters
- provider string — Service to authenticate with
- wallet_address string — Wallet for session binding
- ttl number — Session duration in seconds
Example
const session = await client.post( "/api/v1/auth/session", { provider: "github", wallet_address: "0xAb5...", ttl: 3600 } ); // { token: "ey...", expires_at: "..." }
Data & Intelligence
4 endpointsParameters
- tokens string[] — Token symbols (e.g. ["ETH","USDC"])
- vs_currency string — Quote currency (default: "usd")
- include_gas boolean — Include gas price estimates
Example
const data = await client.get( "/api/v1/prices?tokens=ETH,USDC" ); // { ETH: { usd: 2847.50, change_24h: 1.2 }, // USDC: { usd: 1.00 }, // gas: { base: "0.004 gwei" } }
Parameters
- address string — Wallet or ENS to analyze
- chain string — Chain to query (default: "base")
- depth string — "summary" | "full"
Example
const report = await client.get( "/api/v1/analytics?address=vitalik.eth" ); // { portfolio_value: "$1.2M", // risk_score: 12, tx_count: 4821 }
Parameters
- address string — Wallet address to index
- chains string[] — Chains to query
- type string — "balances" | "history" | "nfts"
Example
const history = await client.get( "/api/v1/index/query", { address: "0xAb5...", chains: ["base", "ethereum"], type: "history" } ); // { transactions: [...], total: 142 }
Parameters
- model string — Model ID (OpenAI-compatible)
- messages array — Chat messages array
- max_tokens number — Max response tokens
Example
const resp = await client.post( "/api/v1/ai/chat", { model: "anthropic/claude-sonnet", messages: [{ role: "user", content: "Classify this tx..." }] } ); // { response: "This appears to be..." }
Communication & Notification
3 endpointsParameters
- channel string — "email" | "sms"
- to string — Recipient address or phone
- subject string — Email subject line
- body string — Message body (text or HTML)
Example
await client.post("/api/v1/notify/send", { channel: "email", to: "[email protected]", subject: "Payroll Complete", body: "50 recipients paid via Spraay" }); // { sent: true, id: "msg_a1b2c3" }
Parameters
- url string — Your webhook endpoint URL
- events string[] — Events to subscribe to
- secret string — Signing secret for verification
Example
await client.post("/api/v1/webhook/register", { url: "https://myapp.com/hooks", events: ["batch.complete"], secret: "whsec_..." }); // { id: "wh_x9y8", active: true }
Parameters
- to string — Recipient wallet or ENS
- message string — Message content
- content_type string — "text" | "attachment"
Example
await client.post("/api/v1/xmtp/send", { to: "0xRecipient...", message: "Payment of 50 USDC sent", content_type: "text" }); // { sent: true, conversation_id: "..." }
Financial Primitives
5 endpointsParameters
- token string — Token symbol or address
- amount string — Amount to escrow
- recipient string — Recipient address
- conditions object — Release conditions (milestone, time-lock)
Example
const escrow = await client.post( "/api/v1/escrow/create", { token: "USDC", amount: "5000", recipient: "0xFreelancer...", conditions: { type: "milestone", deadline: "2025-04-01" } } ); // { escrow_id: "esc_...", tx: "0x..." }
Parameters
- from string — Input token symbol
- to string — Output token
- amount string — Input amount
- slippage number — Max slippage % (default: 0.5)
Example
const quote = await client.get( "/api/v1/swap/quote?from=USDC&to=WETH&amount=100" ); // { amountOut: "0.0351", // route: "USDC→WETH", // priceImpact: "0.02%" }
Parameters
- from_chain string — Source chain
- to_chain string — Destination chain
- token string — Token to bridge
- amount string — Amount
Example
const bridge = await client.post( "/api/v1/bridge/transfer", { from_chain: "base", to_chain: "arbitrum", token: "USDC", amount: "1000" } ); // { bridge_id: "br_...", eta: "~2 min" }
Parameters
- name string — Payroll run name
- token string — Payment token
- employees array — [{address, amount, memo}]
- schedule string — "once" | "weekly" | "monthly"
Example
const run = await client.post( "/api/v1/payroll/run", { name: "March 2025", token: "USDC", employees: [ { address: "0x...", amount: "3500" }, { address: "0x...", amount: "4200" } ] } ); // { payroll_id: "pr_...", tx: "0x..." }
Parameters
- to string — Client wallet or email
- items array — Line items [{desc, amount}]
- token string — Accepted payment token
- due_date string — Payment deadline
Example
const inv = await client.post( "/api/v1/invoice/create", { to: "[email protected]", items: [{ desc: "Dev work", amount: "2500" }], token: "USDC", due_date: "2025-04-15" } ); // { invoice_id: "inv_...", // pay_link: "https://..." }
Infrastructure & DevOps
4 endpointsParameters
- chain string — Target chain
- method string — JSON-RPC method
- params array — Method parameters
Example
const block = await client.post( "/api/v1/rpc", { chain: "base", method: "eth_blockNumber", params: [] } ); // { result: "0x1a2b3c" }
Parameters
- content string|object — Content to pin
- name string — Pin name/label
- backend string — "ipfs" | "arweave"
Example
const pin = await client.post( "/api/v1/storage/pin", { content: { receipt: "...", tx: "0x..." }, name: "payroll-receipt-march", backend: "ipfs" } ); // { cid: "Qm...", url: "https://..." }
Parameters
- cron string — Cron expression
- action object — API call to execute
- max_runs number — Max executions (0 = unlimited)
Example
await client.post("/api/v1/cron/schedule", { cron: "0 9 1 * *", // 1st of month action: { endpoint: "/api/v1/payroll/run", body: { name: "Monthly" } }, max_runs: 12 }); // { job_id: "cron_...", next: "..." }
Parameters
- action string — "ingest" | "query"
- entries array — Log entries to store
- filter object — Query filters
Example
await client.post("/api/v1/logs", { action: "ingest", entries: [{ level: "info", msg: "Batch sent to 50 recipients", tx: "0x..." }] }); // { stored: 1, id: "log_..." }
GPU / Compute
3 endpointsParameters
- model string — Shortcut (flux-pro, llama-70b, whisper) or full ID
- input object — Model-specific inputs
- version string? — Specific model version (optional)
- webhook string? — Async result delivery URL
Example
const img = await client.post( "/api/v1/gpu/run", { model: "flux-pro", input: { prompt: "a serene mountain lake" } } ); // { id: "abc123", status: "succeeded", // output: ["https://replicate.delivery/..."] }
Parameters
- id string — Prediction ID from /gpu/run
Example
const status = await client.get( "/api/v1/gpu/status/abc123xyz" ); // { id: "abc123xyz", status: "succeeded", // output: [...], metrics: { predict_time: 4.2 } }
No parameters required
Example
const models = await client.get( "/api/v1/gpu/models" ); // { total: 13, categories: { // image: [{ shortcut: "flux-pro", ... }], // video: [...], llm: [...], ... } }
Search / RAG
3 endpointsParameters
- query string — Search query
- search_depth string? — "basic" (default) or "advanced"
- max_results number? — 1-20 (default: 5)
- topic string? — "general" | "news" | "finance"
Example
const results = await client.post( "/api/v1/search/web", { query: "x402 protocol ecosystem", search_depth: "basic", max_results: 5 } ); // { answer: "x402 is an open...", // results: [{ title, url, content }] }
Parameters
- urls string[] — 1-5 URLs to extract content from
Example
const content = await client.post( "/api/v1/search/extract", { urls: ["https://docs.base.org/overview"] } ); // { results: [{ url: "...", // content: "Base is a secure..." }] }
Parameters
- query string — Natural language question
- topic string? — "general" | "news" | "finance"
Example
const answer = await client.post( "/api/v1/search/qna", { query: "What is x402 protocol?" } ); // { answer: "x402 is an open standard...", // sources: [{ title, url, score }] }
Robotics / RTP
8 endpointsRobot Task Protocol (RTP) — the open standard for AI agents to discover, commission, and pay for physical robot tasks via x402. Proposed as an x402 extension in #1569.
Parameters
- name string — Human-readable device name
- capabilities string[] — e.g. ["pick", "place", "scan"]
- price_per_task string — USDC per task (e.g. "0.05")
- payment_address string — Operator wallet for payments
- connection object — {type: "webhook"|"xmtp"|"wifi"|"websocket", webhookUrl: "..."}
Example
const robot = await client.post( "/api/v1/robots/register", { name: "WarehouseBot-01", capabilities: ["pick", "place", "scan"], price_per_task: "0.05", payment_address: "0xYourWallet", connection: { type: "webhook", webhookUrl: "https://yourserver.com/rtp/task" } } ); // { status: "registered", // robot_id: "robo_138fd1f8e0ee51a", // rtp_uri: "rtp://gateway.spraay.app/robo_..." }
Parameters
- robot_id string — Target robot identifier
- task string — Capability verb: pick, place, scan, deliver, etc.
- parameters object — Task-specific params (e.g. {item, from_location})
- callback_url string? — URL to receive result on completion
- timeout_seconds number? — Max execution time (default: 60)
Example
const result = await client.post( "/api/v1/robots/task", { robot_id: "robo_138fd1f8e0ee51a", task: "pick", parameters: { item: "SKU-00421", from_location: "bin_A3" }, timeout_seconds: 60 } ); // { status: "DISPATCHED", // task_id: "task_xyz789", // escrow_id: "escrow_001" }
Parameters
- task_id string — Task identifier from dispatch
- status string — "COMPLETED" | "FAILED"
- result object — {success, output, data, error}
Example
await client.post( "/api/v1/robots/complete", { task_id: "task_xyz789", status: "COMPLETED", result: { success: true, output: "Picked SKU-00421 from bin_A3" } } ); // { task_id: "task_xyz789", // status: "COMPLETED", escrow: "released" }
Parameters
- capability string? — Filter by verb: pick, scan, deliver, etc.
- chain string? — Payment chain (default: base)
- max_price string? — Max USDC per task
- status string? — "online" | "offline" | "busy"
Example
const robots = await client.get( "/api/v1/robots/list?capability=pick&max_price=0.10" ); // { robots: [{ robot_id: "robo_...", // name: "WarehouseBot-01", // capabilities: ["pick","place","scan"], // price_per_task: "0.05" }], total: 1 }
Parameters
- task_id string — Task identifier to check
Example
const status = await client.get( "/api/v1/robots/status?task_id=task_xyz789" ); // { task_id: "task_xyz789", // status: "COMPLETED", // result: { success: true, output: "..." } }
Parameters
- robot_id string — Robot identifier
Example
const profile = await client.get( "/api/v1/robots/profile?robot_id=robo_138fd1f8e0ee51a" ); // { robot_id: "robo_...", name: "WarehouseBot-01", // capabilities: ["pick","place","scan"], // price_per_task: "0.05", status: "online", // rtp_uri: "rtp://gateway.spraay.app/robo_..." }
Parameters
- robot_id string — Robot identifier (required)
- name string? — Updated name
- capabilities string[]? — Updated capability list
- price_per_task string? — Updated USDC price
- connection object? — Updated connection config
- status string? — "online" | "offline" | "maintenance"
Example
const updated = await client.patch( "/api/v1/robots/update", { robot_id: "robo_138fd1f8e0ee51a", price_per_task: "0.08", capabilities: ["pick", "place", "scan", "deliver"] } ); // { status: "updated", // robot_id: "robo_138fd1f8e0ee51a", // updated_fields: ["price_per_task", "capabilities"] }
Parameters
- robot_id string — Robot identifier to remove
Example
await client.post( "/api/v1/robots/deregister", { robot_id: "robo_138fd1f8e0ee51a" } ); // { status: "deregistered", // robot_id: "robo_138fd1f8e0ee51a", // name: "WarehouseBot-01" }
Compliance & Audit
2 endpointsParameters
- wallet string — Wallet to audit
- from string — Start date (ISO 8601)
- to string — End date
- format string — "json" | "csv" | "pdf"
Example
const report = await client.get( "/api/v1/audit/query", { wallet: "0xTreasury...", from: "2025-01-01", to: "2025-03-31", format: "csv" } ); // Returns CSV of all batch payments // with tx hashes, timestamps, amounts
Parameters
- wallet string — Wallet address
- tax_year number — Tax year
- jurisdiction string — "US" | "UK" | "EU"
- method string — "fifo" | "lifo" | "hifo"
Example
const taxes = await client.post( "/api/v1/tax/calculate", { wallet: "0x...", tax_year: 2025, jurisdiction: "US", method: "fifo" } ); // { gains: { short: "$420", // long: "$1200" }, events: 84 }
Agent Wallet
5 endpointsSmart contract wallet provisioning for AI agents on Base. Forked from Abstract Global Wallet — factory-deployed minimal proxies with session keys, spending limits, and time-bound permissions.
Parameters
- agentId string — Unique agent identifier
- agentType string — Framework: "langchain" | "eliza" | "crewai" | "custom"
- mode string — "managed" (server generates key) | "self-custody" (provide ownerAddress)
- ownerAddress string — Required for self-custody mode
Example
// Provision a managed wallet for a LangChain agent const wallet = await spraay.agentWallet.provision({ agentId: "trading-bot-007", agentType: "langchain", mode: "managed" }); // { walletAddress: "0x...", chainId: 8453, // encryptedKey: "base64...", txHash: "0x..." }
Parameters
- walletAddress string — Agent wallet contract address
- sessionKeyAddress string — Address to authorize as session key
- spendLimitEth string — Max ETH the session key can spend
- durationHours number — Hours until session key expires
- allowedTargets string[] — Whitelisted contract addresses (optional)
Example
// Add a session key: 0.5 ETH limit, 24 hours const session = await spraay.agentWallet.addSessionKey({ walletAddress: "0xWallet...", sessionKeyAddress: "0xSigner...", spendLimitEth: "0.5", durationHours: 24, allowedTargets: ["0xBatchContract"] }); // { txHash: "0x...", expiresAt: "2026-03-21T..." }
Parameters
- address string — Agent wallet contract address
Example
const info = await spraay.agentWallet.info({ address: "0xWallet..." }); // { balanceEth: "0.42", agentId: "trading-bot-007", // agentType: "langchain", sessionKeys: [...] }
Parameters
- walletAddress string — Agent wallet contract address
- sessionKeyAddress string — Session key to revoke
Parameters
- ownerAddress string — Wallet owner address
- agentId string — Agent identifier for salt generation
XRP Ledger
3 endpointsParameters
- recipients array — Array of { address, amount } objects (r-addresses)
- token string — "XRP" (default, native drops conversion handled)
- sender_secret string — Sender's secret key for signing
Example
const result = await client.post( "/api/v1/xrpl/batch", { recipients: [ { address: "rN7n3...", amount: "10" }, { address: "rK4x2...", amount: "25" }, { address: "rP9m7...", amount: "15" } ] } ); // { success: true, tx_count: 3, // hashes: ["A1B2C3...", ...], // total_sent: "50 XRP" }
Parameters
- recipients array — Array of { address, amount } objects
- token string — "XRP" (default)
Example
const est = await client.post( "/api/v1/xrpl/batch/estimate", { recipients: [ { address: "rN7n3...", amount: "10" } ] } ); // { valid: true, tx_count: 1, // estimated_fee: "0.000012 XRP", // total_amount: "10 XRP" }
Parameters
- — No parameters required
Example
const info = await client.get( "/api/v1/xrpl/batch/info" ); // { chain: "xrpl", chain_id: 15, // fee_address: "rpyynY82uCC...", // features: ["batch", "estimate"], // method: "sequential_payments", // sdk: "xrpl.js" }
Stellar
4 endpointsParameters
- recipients array — Array of { address, amount } (G-addresses, up to 100)
- token string — "XLM", "USDC", "EURC", or asset code
- asset_issuer string — Issuer address (required for non-XLM assets)
- sender_secret string — Sender's Stellar secret key
- memo string — Optional transaction memo
Example
const result = await client.post( "/api/v1/stellar/batch", { token: "XLM", recipients: [ { address: "GCXK...", amount: "100" }, { address: "GDPJ...", amount: "250" }, { address: "GBWQ...", amount: "75" } ], memo: "Q1 payroll" } ); // { success: true, tx_hash: "a4f8...", // recipients_paid: 3, // total_sent: "425 XLM", // fee: "0.00003 XLM" }
Parameters
- recipients array — Array of { address, amount } objects
- token string — Asset code ("XLM", "USDC", etc.)
- asset_issuer string — Issuer for non-XLM assets
Example
const est = await client.post( "/api/v1/stellar/batch/estimate", { token: "USDC", asset_issuer: "GA5ZS...", recipients: [ { address: "GCXK...", amount: "100" } ] } ); // { valid: true, ops_count: 1, // tx_count: 1, fee: "0.00001 XLM", // trustline_issues: [] }
Parameters
- — No parameters required
Example
const info = await client.get( "/api/v1/stellar/batch/info" ); // { chain: "stellar", chain_id: 16, // max_ops_per_tx: 100, // method: "multi_operation_tx", // supported_assets: ["XLM","USDC","EURC"], // sdk: "@stellar/stellar-sdk", // finality: "~5 seconds" }
Parameters
- recipients array — Array of { address, amount, dest_asset } objects
- send_asset string — Asset to send ("XLM" default)
- max_slippage number — Max slippage percentage (default: 1%)
- sender_secret string — Sender's Stellar secret key
Example
const result = await client.post( "/api/v1/stellar/path-batch", { send_asset: "XLM", recipients: [ { address: "GCXK...", amount: "50", dest_asset: "USDC" }, { address: "GDPJ...", amount: "100", dest_asset: "USDC" } ], max_slippage: 1.5 } ); // { success: true, tx_hash: "b7c9...", // paths_used: 2, // total_xlm_spent: "1250.45 XLM", // total_usdc_received: "150.00 USDC" }
Connect via
MCP Server
60 tools for Claude Desktop, Cursor, Cline. Install from Smithery.
Coinbase AgentKit
Batch send action for any AgentKit-powered AI agent. PR #944.
Direct x402 Gateway
Hit endpoints directly with any x402 client. USDC on Base.
SDKs & Libraries
TypeScript SDK, Solana SDK, Python CLI. Open source on GitHub.
RTP Spec
Robot Task Protocol v1.0 — open standard for AI agents hiring robots via x402.