x402 with cURL: probe, pay, and test from the terminal

cURL is the quickest way to see what an x402 endpoint actually does: you get the raw 402 envelope, and you can run a free real call without writing any code.

Test an endpoint for free

Add ?trial=1 (or the header X-2s-Trial: 1) to get one free real call per endpoint per hour — the handler runs and returns real data, marked meta.trial:

cURL — free trialbash
# Free trial call — real data, no payment, no signup (1/endpoint/hour):
curl "https://2s.io/api/weather/zip?zip=94103&trial=1"

See the 402 envelope

Call without payment to receive the machine-readable PaymentRequirements. The accepts array lists each settlement rail with the amount, asset, and destination:

cURL — probebash
# 1. Probe with no auth → HTTP 402 + the x402 PaymentRequirements envelope:
curl -i "https://2s.io/api/weather/zip?zip=94103"
# → 402 Payment Required
# → body: { "x402Version": 2, "accepts": [ { ...payTo, maxAmountRequired, network... } ], "error": "..." }

The paid retry

To pay, you sign the quoted authorization and resend with the base64 payload in the PAYMENT-SIGNATURE header (X-PAYMENT also works for v1 clients). Signing requires a wallet library, so in practice you let an SDK build the header — but the wire shape is just one extra header:

cURL — paid retry (shape)bash
curl "https://2s.io/api/weather/zip?zip=94103" \
  -H "PAYMENT-SIGNATURE: <base64 payment payload>"
# → 200 OK + X-PAYMENT-TX: 0x... (on-chain settlement)

Call a live x402 API right now — no signup.

Browse the full endpoint directory, grab the quickstart, or read the llms.txt manifest. Every endpoint is keyless and pay-per-call.

FAQ

How do I test an x402 API without paying?
Append ?trial=1 to the URL (or send header X-2s-Trial: 1). You get one free real call per endpoint per hour on 2s — useful for verifying the response shape before wiring payment.
Can I pay an x402 call with pure cURL?
You can send the paid request with cURL, but building the PAYMENT-SIGNATURE requires signing a payment authorization with a wallet key, which cURL cannot do alone. Use an SDK (or a small signing script) to produce the header, then cURL can send it.
What header carries the payment?
PAYMENT-SIGNATURE (the x402 v2 header). X-PAYMENT is accepted for older v1 clients. The value is a base64-encoded JSON payment payload.

Related

Topics: x402 curl example · x402 curl · x402 test · how to test x402 · x402 payment required curl