pay_x402
Handle an x402 payment flow. Fetches a URL, and if the server returns HTTP 402 Payment Required, parses the payment requirements (v1 body or v2 PAYMENT-REQUIRED header), signs an EIP-3009 TransferWithAuthorization for the "exact" scheme…
Instructions
Handle an x402 payment flow. Fetches a URL, and if the server returns HTTP 402 Payment Required, parses the payment requirements (v1 body or v2 PAYMENT-REQUIRED header), signs an EIP-3009 TransferWithAuthorization for the "exact" scheme (no gas, nothing broadcast by the payer), and retries the request with the payment header. AgentWallet paywalls are paid by on-chain transfer instead. The "upto" scheme is settled with a Permit2 authorization bounded by the cap. Returns the final response and the settlement receipt. Supports the x402 open payment standard (https://x402.org). max_payment can only lower the operator's cap for one call.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to access (will handle 402 payment if required) | |
| body | No | Optional request body for POST/PUT requests | |
| method | No | HTTP method (GET, POST, PUT, DELETE) | GET |
| headers | No | Optional JSON string of additional request headers. Credentials placed here (Authorization, Cookie, API keys) are sent only to the origin in `url`; if the endpoint redirects to a different origin they are dropped, not forwarded. | |
| wallet_id | Yes | Wallet ID to pay from | |
| approval_id | No | An approval id from an earlier over-cap attempt. Once the owner has approved it, pass it here to make that one payment. | |
| max_payment | No | Maximum payment in human-readable format (e.g. "1.00" for 1 USDC). Lowers the operator's AGENTWALLET_MAX_AUTOPAY ceiling (default "1") for this one call; it can never raise it, and a value above the ceiling is ignored and reported as max_payment_ignored. | |
| prefer_chain | No | Preferred chain ID if the server accepts payment on multiple chains (e.g. 8453 for Base, 1 for Ethereum) | |
| request_approval | No | Hosted wallets only. When the payment exceeds the cap, email the wallet owner an approve/deny link instead of refusing, and return an approval_id to retry with. Default true unless AGENTWALLET_APPROVALS=0. | |
| fresh_authorization | No | Sign a new authorization even if one for the same endpoint, amount and recipient is still valid. By default a repeat call within the validity window re-sends the earlier signature (same nonce, so it cannot settle twice) instead of paying again. |