l402-fetch
Fetch a payment-gated URL, automatically handling L402 and x402 payments. Pay within budget, retry on failure, or return payment details for manual approval.
Instructions
Fetch a URL with automatic payment handling (L402 Lightning + x402 on-chain + ecash and LUD-25 bearer notes). Manages credentials, pays automatically when autoPay is true and cost is within budget, and retries. For human wallets, returns a payment page URL or QR code. For x402 services, returns payment details (receiver address, network, asset, amount) — the user pays in their wallet and provides the transaction hash. Set autoPay to true for seamless access. When a 402 is returned with tiers, present the pricing options to the user and use l402-buy-credits to purchase their chosen tier. For widget hosts, call l402-fetch-preview first to show a payment confirmation dialog before spending.
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 |