AI Agent Payments: Mandates, Spend Limits and Safe Retries
Saket Bhatnagar, Founder, SevyDevy, Last updated , 18 min read
Summary
- AI agent payments are purchases an AI agent makes for you, so the safe design gives it a narrow, revocable way to pay instead of your real card.
- A mandate is a signed, dated permission that says what the agent may buy, from whom, up to what amount and until when. Your code checks it before every payment.
- Spend limits and scoped credentials enforce that permission. A scoped credential stands in for your real card number and works only for one merchant, amount or time window. Examples are network tokens (substitute numbers) and virtual cards.
- An idempotency key is a unique ID sent with a payment request, so a retried request cannot charge twice. Pair it with human approval above a threshold and an audit log you cannot quietly edit.
- Beginners can stop after the mandate and credential sections. Engineers get a tested Python simulation. A lost reply caused a double charge without a key. A budget checked but not reserved before paying overspent in 20 of 20 runs.
What goes wrong when an AI agent can spend real money?
Small bugs turn into real charges. A retry after a timeout can pay twice, a confused agent can pay the wrong seller, and nobody can later prove who approved what.
Picture a common setup. A 12-person office in Pune lets an agent reorder printer ink, paper and stationery when stock runs low. The setup is made up, but each failure below is a real pattern. The first week, the payment call times out, the agent retries, and the card is charged twice. Later a product page tricks the agent into a gift card purchase.
AI agent payments need the same discipline as any payment system, plus one more worry. The caller is a program that can misread a page or follow a planted instruction. So the money rules must live outside the agent, in code it cannot talk its way past.
This guide follows that office agent from its first purchase to a refund. Each section adds one control and shows the failure it stops.
Which words do you need before reading about AI agent payments?
You need seven words. Each one gets a plain meaning here, and the rest of the guide uses the same word every time.
- Mandate: a signed, dated permission from a person that says what the agent may buy, from whom, up to how much and until when.
- Spend limit: a maximum amount per purchase, per day or per month, checked before money moves.
- Scoped credential: a payment credential that works only inside set limits, such as one merchant or one amount. It stands in for your real card number.
- Issuer: the bank or company that gave out the card. Each charge request it approves or declines is called an authorisation.
- Idempotency key: a unique ID you send with a payment request so the processor treats retries as the same request, not a new one.
- Refund: the seller sends money back. A chargeback is different: the cardholder's bank forcibly takes money back from the seller after a complaint.
- Audit trail: a record of every request, decision and payment, kept so that later nobody can change it unnoticed.
How do AI agent payments work safely?
Safe AI agent payments put a spend gate between the agent and the money. The agent asks to buy; the gate checks the mandate, may ask a human, then pays with a scoped credential and logs everything.
Think of an office petty-cash float. The manager hands a clerk a float of 8,000 rupees each morning. The float size is the budget. Any spend above 3,000 rupees needs the manager's signature, which is the approval threshold. Every rupee out needs a voucher in a numbered book, which is the audit trail.
Where the picture breaks: cash runs out on its own, so the clerk physically cannot overspend. Software limits only work where they are enforced. A limit written in the agent's instructions is a request, not a wall.
One purchase through the spend gate
Drag to exploreNotice that the agent never touches the processor or the real card. Every path, including a block, writes to the audit log.
Diagram connections:
- Office supplies agent to Spend gate (purchase request)
- Spend gate to Human approver (approval if over threshold)
- Spend gate to Credential vault (scoped credential)
- Spend gate to Payment processor (charge)
- Payment processor to Card issuer (authorisation)
- Spend gate to Audit log (record decision)
- Office supplies agent: Agent → Gate: buy ink, Rs 1,800
- Spend gate: Gate checks mandate, merchant, limits
- Human approver: Gate → Human: only above Rs 3,000
- Credential vault: Gate → Vault: fetch merchant-locked token
- Payment processor: Gate → Processor: charge with idempotency key
- Card issuer: Processor → Issuer: issuer checks its own limits
- Audit log: Every block, approval and charge appended
There are two walls in this picture. Your spend gate is the first. The card issuer's own controls are the second, and they hold even if your gate has a bug.
What is a payment mandate, and what should it limit?
A mandate is the person's permission written as data: what, from whom, how much, until when. Your gate compares every purchase against it before paying.
A good mandate is narrow and short-lived. For the office agent, a sensible one allows two stationery sellers only. It caps one purchase at 5,000 rupees, a day at 8,000 rupees, and expires in 30 days.
| Control | What it stops | Office agent value (made up) | Where to enforce it |
|---|---|---|---|
| Allowed merchants | Paying a lookalike or gift card site | Two stationery sellers | Your gate and a merchant-locked credential |
| Per-purchase cap | One huge mistaken order | Rs 5,000 | Your gate and the card's per-authorisation limit |
| Daily or monthly budget | Many small charges adding up | Rs 8,000 a day | Your gate, reserved atomically |
| Approval threshold | Large buys with no human look | Above Rs 3,000 | Your gate, with approval tied to the exact cart |
| Expiry | A forgotten permission used months later | 30 days | Your gate and the credential's expiry |
| Categories | Spending outside the job | Office supplies only | Card category controls |
The simulation in this guide ran each control against the office agent. An ink order of 1,800 rupees went through. A gift card site was blocked as merchant_not_allowed. A 6,500 rupee order was blocked as over_per_txn_limit. A 4,200 rupee chair was blocked until a manager approved it.
How an open agent payments protocol writes mandates
The Agent Payments Protocol, or AP2, is an open protocol for agent purchases, at version 0.2 as of 30 October 2026. It splits permission into a Checkout Mandate, covering the items, and a Payment Mandate, covering the payment.
Each mandate is open or closed. An open mandate holds the person's constraints, such as an amount range, a budget, allowed payees and an expiry time. A closed mandate approves one finished cart and one exact amount.
The specification names two modes. In Human Present, the person sees the final cart and approves it. In Human Not Present, the person approves only the constraints, and the agent approves closed mandates inside them.
AP2 mandates are signed digital credentials, chained so the cart, payment and receipt can be matched later. The specification says dispute handling is outside its scope. Work on the standard continues in FIDO Alliance working groups.
How Indian rules already shape recurring mandates
In India, recurring payments on cards, prepaid instruments such as wallets, and UPI follow the RBI Digital Payments E-mandate Framework, 2026, dated 21 April 2026. UPI is India's instant bank-to-bank payment system. The rules read like a checklist for agent mandates.
- Registering a mandate needs an additional factor of authentication, or AFA, such as a one-time password (OTP) or PIN.
- Every mandate states a validity period. For variable amounts, the customer can set a maximum value per transaction.
- The first transaction needs AFA. Later ones need none up to 15,000 rupees each.
- Insurance premiums, mutual fund subscriptions and credit card bills may go without AFA up to 1 lakh (100,000) rupees.
- The issuer sends a notice at least 24 hours before each debit, and the customer can opt out of that debit.
These limits are as of 30 October 2026. An agent that triggers card or UPI recurring payments in India works inside them, whatever its own mandate says.
Why should an AI agent never hold your real card number?
Because anything the agent can read, it can leak or misuse. Give it a scoped credential that is useless outside one merchant, amount or time window.
The agent reads web pages written by strangers. A planted instruction could make it paste a card number into a form or a chat. A stand-in credential limits the damage to one small, cancellable thing.
Network tokens
A payment token replaces the card's primary account number, the long number on the card, with a different value. EMVCo, the body that maintains EMV card standards, defines token domain restriction controls. These can tie a token to a specific device, merchant or use case.
Tokens also survive card changes. EMVCo notes that a token stored at a merchant can be linked to a new card number without any cardholder input.
Virtual cards with spending controls
A virtual card is a card number issued by software for one job. With Stripe Issuing, as of 30 October 2026, each card or cardholder carries spending_controls. These set allowed or blocked merchant categories, merchant countries and spending limits, such as per authorisation, weekly or monthly.
Read the fine print before trusting those limits fully. Stripe documents that spend aggregation is best-effort, with up to 30 seconds of delay. Tips and fees posted later can push spend over a limit.
Defaults matter too. If you set no limit, a new card gets 500 US dollars a day. A 10,000 dollar cap also applies to each authorisation. You cannot change these defaults yourself; only Stripe support can turn them off. Locking a card to exact merchant IDs is in private preview.
Agent tokens from card networks
Card networks now issue tokens meant for agents, as of 30 October 2026. Visa Intelligent Commerce returns an agentic token in place of the card number, and holds consumer-set spend limits and expiry in purchase instructions. Mastercard announced Agent Pay on 29 April 2025, with Agentic Tokens built on its tokenisation, and said agents will need to be registered and verified.
How do idempotency keys stop double charges when an agent retries?
You create one unique key per purchase and send it with every try. The processor saves the first result under that key and returns it again for retries, so money moves once.
Here is the trap. The charge succeeded, but the reply was lost on the network. The agent sees a timeout and cannot tell "failed" from "succeeded but silent". Retrying is right, but only if the processor can spot the repeat.
The simulation answers it. Without a key, the toy processor created 2 charges, 2,400 rupees for one 1,200 rupee order. With one key reused on the retry, it created 1 charge and replayed the saved reply.
import uuid
def new_order(amount, merchant):
# make the key once, with the order, and save both BEFORE the first try
return {"amount": amount, "merchant": merchant, "key": str(uuid.uuid4())}
def charge_with_retry(processor, order):
for attempt in range(3):
try:
return processor.charge(order["amount"], order["merchant"], key=order["key"])
except TimeoutError:
continue # same key on every retry
raise RuntimeError("still unsure after 3 tries: check the order, do not buy again")What just happened? The key is made once, when the order is created, and saved with it. Every retry, even after a restart, reuses that key. A key made inside the loop would look new each time and charge again.
What real processors promise
Stripe's API reference, as of 30 October 2026, says keys can be up to 255 characters. It suggests V4 UUIDs, which are random IDs, and warns against putting personal data in keys.
For API v1, Stripe saves the status code and body once its server starts processing the request. Retries get that saved response, including 500 server errors. Keys can be removed once they are at least 24 hours old, and a reused key after that is a new request. So a saved server error replays too: check the payment's real state before trying a new key.
Two more rules catch people. A reused key with different parameters returns an error. A request that fails validation or clashes with a running request is not saved, so you can retry it.
Where should the spend limit be checked so two tasks cannot overspend?
Check and reserve the amount in one atomic step, before calling the processor. Atomic means no other task can act between the check and the reservation. Reading the balance first and recording the spend after the call lets two tasks pass the same check.
The office agent sometimes runs two tasks at once, say ink and paper. In the race test, each tried to spend 5,000 rupees from an 8,000 rupee budget. Each payment call took a made-up 50 milliseconds.
With check-then-act, both tasks saw 8,000 free, and both paid. That overspent in 20 of 20 runs, ending at 10,000 rupees. Reserving the amount under a lock, which lets only one task touch the budget at a time, gave 0 of 20 overspends.
Reserve
In one atomic step, check the budget and record a hold for the amount. In a database this is one transaction or a conditional update.
Pay
Call the processor with the purchase's idempotency key and the scoped credential.
Settle
On success, turn the hold into a spend record linked to the charge ID.
Release
On a clear decline, release the hold. On a timeout, keep it and retry with the same key until you know the outcome.
Keep the issuer's limit as the backstop. Your reservation is exact, while the issuer's aggregation can lag by seconds.
When should a human approve an AI agent's payment?
Ask a human when a purchase crosses an amount threshold, uses a new merchant, or falls outside the usual pattern. The approval should cover the exact cart, amount and merchant, and expire soon.
An approval that says "yes, buy chairs" is too loose. The agent could change the cart after the click. Tie approval to the closed cart, the same idea as AP2's closed mandate, and keep its signature in the log.
Deciding whether a purchase needs a person
Drag to exploreRead the questions top to bottom. A purchase reaches the processor only after every check says yes.
Diagram connections:
- Purchase request to Inside the mandate?
- Inside the mandate? to Block and log (No)
- Inside the mandate? to Over Rs 3,000 or new? (Yes)
- Over Rs 3,000 or new? to Pay with key (No)
- Over Rs 3,000 or new? to Ask the manager (Yes)
- Ask the manager to Pay with key (Approved)
- Purchase request: Cart, merchant, amount from the agent
- Inside the mandate?: Merchant, cap, budget, expiry
- Over Rs 3,000 or new?: Threshold or first-time merchant
- Ask the manager: Shows exact cart; approval expires in 1 hour
- Pay with key: Scoped credential plus idempotency key
- Block and log: Reason saved, agent told why
Set thresholds from real spending, not guesses. If 90 percent of the office's past orders (made up) are under 3,000 rupees, that threshold asks for a person about once in ten orders. Asking for everything trains people to click yes without reading.
What happens when an AI agent's purchase must be undone?
Ask for a refund first; a chargeback is the slow fallback. A refund is the seller returning money, while a chargeback is the bank forcing it back after a dispute.
| Question | Refund | Chargeback (dispute) |
|---|---|---|
| Who starts it | The seller | The cardholder, through their bank |
| Where money goes | Only to the original payment method | Back through the card network |
| How long | Credit shows in about 5-10 business days | Usually 2-3 months from start to decision |
| Limits | Several partial refunds, never more than the charge | Seller has usually 7-21 days to send evidence |
| Who decides | The seller | The cardholder's bank |
A few rules shape the agent's undo path. If the payment was only authorised and not yet captured, cancel it rather than refund. While a dispute is open, the seller cannot refund outside the dispute process. Stripe notes that card networks typically allow disputes within 120 days of payment.
The simulation checked the over-refund rule. A 1,000 rupee refund on the 1,800 rupee ink order worked. A second 1,000 rupee refund was rejected with 800 rupees left to refund.
What should an audit trail for AI agent payments record?
It should record enough to replay every decision: what the agent asked, which mandate allowed it, who approved, which key and credential paid, and what came back.
- The agent's request: cart, merchant, amount, and the task that led to it.
- The mandate ID and version that was checked, and the gate's decision with its reason.
- The approver, the approved cart's hash, and the approval time.
- The idempotency key, the credential ID (never the card number), and the processor's charge ID.
- Every timeout, retry, refund, dispute and block, each with a timestamp.
Make the log tamper-evident. Each row stores a hash, a short fingerprint computed from content, of the row before it. Editing an old row then breaks the chain. In the simulation, the log verified as ok with 7 rows. After one old amount was edited, verification reported broken at row 0.
A hash chain shows tampering but does not stop it. Store the latest hash somewhere separate, such as object storage set to refuse edits, so an attacker cannot rewrite the whole chain.
How do you explain AI agent payments in a system design interview?
Frame it as a spend gate outside the model, then walk through one purchase and its failures.
State the threat
The caller is a program that can be confused or tricked, so money rules must sit in code it cannot change.
Define the mandate
Allowed merchants, per-purchase cap, budget, approval threshold and expiry, stored as signed data.
Pick the credential
A network token or virtual card locked to merchant and amount, so the issuer enforces limits as a second wall.
Make payment calls safe to retry
One idempotency key per purchase, saved before the first try, and an atomic budget reservation.
Add the human and the undo
Approval tied to the exact cart above a threshold, and a refund path that also needs approval.
Close with the audit trail
A hash-chained log of requests, decisions, keys, charge IDs and refunds, with numbers like Rs 8,000 a day.
Questions people ask
Can I just tell the agent its budget in the prompt?
No, a budget in the prompt is a request, not a control. The agent can misread it or be talked out of it by a planted instruction on a web page. Enforce the budget in your spend gate and again with the card issuer's limits.
Is a virtual card enough to make agent payments safe?
No, it is one wall, not the whole design. Issuer limits can lag, since Stripe documents best-effort aggregation with up to 30 seconds of delay as of 30 October 2026. You still need your own atomic budget check, idempotency keys and an audit log.
How long should I keep an idempotency key?
Keep it with the order for as long as the order can be retried. Stripe, for API v1, may remove keys once they are at least 24 hours old, as of 30 October 2026. A retry after that counts as a new request, so do not retry days later without checking the order first.
What is the difference between an open and a closed mandate?
An open mandate holds limits, while a closed mandate approves one exact cart and amount. In AP2 version 0.2, the person can approve open constraints and let the agent approve closed mandates inside them, or approve the closed cart directly.
Do RBI e-mandate rules apply to AI agent payments in India?
They apply when an agent's payments run as recurring e-mandates on cards, prepaid instruments or UPI. One-off purchases are outside this framework. As of 30 October 2026, the 2026 framework needs AFA at registration and first payment, and allows later debits up to 15,000 rupees without AFA.
Should the agent be allowed to issue refunds?
It can request refunds, but approval should sit with your gate or a person. A refund moves money just like a purchase. Log refund requests, approvals and results the same way, and remember refunds go only to the original payment method.
Keep learning
Practise it with Lala
A question on this guide, hints and a review.
Read next
Sources (12)
- Stripe API reference: Idempotent requests
- Stripe docs: Issuing spending controls
- Stripe docs: Refund and cancel payments
- Stripe docs: How disputes work
- Agent Payments Protocol (AP2) home page
- AP2 specification v0.2
- AP2 Payment Mandate
- EMVCo: EMV Payment Tokenisation
- EMVCo: Tokenisation quick reference guide (PDF)
- Visa Developer: Visa Intelligent Commerce overview
- Mastercard press release: Mastercard Agent Pay (29 April 2025)
- RBI Master Direction: Digital Payments E-mandate Framework, 2026