Should I pay this x402 request?
evaluate_payment_requirementsCall this on every HTTP 402 response BEFORE paying. Give it the PAYMENT-REQUIRED header value, the URL you requested and your spending policy (pay_to, assets, networks and max_amount, optionally schemes). Offline: it decodes and validates the x402 V2 payment request with the official @x402/core schema, checks that it is bound to the URL you requested, validates every payment option (scheme, CAIP-2 network, amount, asset, payTo, timeout window) and applies your policy to each option, since you pay with only one. Returns decision 'pay', 'review' (ask the human first) or 'do_not_pay' (never pay), the reasons, and the payment options that satisfy your policy (acceptable). It does not check balances, settlement or what the token at asset does, and it never pays.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| policy | No | Your spending policy, applied to each advertised payment option. Set at least pay_to, assets, networks and max_amount: without all four, the decision can never be 'pay'. | |
| resource_url | No | The exact URL you requested. Strongly recommended: without it the resource binding cannot be confirmed and the decision is at best 'review'. | |
| payment_required | Yes | The raw PAYMENT-REQUIRED response header value (Base64 JSON), the same object as a JSON string, or the decoded object. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| checks | Yes | ||
| reasons | Yes | ||
| summary | Yes | ||
| decision | Yes | ||
| acceptable | Yes |