Handbooks  /  Agentic Payments
Handbook~14 min readAgentsworked math + runnable code
Handbook

Agentic
payments.

An agent that can browse and call tools eventually hits a paywall — an API that costs a cent a call, a dataset behind a charge, a compute job to rent. Stopping to ask a human defeats the point of autonomy; handing the agent your card defeats your bank balance. The answer is a machine-native checkout (x402) plus a signed mandate that says exactly how much this agent may spend, on what, before it can spend a cent. This handbook is how those rails work — and how to keep a looping agent from spending your month's budget in a minute.

01

The 402 revival: a checkout for machines

HTTP has always had a status code reserved for this: 402 Payment Required, dormant since the 1990s. x402 finally uses it. An agent requests a resource; the server replies 402 with payment terms (amount, address, token). The agent pays — typically a tiny stablecoin transfer — and retries the request carrying proof of payment. This time it gets 200 and the resource.

x402 — pay inside the request/response loop
GET /data
402
price + terms
pay + retry
proof attached
200 + data

No checkout page, no human. Payment becomes just another part of the protocol — which is exactly what an autonomous agent needs. But a checkout an agent can drive is also a checkout a hijacked agent can drive. That's why x402 is only half the story; the other half is the authority the agent carries into it.

02

Mandates: OAuth scopes, but for money

You don't hand the agent your wallet — you hand it a mandate: a signed authorization that scopes what it may spend. Just as an OAuth token grants "read your email but not send," a payment mandate grants "spend up to $20 a transaction, $50 total, only at these merchants, until Friday." Protocols like AP2 standardize these mandates so any agent and any merchant can speak the same authorization language.

mandate = { per_txn_max, max_total, allowed_merchants, expiry }  ·  signed, not guessable

The agent acts freely inside the mandate and is refused outside it. Authority is delegated, bounded, and revocable — the model never holds unlimited spending power.

The key idea

Don't trust the agent to spend wisely — bound what "spend" can even mean. The mandate turns "please don't overspend" (a hope) into "cannot overspend" (an invariant enforced by the payment layer).

03

Spend caps: enforce before you execute

The mandate is only as good as the check. Before every payment, the payment layer verifies three things against the mandate: is the amount within the per-transaction ceiling, does it keep cumulative spend under the total budget, and is the merchant in scope? All three must pass, or the payment is refused before any money moves.

authorize ⟺ amount ≤ per_txn_max  AND  spent+amount ≤ max_total  AND  merchant ∈ allowed

This is least privilege applied to money: the agent's spending power is the narrowest set of payments that still lets it do its job. Everything else is denied by default.

Crucially, the check runs in the payment layer, not the prompt. You're not asking the model to respect a budget in its reasoning — you're making the budget a precondition it physically cannot bypass, the same way a sandbox enforces file access regardless of what code wants to do.

04

The runaway agent, contained

Here's the threat the caps exist for. A prompt-injected or looping agent decides to make a hundred payments — draining an account is exactly the kind of damage autonomy makes possible. With the mandate check in front of every payment, it can't. Cumulative spend climbs to the cap and then every further payment is refused; the loop spins but the money stops.

no caps: injected agent runs 100 payments → account drained
with mandate: spend hits max_total → every further payment refused → damage bounded to the cap you chose

The runnable enforcer below makes this concrete: point a "runaway" agent at a $50 mandate, watch it try to spend $200, and watch it get stopped cold at the ceiling. The final spend is bounded by max_total no matter how many times it tries.

05

The protocol landscape

Several protocols are converging on this shape, and it's early enough that they overlap. Broadly: x402 handles the machine-native settlement (the 402 flow and payment proof), AP2-style mandates handle the scoped authorization, and processor-led and wallet-led efforts add identity, dispute handling, and fiat bridges. Expect consolidation, but the primitives — a checkout an agent can drive, and a signed scope on what it may spend — are stable regardless of which brand wins.

The reported traction is real: the category has already moved into nine figures of transaction volume with major processors adopting agent-payment rails. For an engineer the takeaway isn't which protocol to bet on today; it's that "my agent needs to pay for something" now has real answers — and each one needs the mandate discipline above bolted on.

06

Why it matters

Agentic payments are a genuinely new capability surface, and capability surfaces are where agents get dangerous. The good news is that this one has a clean control story: delegated, bounded, revocable authority checked before execution — the same least-privilege pattern that governs an agent's tool access and file system. If you're designing the backend, the mandate-verification and settlement flow is a system-design problem in its own right; see the payment system and digital wallet designs for the human-rails version this builds on.

The mental shift is the same one that made agents safe to give tools at all: never rely on the model to behave, bound what "behaving badly" can even cost. A mandate is a spending sandbox, and like every good sandbox, it works precisely because it doesn't trust the thing inside it.

Read next

The rails this builds on: Payment System and Digital Wallet. The least-privilege discipline: AI Security.

RUN IT YOURSELF

A mandate enforcer that stops a runaway agent

This is the whole safety model in a dozen lines. A signed mandate sets a per-transaction ceiling, a total budget, and allowed merchants; every payment must clear all three checks before it executes. Watch a legitimate payment go through, an over-limit one get refused, a wrong merchant get blocked — and a runaway agent that tries to spend $200 get capped at the $50 budget no matter how hard it loops. Change the mandate and the purchase list.

CPython · WebAssembly
Frequently asked

Quick answers

What is x402?

A machine-native checkout on the HTTP 402 status code: the server replies 402 with payment terms, the agent pays (usually a small stablecoin transfer) and retries with proof, then gets the resource — no human checkout page.

What is a mandate (AP2)?

A signed authorization scoping what an agent may spend — per-transaction ceiling, cumulative budget, allowed merchants, expiry. OAuth scopes, but for money. The agent acts freely inside it and is refused outside it.

How do spend caps stop a runaway agent?

Every payment is checked against the mandate before executing (amount ≤ per-txn, spent+amount ≤ total, merchant ∈ allowed). A looping or injected agent is refused once it would breach the cap — enforced by the payment layer, not the model.

Why does it matter now?

Autonomous agents need to pay mid-task and a human checkout defeats the point. x402 plus scoped mandates make it work at scale — a category already moving nine figures — but it needs the same least-privilege discipline as any agent capability.

The Agentic Payments Handbook · Vibe Engines · 2026 · reported protocol traction from public sources · more handbooks →
Finished this one? 0 / 160 Handbooks done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.