
Agents for Humans: how an agent pays with x402 and AgentCore Payments
HTTP 402 was reserved in 1997 and never used, because software could not pay without a human filling in a form. x402 revives it. How a Strands merchant agent takes a stablecoin deposit with no payment processor, why the spend cap has to live outside the prompt, and where a human still says yes. No web3 background assumed.
Series: Headless Merchants, Real Payments (3 articles)
- 2Agents for Humans: how an agent pays with x402 and AgentCore Payments This article
Agents for Humans: how an agent pays with x402 and AgentCore Payments
Part 2 of 3 in Headless Merchants, Real Payments. Part 1 covered the agent, the gateways, the knowledge base and the guardrails. Part 3 covers what the ecosystem still needs. The thread: merchant agents will replace websites, and
table-relay is a working illustration.Discovery without transaction is a fancier Yelp.
A merchant agent that can be found and questioned but not paid is a listing, and listings are
what platforms already sell. That is the whole argument of this series compressed into one
sentence, so this post is about the part that makes it a storefront instead: the money.
No web3 background is assumed. If you have never heard of x402 or a stablecoin, the next three
sections are for you.
Why an agent needs to pay at all
table-relay is a restaurant running as a public agent. Its concrete problem is no-shows: a
table booked and not honoured is revenue that cannot be recovered, because the slot is gone.The normal fix is a deposit. Taking one requires a payment processor, a card on file, and PCI
exposure that a family-run restaurant does not have and will never acquire. So they take no
deposit and absorb the loss, and separately pay a booking platform per cover just to be
findable. Discovery and payment are two taxes on the same small business.
Now put an AI assistant in the middle. Your assistant finds the restaurant's agent, negotiates a
table, and reaches the deposit. What happens next decides whether any of this is useful:
- If it hands you a checkout link, you have left the conversation, the merchant still needs a processor, and nothing has changed except the referral path.
- If the assistant can settle it directly, the merchant needs no processor, no card on file and no platform, and you never leave the conversation.
That second option is what x402 makes possible, and it is the only version where the merchant's
economics actually change.
What x402 is, in plain terms
HTTP has had a status code reserved for this since 1997:
402 Payment Required . It was never
used, because there was no way for software to pay without a human filling in a form.x402 revives it. The exchange is three steps:
- A client requests something that costs money.
- The server answers 402 with machine-readable terms: amount, recipient, asset, network.
- The client attaches a signed payment and retries. The server verifies it and delivers.
No account, no signup, no card form, no redirect. The payment is part of the request, the way
authentication is part of a request.
The money is a stablecoin, in this case USDC. That word matters for readers who assume
cryptocurrency means volatility: a stablecoin is a token redeemable one-for-one for a dollar. It
is a dollar with an API, not a speculative asset. Nothing here appreciates, and nothing here is
an investment.
Two properties make it viable at small amounts. Settlement is seconds and fractions of a cent,
so a five-cent deposit is economically sensible in a way a card transaction never is. And under
the EIP-3009 scheme x402 uses, the payer signs an authorisation and the merchant submits it
on chain and pays the network fee. The paying wallet holds USDC and nothing else, with no second
asset to keep topped up.
table-relay runs entirely on Base Sepolia, a test network. The USDC is free from a faucet
and worth nothing. Every settlement in this post is real in mechanism and worthless in value,
which is exactly what you want while learning.What AgentCore Payments is
x402 tells you the wire format. It does not give your agent a wallet, and it does not stop your
agent spending everything in it.
Amazon Bedrock AgentCore Payments is the managed layer that does. Three things sit in a stack,
and it helps to keep them separate:
Layer | What it does | Analogy |
|---|---|---|
x402 | The protocol. 402 challenge, signed proof, delivery. | The WWW-Authenticate challenge, for money |
Coinbase CDP | The wallet and the settlement. Custodies keys, signs, moves USDC. | The bank |
AgentCore Payments | Policy, credential custody, spend limits, audit trail. | Corporate expense policy and the card issuer |
AWS never touches a blockchain. Coinbase does. AWS owns the part an enterprise actually worries
about: where the keys live, what the agent is allowed to spend, and what got spent.
Concretely it gives you four things:
- A managed wallet per user, created through the API. No private key in your code, no seed phrase, no key material in your container. Signing happens inside a trusted execution environment.
- A spend session carrying a maximum amount and an expiry, enforced by the service.
- A signer that turns a merchant's 402 challenge into a valid signed proof.
- An audit trail, one record per payment.
Setting it up is a chain of five resources: a credential provider holding your Coinbase keys, a
payment manager, a connector to the provider, a wallet instrument, and a spend session. It is
more ceremony than one API call, and every link exists for a reason you can name.
How the human stays in the loop
This is the part I care most about, and it is the reason the hackathon's name fits.
An agent that can spend money autonomously is only adoptable if the person on the hook can bound
it.
table-relay bounds it twice, in two different places, on purpose.The first bound is a hard limit the model cannot see. The spend session carries a maximum
(
$2 over 120 minutes in the demo) enforced server-side by AgentCore. The AWS documentation
notes specifically that this prevents prompt injection from overriding the limit, and that
property is the whole point:A budget in a system prompt is a suggestion. A budget in a payment session is a constraint.
If the cap lived in the agent's instructions, then a sufficiently persuasive message could argue
with it. It does not live there. No amount of persuasion moves a server-side counter.
The second bound is a human saying yes. Strands ships a human-in-the-loop intervention, so
this is configuration rather than architecture:
from strands import Agentfrom strands.vended_interventions.hitl import HumanInTheLoop
agent = Agent( tools=[talk_to_merchant, pay_deposit], interventions=[HumanInTheLoop(allowed_tools=["talk_to_merchant"])],)talk_to_merchant is allowed to run freely. pay_deposit is not on the allowlist, so when the
model reaches for it the agent stops instead of calling it:result = agent("Book me a table for two at 8pm on Friday")
while result.stop_reason == "interrupt": for i in result.interrupts: print(i.reason) # "pay_deposit: 0.10 USDC to Sushi Schrödinger" answer = input("approve? [y/n] ") # a real human, a real decision result = agent([{ "interruptResponse": { "interruptId": i.id, "response": answer } }])The agent pauses, surfaces exactly what it wants to spend and to whom, waits, and resumes with
the answer. Everything else on the path is autonomous: finding the restaurant, checking
availability, asking about the menu, holding the table, confirming afterwards. The human is
interrupted once, for the only decision that moves money.
That is the shape I would argue for generally. Not an agent that asks permission constantly,
which trains people to click yes. An agent that handles the whole errand and stops at the one
irreversible step.

