This page explains the roles and responsibilities of the client and server in the x402 protocol.Understanding these roles is essential to designing, building, or integrating services that use x402 for programmatic payments.
Client refers to the technical component making an HTTP request. In practice, this is often the buyer of the resource.Server refers to the technical component responding to the request. In practice, this is typically the seller of the resource
Initiate requests: Send an HTTP request to the resource server.
Handle payment requirements: Read the 402 Payment Required response and extract payment details.
Prepare payment payload: Use the provided payment requirements to construct a valid payment payload.
Resubmit request with payment: Retry the request with the X-PAYMENT header containing the signed payment payload.
Clients do not need to manage accounts, credentials, or session tokens beyond their crypto wallet. All interactions are stateless and occur over standard HTTP requests.
Define payment requirements: Respond to unauthenticated requests with an HTTP 402 Payment Required, including all necessary payment details in the response body.
Verify payment payloads: Validate incoming payment payloads, either locally or by using a facilitator service.
Settle transactions: Upon successful verification, submit the payment for settlement.
Provide the resource: Once payment is confirmed, return the requested resource to the client.
Servers do not need to manage client identities or maintain session state. Verification and settlement are handled per request.