curl
Replace the host with your deployment; everything else is verbatim.
1 — see what it costs
curl -s https://api.example.com/v1/catalog | jq .
# or ask one endpoint directly and read its 402:
curl -s -D - -o /dev/null \
-X POST https://api.example.com/v1/player \
-H 'Content-Type: application/json' \
-d '{"name": "Bijan Robinson", "week": 5}'
# HTTP/1.1 402 Payment Required
# payment-required: eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6W3sic2NoZW1lIjoi...
2 — pay and retry
# PAYMENT_SIGNATURE = base64(JSON PaymentPayload) built by your x402 client
curl -s -D headers.txt \
-X POST https://api.example.com/v1/player \
-H 'Content-Type: application/json' \
-H "PAYMENT-SIGNATURE: $PAYMENT_SIGNATURE" \
-d '{"name": "Bijan Robinson", "week": 5}' | jq .
# settlement receipt:
grep -i '^payment-response:' headers.txt | cut -d' ' -f2 | base64 -d | jq .
# { "success": true, "transaction": "…", "network": "algorand:…", "payer": "…" }
3 — against a mock-mode server (no chain)
A deployment running X402_MODE=mock accepts the literal header value
mock-paid. This is how the demo and this web UI are tested end to
end without touching a wallet.
curl -s -X GET 'https://api.example.com/v1/trending?lookback_hours=24' \
-H 'PAYMENT-SIGNATURE: mock-paid' | jq .verdict