Decode an HTTP 402 response
decode_402_challengeParse HTTP 402 responses to identify the payment scheme (L402, x402, MPP), decode the invoice or macaroon, and return the headers and steps needed to pay and retry.
Instructions
Call 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 |