Pay for an x402 API
pay_x402Calls an API URL, pays any 402 Payment Required challenge in USDC from the wallet under presign-guard spending limits, and returns the response.
Instructions
Call a URL that may answer 402 Payment Required and pay it in USDC from this wallet, then return the response. Works with x402 and with MPP (the Machine Payments Protocol): method evm (USDC on this wallet's chain) and method tempo (USDC.e on Tempo, from this wallet's address there). With a Solana or Algorand account set up, x402 offers in USDC there are paid too, and with an XRPL account x402 offers in RLUSD on the XRP Ledger (all after USDC on this chain). When an API offers several, x402 comes first, then MPP evm, then Tempo. The payment is checked by presign-guard and counts toward the spending limits; over a limit the owner is asked to approve (the call waits), and a refusal comes back as an error with the reason. max_price_usd caps the price of this call. If the API doesn't answer properly after a payment, the result says whether the payment was taken on-chain (charge), and paying that endpoint again is refused while the first payment can still be collected, or for an hour after it was taken without an answer: don't try to get around that, tell the owner.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"url": "<url>"
},
"name": "pay_x402"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The API URL | |
| body | No | Request body: a string, or an object sent as JSON | |
| method | No | HTTP method (default GET) | |
| reason | No | What this is for, in a few words (shown to the owner on the receipt and in approval requests) | |
| headers | No | Extra request headers, e.g. content-type | |
| max_price_usd | No | The most this call may cost, in dollars (never above the server's MAX_PAYMENT_USD) |