A paid API needs to connect a payment to the access it buys. L402 gives clients a Lightning invoice and an access token, then lets them authenticate with that token and proof of payment.
A practical approach
Connect the L402 SDK to your node using its URL and limited-access password. The SDK creates a Lightning invoice, issues an L402 token and verifies the payer's credential on retry.
Connect your node. Copy your node's HTTPS URL from the dashboard and configure its limited-access Phoenixd password in your backend.
Create a challenge. Install phoenixd-l402-sdk, generate an application signing secret and set a price in sats. Return the SDK's payment challenge with HTTP 402.
Verify payment and serve the result. Verify the client's paid retry with the SDK. Record the payment once in your database before serving the result.
Record each purchase in your application's database before delivering the result. Use your purchase records to prevent payment reuse and recover delivery if a request fails.
Read the setup guideReady to explore l402 with your Phoenixd node?
Get Started