Solutions/Paid APIs (L402)

Paid APIs (L402)

Use your Phoenixd node as the payment backend for an API that charges for data, content, or compute.

Implement the L402 payment and access layer in your application or compatible middleware, using your node to create Lightning invoices.

How L402 works

  1. A client requests a protected resource.
  2. Your application returns HTTP 402 Payment Required with a Lightning invoice and a credential, typically a macaroon, bound to the invoice's payment hash.
  3. The client pays the invoice and obtains the payment preimage.
  4. The client retries with the credential and preimage. Your application validates both before granting access.

Your application defines pricing, credential expiry, and the resources or usage each payment unlocks.

Build with your node

Connect your backend to your Phoenixd node to create invoices. Add middleware that issues L402 challenges, signs credentials, and verifies the client's proof of payment.

Keep node credentials and credential signing keys on your server. Clients receive the invoice and access credential.

Learn more

On this page