live on Bitcoin mainnet

The open Lightning
facilitator for x402

Accept HTTP 402 payments over the Lightning Network. Register a wallet, get a merchant ID — your server handles the rest.

register & start accepting payments
# 1. Register your Lightning wallet (one-time)
curl -X POST https://x402.albylabs.com/register \
  -d '{"nwcSecret":"nostr+walletconnect://..."}'
# → { "merchantId": "3f2a…" }

# 2. Add payment middleware to your resource server
app.use(paymentMiddleware({
  "GET /resource": {
    scheme: "exact",  network: "lightning:mainnet",
    price: { amount: "21", asset: "sat" },
    extra: { merchantId: "3f2a…" }
  }
}));
Payment flow

How it works

Lightning requires invoices to exist before payment. This facilitator bridges that gap transparently within the x402 protocol.

01

Client requests a protected resource

HTTP request with no payment — the middleware intercepts it.

02

Fresh BOLT11 invoice is generated

The resource server calls POST /invoice — the facilitator looks up the NWC secret from Redis and creates the invoice on demand.

03

HTTP 402 returned to client

Response includes the BOLT11 invoice and paymentHash in PaymentRequirements.extra.

04

Client pays and receives a preimage

Any Lightning wallet pays the invoice. The payment preimage serves as cryptographic proof.

05

Verify and settle

POST /verify checks sha256(preimage) == paymentHash — instant, no network call. POST /settle confirms via NWC.

06

Resource delivered

Payment confirmed. The protected content is served.

REST API

Endpoints

Standard x402 facilitator interface, extended with Lightning-specific endpoints for invoice management.

POST
/register
Register a Lightning wallet via NWC connection string. Returns a stable merchantId. Credentials stay server-side.
public
POST
/invoice
Generate a fresh BOLT11 invoice for a registered merchant. Called by your resource server before returning HTTP 402.
lightning
GET
/invoice/:paymentHash
Look up a stored invoice by payment hash. Invoices self-expire via Redis TTL.
lightning
POST
/verify
Verify a payment payload. Checks sha256(preimage) == paymentHash — instant cryptographic verification, no network call.
x402
POST
/settle
Settle a verified payment. Confirms settled_at via NWC lookup_invoice.
x402
GET
/supported
Returns supported payment schemes and networks for capability discovery.
x402
Design

Built for production

A minimal surface area — no accounts, no API keys, no complex configuration.

01

Nostr Wallet Connect

Works with any NWC-compatible wallet. Grant make_invoice and lookup_invoice only — the facilitator can never move funds.

02

Secrets stay server-side

Your NWC string is stored in Redis behind an opaque UUID. Clients only ever see the merchantId — never your credentials.

03

Redis-backed storage

Merchant registry and invoice store backed by persistent Redis. Invoices self-expire via TTL — no cron jobs, no cleanup logic.

04

Multi-tenant

One facilitator, any number of merchants. Each wallet registers independently and receives an isolated identity.

05

Instant verification

The verify step is pure cryptography — no Lightning node call. Settlement confirms via NWC only after verification passes.

06

Open standard

Built on the open x402 spec. Compatible with any x402 client or resource server — not locked to this facilitator.

Get started

Start accepting payments

Register your Lightning wallet and add one middleware call to your server.

Try the live demo

Hit /demo/resource — it returns a real HTTP 402 with a BOLT11 invoice. Pay it with any Lightning wallet to receive the resource.