The one moment a human is interrupted. Everything before and after it is autonomous.
What actually happens when a table is booked
Putting the pieces together, one booking looks like this:
- The diner's agent resolves the restaurant's agent card and asks for a table.
- The merchant holds the table and answers with a 402 challenge: 0.10 USDC, this recipient, this asset, this network.
- The diner's agent hits its human-in-the-loop gate and stops.
- The human approves.
- AgentCore signs the authorisation with the managed wallet, after checking the request against the session's remaining budget.
- The signed proof goes back to the merchant, which verifies and settles it through the Coinbase facilitator.
- USDC moves on Base Sepolia. The merchant records the settlement and confirms the booking.
Six of those seven steps need no human. The seventh is a
y 
Anyone can check this without asking me. The transaction's own sender is the facilitator, not the payer, which is EIP-3009 doing its job.
Watch the 2 minute 41 second demo : anonymous discovery, a grounded menu answer, one human approval, and a USDC deposit settled on Base Sepolia.
The lessons that generalise
Plenty of small API details cost me time and are not worth your attention. These five are.
Payment belongs below the reasoning loop, not inside it. Settlement runs in middleware that
executes before the model does. The model never sees the signed payload, never reasons about
money, and never spends tokens deliberating about it. It receives a short token meaning "this is
paid" and gets on with the booking.
Never let an identifier that controls money come from model output. The merchant once
confirmed a booking against reference
RS-0001 , which was not the live reservation. RS-0001
was the example in the tool's own docstring. A docstring ships on every request, so it is
prompt text, and its examples are anchors that a model will reach for when it needs a plausible
identifier. Nothing was lost, because the settlement path refuses to settle unless the
reservation is held, has a deposit due and is unpaid. A server-side invariant caught what the
model got wrong. The fix was structural: identifiers now ride in task metadata rather than model
output, and the recorded settlement rather than the model's claim is the security boundary.Silent failures cost more than loud ones. My first valid payment was reported as rejected,
with no error, because I read
.valid on a response object whose field is .is_valid . Missing
attribute returns None , None is falsy, and every good payment looked bad. A wrong answer that
looks plausible sends you searching everywhere except the broken line. Assert on the shape of
responses you do not control.A managed runtime may not give you the seam a protocol assumes. x402 is HTTP-native, and
AgentCore Runtime exposes no HTTP status seam: invocations carry no path, and A2A JSON-RPC always
returns
200 with the outcome in the payload. So the challenge moves into A2A message metadata
instead, using the keys from the Apache-2.0 x402_a2a extension. It works, and the cost is that
a plain-HTTP client cannot pay this merchant. Worth knowing before you design around the
canonical shape.The rough edges are in the ecosystem, not the code. The blockers that actually stopped me
were an AWS Marketplace subscription required before the Coinbase connector will create, and a
funding flow whose onramp is mainnet-only, so testnet funding is a manual faucet transfer. Neither
is a bug. Both are what "early" looks like, and both are Part 3's subject.
What it cost, and one asymmetry
Under $2 of infrastructure for the weekend. The Coinbase connector is metered through AWS
Marketplace and free-tier eligible. Settlement is testnet USDC from a faucet, so the payments
themselves cost nothing. Foundation model tokens dominated everything else.
Which surfaces something worth noticing. The agent's stablecoin budget is enforced
server-side by a session that prompt injection cannot override. Its token budget is enforced
nowhere:
max_tokens and a request rate limit are the only bounds, and neither is a spend cap.
Same platform, same weekend, two very different postures on autonomous spend.Conclusion
The rails work. An agent can be handed a wallet it cannot drain, a budget it cannot argue with,
and a human who says yes once per payment. A merchant can accept money with no processor, no card
on file and no platform in the middle. Six settlements landed on Base Sepolia and stayed there.
What does not work is the other side of the conversation. No mainstream consumer assistant can
resolve an agent card, parse a payment challenge, hold a wallet and sign a mandate. Until one
can, this loop only closes when the diner is also an agent you control.
That gap is Part 3: merchant agents will replace websites. The rails are ready; the ecosystem
isn't.
Code:
table-relay , Apache-2.0, built for the Agents for Humans hackathon. All restaurants,
menus and reservations are fictional. All settlement runs on Base Sepolia testnet, so no real
funds are involved.Series: Headless Merchants, Real Payments (3 articles)
- 2Agents for Humans: how an agent pays with x402 and AgentCore Payments This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article