What is the x402 Settlement Flow?
The x402 settlement flow is the multi-step process by which a client's payment payload is verified, the requested resource is served, and the payment is executed on-chain — typically via a facilitator's /verify and /settle endpoints.
WHY IT MATTERS
The x402 settlement flow follows a deliberate verify-before-settle pattern that protects both parties:
- Client requests resource — standard HTTP GET/POST
- Server returns 402 with PAYMENT-REQUIRED header containing accepted payment requirements
- Client constructs payment payload — selects a matching (scheme, network) pair, signs the payment authorisation (e.g. EIP-3009 for exact/EVM)
- Client re-requests with PAYMENT-SIGNATURE header
- Server forwards to facilitator /verify — confirms signature validity, amount correctness, nonce freshness, and sufficient balance
- Server fulfils request — performs the actual work (returns data, generates tokens, etc.)
- Server calls facilitator /settle — the facilitator submits the pre-signed authorisation on-chain and waits for confirmation
- Server returns 200 with resource body and PAYMENT-RESPONSE header containing transaction hash
This flow means the resource server can trade off settlement speed for payment guarantee. For low-value requests, the server might serve the resource immediately after verification (optimistic settlement). For high-value requests, it might wait for on-chain confirmation before responding.
Cloudflare has also proposed a deferred scheme where settlement happens later in batches — useful for crawlers and high-frequency agents that benefit from aggregated billing.
HOW POLICYLAYER USES THIS
PolicyLayer enforces policies at step 3 — before the client constructs a payment payload. The two-gate architecture validates the payment intent (Gate 1) and verifies the final transaction matches the approved intent (Gate 2), ensuring no tampering between policy approval and on-chain settlement.