CAI.com

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

  1. Agent receives 402 with payment challenge (address, amount, chain, token).
  2. POST /x402-payment-prepare — returns attempt_id; may set requires_user_confirm.
  3. User confirms unless an active payment mandate covers the merchant domain.
  4. POST /x402-payment-execute — custodial transfer; retain tx_hash.
  5. 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

Authoritative docs