What the agent does
From request to receipt, under a budget.
The agent makes the call and pays for it. The rules sit between every call and the money.
01
Request
The agent calls an endpoint priced with x402. The endpoint answers 402 with its price in USDC.
02
Rules
Cap per call, monthly cap and the approved endpoint are checked before anything is paid.
03
Payment
Inside the caps the call is paid in USDC and goes through. Above them it is refused and nothing is paid.
04
Receipt
Each paid call gets a signed receipt and a ledger entry, both in the audit trail.
Behind it
The parts that run it.
One call from the agent. Everything else is the platform: mandate, wallet, payment, receipt.
Sandbox run · demo data
Cookbook
Pay per call under a budget, in a few lines.
The consumer signs the mandate on the consent page; the agent makes one REST call per paid request. The same recipe runs in test mode with a test key.
- A test keyFrom the Dashboard. Test keys are free; nothing moves real money.
- A mandateCap per call, monthly cap and the approved endpoint. The Dashboard opens the consent page; the consumer signs it.
- A USDC funding sourceIn test mode the calls settle on Base Sepolia; mainnet is off by default.
// 1 · the consumer signed mnd_demo_cmp on the consent page: US$ 1.00 per call, US$ 20.00 a month, one endpointimport { CodeSpar } from "@codespar/sdk";const cs = new CodeSpar(); // 2 · pay for one call to the x402-priced endpoint, at most the per-call capconst res = await cs.api.response("post", "/v1/consumers/mandates/{id}/spend", { path: { id: "mnd_demo_cmp" }, body: { amount_minor: 100, payee: "https://inference.example/v1/summarize", attempt_id: "call_0001" },}); // 3 · inside the caps: paid in USDC, receipt signed · above them: refused, nothing paidif (res.ok) console.log(res.data.receipt?.id, res.data.payment.amountMinor); // rcpt_… 40else console.log(res.status); // 422Sandbox run · demo data