# agent to merchant l402 payment

> Pay an Aperture-style 402 challenge and fetch the resource.

agent to merchant l402 payment is a paid AI agent skill on Agensi by agent-bitcoin, in APIs & Backend. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $9 (one-time purchase)
- Creator: [agent-bitcoin](https://www.agensi.io/creators/agent-bitcoin)
- Category: [APIs & Backend](https://www.agensi.io/skills/apis-backend)
- Version: 1.0
- Last updated: 2026-11-23
- Security: scan passed (2026-11-23); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/agent-to-merchant-l402-payment
- Tags: api, lightning-network, l402, bitcoin, lnd

## About this skill

Handling 402 Payment Required status codes often stalls automated agents that lack a native way to negotiate Lightning Network payments. This skill enables an agent to detect L402-gated endpoints, pay the requested invoice using the Lightning Network, and retrieve the protected resource.

### What it does
- **L402 negotiation** automatically handles the HTTP 402 challenge-response flow.
- **Lightning payments** pays BOLT11 invoices via an unlocked LND node to satisfy the gate.
- **Resource retrieval** fetches the content from the merchant endpoint after successful payment.
- **State reporting** provides clear feedback on the HTTP status code and payment confirmation.
- **Safety controls** enforces strict opt-in for mainnet spends and automated payments.

### How it works
1. **Identify target** the user provides a URL that requires an L402 payment.
2. **Environment setup** the agent ensures the `agent-bitcoin` SDK is installed and the LND node is reachable.
3. **Execute payment** the `L402Client` fetches the URL, intercepts the 402 error, and pays the invoice.
4. **Deliver resource** the agent returns the final status and the content of the paid resource.

### Frameworks & tools
Python 3.10+, `agent-bitcoin` SDK, LND (Lightning Network Daemon), and Aperture-style merchant gateways.

### Why this beats prompting it yourself
Standard prompts cannot handle the multi-step cryptographic handshake and wallet interaction required for L402. This skill provides the specific logic needed to bridge the gap between HTTP requests and Lightning wallet RPCs.

### Use cases
- Access paid API endpoints that charge per-request via Lightning.
- Download gated documentation or datasets from L402-enabled merchants.
- Automate micro-payments for agent-to-agent service consumption.

### Known limitations
Requires a locally accessible, unlocked LND node. Defaulted to Regtest; Mainnet and Autopay require explicit user permission.

## Requires

- Python

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the agent to merchant l402 payment skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does this skill handle the 'Payment Required' error differently than a standard HTTP request?

This skill automates the HTTP 402 "Payment Required" handshake, allowing your agent to detect, pay, and resolve Lightning Network-gated resources without manual intervention. It solves the problem of automated agents getting stuck at payment-walled APIs or content gateways.

### What specific infrastructure do I need to have in place to use this skill?

The skill requires a Python 3.10+ environment, the agent-bitcoin SDK, and access to an unlocked Lightning Network Daemon (LND) node. It is designed to work with any agent framework that supports custom tool integration, such as LangChain or Autogen.

### What exactly is included in the purchase of this skill?

You receive the specialized logic for the L402 challenge-response flow, integration code for the agent-bitcoin SDK, and documentation on connecting your LND node. This includes the ready-to-use tool definition for your agent's toolkit.

### Can this skill automatically spend my real Bitcoin on Mainnet?

By default, the skill is configured for Regtest to ensure a safe testing environment. To use it on Mainnet or enable automated payments (Autopay), you must explicitly adjust the security flags within your configuration.

### Is this compatible with all Lightning payment gateways or just specific ones?

This skill is specifically optimized for Aperture-style L402 gateways, which are the industry standard for Lightning-gated APIs. It will work with any merchant endpoint that follows the standard L402/LSAT protocol for BOLT11 invoices.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
