← All Posts

L402 Proof Replay Quickstart: 402 to Paid Retry in 60 Seconds

2026-02-18 — l402, lightning, api, quickstart, mcp

If an API returns 402 Payment Required and then keeps failing on retry auth formats, use /api/proof-replay to generate working replay variants in the right order.

Step 1: Request Invoice

REQ=$(curl -sS -X POST https://maximumsats.com/api/proof-replay \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/api/paid","method":"POST","headers":{"Content-Type":"application/json"},"body":{"prompt":"hello"}}')

echo "$REQ" | jq .
PAYMENT_HASH=$(echo "$REQ" | jq -r '.payment_hash')

Step 2: Pay Invoice

Pay the returned Lightning invoice (7 sats). Keep the same request body and payment_hash.

Step 3: Retry with payment_hash

curl -sS -X POST "https://maximumsats.com/api/proof-replay?payment_hash=${PAYMENT_HASH}" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/api/paid","method":"POST","headers":{"Content-Type":"application/json"},"body":{"prompt":"hello"}}' | jq .

The response includes replay variants in priority order:

  1. query_payment_hash
  2. x_payment_hash_header
  3. authorization_l402_hash
  4. authorization_l402_macaroon_proof (when macaroon/proof provided)

Accepted payment_hash Locations

MCP Mode

Same flow is available via MCP tool proof_replay_generate at /mcp?format=json.

Links

Found this useful?

Send a tip via Lightning. One click, no account needed.

Tip 100 sats ⚡