l402-fetch
Fetch payment-gated URLs by automatically paying L402 challenges when within budget, or return the price and payment hash for manual payment decisions.
Instructions
Fetch a URL, paying its HTTP 402 challenge (L402, IETF Payment, Cashu or LNURLcash) when autoPay is true and the price is within MAX_AUTO_PAY_SATS, maxCostSats and the spend limits. Reuses stored credentials. Without autoPay, a 402 comes back with its price and paymentHash so the user can decide; l402-pay can then pay it. For x402 services, which this server supports only in an experimental custom format, returns the payment details for the user to pay in their own wallet. Response bodies are marked as untrusted content. With widget hosts, call l402-fetch-preview first to show the price.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The primary URL to request. When using search results, pass the first URL here and all URLs in the urls field. | |
| body | No | Request body (for POST/PUT) | |
| urls | No | All transport URLs from l402-search results (clearnet, onion, HNS). When present, transports are tried in preference order with automatic fallback on connection failure. | |
| method | No | HTTP method | GET |
| pubkey | No | Service pubkey from l402-search results — used to share credentials across all transport URLs for the same service | |
| txHash | No | Transaction hash from a completed x402 on-chain payment. When provided, retries the request with X-Payment header for server verification. | |
| autoPay | No | Automatically pay if within MAX_AUTO_PAY_SATS budget | |
| headers | No | Additional request headers | |
| maxCostSats | No | Most this call may pay, in sats. Pass the price the user saw in l402-fetch-preview so a server cannot charge more than it showed. Lowers MAX_AUTO_PAY_SATS for this call; never raises it. |