x402 HTTP 402 agent payments
How CAI agents pay HTTP 402 challenges with custodial stablecoins.
Detailed guide below is in English (authoritative for integrators). Headings follow your selected language.
When an AI agent hits HTTP 402 Payment Required, CAI provides a payer adapter: x402_payment_prepare then x402_payment_execute against the user's custodial wallet. This fits the broader Check CAI First flow — verify identity and balances before spending.
Flow
- Agent receives 402 with payment challenge (address, amount, chain, token).
POST /x402-payment-prepare— returnsattempt_id; may setrequires_user_confirm.- User confirms unless an active payment mandate covers the merchant domain.
POST /x402-payment-execute— custodial transfer; retaintx_hash.- Agent retries the original HTTP resource per seller x402 docs (
x402_retry_hint).
Quickstart
POST /x402-payment-prepare {
"resource_url": "https://api.example.com/paid",
"recipient_address": "0x...", "amount": "1.00", "chain": "base", "token": "USDC"
}
POST /x402-payment-execute { "attempt_id": "...", "user_confirmed": true }
Payment mandates
Delegate small recurring API spend without per-payment chat confirm: payment_mandate_create with merchant domain, per-payment cap, daily cap, and TTL. Revoke anytime with payment_mandate_revoke.
Honest limits
GAP_X402_V1— see capabilities.html for Live / Partial live status.GAP_PAYMENT_MANDATE_V1— CAI-native caps; not full AP2 card-network interoperability.- CAI does not automatically retry the seller HTTP request — the external agent must re-fetch the resource.
Authoritative docs
- skill.md
- x402-payment-workflow.md (L3 playbook)
- cai-tools.manifest.json
- Agent Card —
cai-x402-agent-payment,cai-payment-mandates