When your API returns HTTP 402, an auto-mode Claude Code agent needs to answer four questions without asking a human:
| Question | Header | Example |
|---|---|---|
| How much? | x-402-amount | 5 (in cents, so $0.05) |
| Which chain? | x-402-chain | base |
| Which token? | x-402-token | USDC |
| Pay to whom? | x-402-recipient | 0xf16F0882de... |
Without these headers, the agent sees a 402 and stops. With them, the agent checks its .agent-budget file, confirms the amount is within limits, and proceeds — all in milliseconds.
curl -sI https://your-api.com/endpoint
Look for HTTP/2 402 in the first line. If you get 200 with trial info, that's fine for first-time callers — but test trial exhaustion next.
Add ?probe=1 (or your equivalent) to simulate a user who's out of free trials:
curl -sI "https://your-api.com/endpoint?probe=1"
You should now get HTTP/2 402.
curl -sI "https://your-api.com/endpoint?probe=1" | grep -i 'x-402-'
Expected output:
x-402-amount: 5
x-402-chain: base
x-402-token: USDC
x-402-recipient: 0x...
curl -s "https://your-api.com/endpoint?probe=1" | python3 -m json.tool | head -20
Look for a payment field in the JSON body. Headers are for routing; the body is for display. Both should agree.
# 1. Exhaust trials (call until 402)
for i in $(seq 1 16); do
curl -sI https://your-api.com/endpoint | grep HTTP
done
# 2. Verify 402 appears with machine-readable headers
curl -sI https://your-api.com/endpoint | grep -i 'x-402-amount'
?probe=1, not on real exhaustion)x-402-recipient points to a wallet that can't receive on the declared chainHere's a live example. Every endpoint on minia2a returns these headers on 402:
$ curl -sI https://minia2a.uk/x402/gas?probe=1 | grep -i 'x-402-'
x-402-amount: 500
x-402-chain: base
x-402-token: USDC
x-402-recipient: 0xf16F0882de08315B438E9f3a2Abfb2d2E5d94ECA
The amount is in cents (500 = $5.00 USDC). The chain is Base L2 (~3¢ gas). The token is native USDC on Base. The recipient is the platform's settlement address.
An auto-mode agent reading these headers knows: this call costs $5.00 USDC on Base. My daily limit is $10.00. I have budget remaining. Proceed.
On August 14, Claude Code Pro/Max/Team users will have auto mode enabled by default. When their agent hits your API:
The difference between those two paths is the difference between 14 paid transactions and 14,000.
Claude Code auto mode supports the concept of a spending limit. The .agent-budget proposal ({daily_limit_usdc: 5, max_per_call_usdc: 1}) gives humans a way to pre-authorize small spending. When your 402 response includes machine-readable headers, the agent can check its budget file and auto-approve — no permission prompt needed.
Together, machine-readable 402 + .agent-budget = the first end-to-end autonomous agent payment flow.
Tested live on August 10, 2026 against minia2a.uk production endpoints. All 4 headers present and correct on every 402 response.
Related: .agent-budget: A Standard for Agent Spending Limits · Claude Code Auto Mode: The Agent Payment Moment