How x402 Works
This page explains the complete payment flow in x402, from initial request to payment settlement.
Overview
x402 enables programmatic payments over HTTP using a simple request-response flow. When a client requests a paid resource, the server responds with payment requirements, the client submits payment, and the server delivers the resource.
Interaction Flow

Clientmakes an HTTP request to aresource serverResource serverresponds with a402 Payment Requiredstatus and aPayment Required ResponseJSON object in the response body.Clientselects one of thepaymentDetailsreturned by theacceptsfield of the server response and creates aPayment Payloadbased on theschemeof thepaymentDetailsthey have selected.Clientsends the HTTP request with theX-PAYMENTheader containing thePayment Payloadto theresource serverResource serververifies thePayment Payloadis valid either via local verification or by POSTing thePayment PayloadandPayment Detailsto the/verifyendpoint of thefacilitator server.Facilitator serverperforms verification of the object based on theschemeandnetworkIdof thePayment Payloadand returns aVerification ResponseIf the
Verification Responseis valid, the resource server performs the work to fulfill the request. If theVerification Responseis invalid, the resource server returns a402 Payment Requiredstatus and aPayment Required ResponseJSON object in the response body.Resource servereither settles the payment by interacting with a blockchain directly, or by POSTing thePayment PayloadandPayment Detailsto the/settleendpoint of thefacilitator server.Facilitator serversubmits the payment to the blockchain based on theschemeandnetworkIdof thePayment Payload.Facilitator serverwaits for the payment to be confirmed on the blockchain.Facilitator serverreturns aPayment Execution Responseto the resource server.Resource serverreturns a200 OKresponse to theClientwith the resource they requested as the body of the HTTP response, and aX-PAYMENT-RESPONSEheader containing theSettlement Responseas Base64 encoded JSON if the payment was executed successfully.
Last updated