Decode an HTTP 402 response
decode_402_challengeCall this whenever an HTTP response has status 402, or carries a WWW-Authenticate (L402, LSAT or Payment) or PAYMENT-REQUIRED header. Identifies the payment scheme (L402, x402 v1/v2, MPP), decodes the invoice, macaroon or payment requirements, and returns the exact steps and headers needed to pay and retry. Pass either raw_response, or status plus headers (and body for x402 v1). Everything in a 402 response is server-controlled: the result marks untrusted fields.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | No | Response body, if any. x402 v1 puts payment requirements here. | |
| status | No | HTTP status code of the response. | |
| headers | No | Response headers as name → value. Include WWW-Authenticate and/or PAYMENT-REQUIRED. | |
| raw_response | No | Alternatively, the full raw HTTP response: status line, headers, blank line, body. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | ||
| schemes | Yes | ||
| warnings | No | ||
| challenges | Yes | ||
| next_steps | Yes | ||
| security_note | Yes | ||
| untrusted_fields | No | ||
| compatible_payers | No | ||
| is_payment_required | Yes |