L402
About L402 and how to use it
L402: The Missing Link in Internet Payment Infrastructure
This text is adapted from the L402 documentation
In today’s AI-driven world, L402 bridges the gap between automation and payments, enabling machine-friendly transactions where traditional human-centric payment flows fall short.
Key Features
L402 simplifies and automates the process of handling payments on the internet, allowing seamless integration into digital workflows. It leverages HTTP as a foundation to standardize how payments are requested and processed, making it easier for AI agents and automated systems to interact with services.
- HTTP-based flow: simplifies payment handling by using HTTP 402 status codes and JSON payloads, allowing clients to request resources, pay and access them seamlessly.
- Standarize payment requests: services indicate payment requirements, making integration predictable and easier for developers to implement across different systems.
- Payment agnostic: works with a variety of payment solutions, from services like Stripe to cryptocurrencies, offering developers the flexibility to use the payment network that best fits their needs.
- Designed for automation: enables seamless, autonomous transactions between services and AI agents, removing the need for human intervention in payment processes.
- Extensible and open source: built to be open and adaptable, making it easy to extend and integrate with future payment solutions and evolving technologies. Introduction
L402 makes payments a core part of HTTP interactions by leveraging the HTTP 402 status code. Payments were largely an afterthought in the internet’s original design, even though the HTTP protocol reserved the 402 “Payment Required” status code for future use. Instead, payment solutions evolved around human-centric processes and relied on networks like Visa and Mastercard, making manual checkout flows the standard. This worked well for traditional web interactions, where payments were either preconfigured or managed manually by users.
With the rise of autonomous systems and AI agents that discover and interact with services independently, the limitations of these human-centric payment flows are becoming clear. These agents interact primarily through APIs and bypass browser-based interfaces, revealing a need for a payment model that supports automated, real-time transactions without human setup.
L402 addresses this gap by making payments “machine-friendly” on the internet. Leveraging HTTP’s 402 status code and JSON payloads, L402 standardizes how services request payments directly within HTTP interactions, enabling AI agents and automated systems to handle payments as naturally as data exchange. This transforms payments into a core, automated component of the web.
A short summary of the L402 flow is as follows:
A client attempts to access a protected API resource that requires payment to use.
Server responds with a 402 Payment Required status code and JSON containing available payment offers and methods for the client to choose from.
Client contacts the payment gateway to request specific payment details for their chosen offer and preferred payment method.
Gateway returns payment details needed for the transaction - such as a checkout URL, Lightning invoice, or ACH account information.
Client completes the payment outside of the protocol using their selected payment method and the provided payment details.
Once payment is confirmed, the payment gateway notifies the server that the payment has been received successfully.
When the client requests the resource again, the server recognizes the completed payment and grants access to the protected resource.
The entire flow uses standard HTTP semantics, making it compatible with any HTTP client - browsers, API clients, or AI agents. While the API, payment gateway, and server are shown as separate entities, with self-custodial methods they could be implemented as the same entity.
markdown2pdf.ai and L402
markdown2pdf.ai is built on top of the L402 protocol, allowing you to easily convert markdown content into PDF format. It uses the L402 protocol to handle payments in a machine-friendly way, enabling AI agents and automated systems to interact with the service without manual intervention.
If you like, you can use our REST API directly, or you can use our Python SDK to simplify the process of converting markdown to PDF. The SDK handles the payment flow automatically, allowing you to focus on your application logic without worrying about payment details.