HTTP 402 Payment Required status code for micropayment flows. The pattern:
- Client calls a protected endpoint
- Server responds
402 Payment Requiredwith a payment quote - Client pays (typically stablecoin, on-chain)
- Client retries with a payment proof
- Server verifies and returns the real response
The request/response dance
First call — no payment:The SDK shortcut
The SDK wraps all of this into one call:/v1/x402/pay, retry with X-Payment-Proof.
Serving x402 endpoints (API provider side)
Register your x402 endpoint so Sly can facilitate payments:receiver_wallet_id and issues the payment_proof that the API will verify.
Verifying proofs (API provider side)
When your server receives a request withX-Payment-Proof:
{ "valid": true, "payment_id": "..." } or a failure reason. The SDK and Sly server-side middleware handle this for you.
x402 facilitator (sandbox only)
Sandbox endpoints have a test facilitator that issues mock proofs without real on-chain settlement:x402 bridge
Sly includes an x402 → Circle bridge for tenants that want to accept x402 payments but settle in fiat. Bridges are configured per-endpoint.Endpoints
| Endpoint | Purpose |
|---|---|
POST /v1/x402/pay | Execute payment for an x402 quote |
POST /v1/x402/verify | Verify a payment proof |
POST /v1/x402/endpoints | Register an x402-priced API endpoint |
GET /v1/x402/endpoints | List registered endpoints |
GET /v1/x402/analytics/* | Payment and usage metrics |
POST /v1/x402/facilitator/* | Sandbox facilitator (testing only) |
POST /v1/x402/bridge/* | On-chain → fiat bridging |
When to use x402
- You run an API and want per-call monetization (not subscriptions)
- Consumers are agents that discover and pay for APIs at runtime — no sign-up flow
- Price points are too low for traditional billing (fractions of a cent per call)
- You want crypto-native settlement with no card networks in the loop
