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:
query_payment_hashx_payment_hash_headerauthorization_l402_hashauthorization_l402_macaroon_proof(when macaroon/proof provided)
Accepted payment_hash Locations
body.payment_hash?payment_hash=...query parameterX-Payment-HashheaderAuthorization: L402 <payment_hash>
MCP Mode
Same flow is available via MCP tool proof_replay_generate at /mcp?format=json.