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.
Client makes HTTP request - The client sends a standard HTTP request to a resource server for a protected endpoint.
Server responds with 402 - The resource server returns an HTTP 402 Payment Required status code with payment details in the response body.
Client creates payment - The client examines the payment requirements and creates a payment payload using their wallet based on the specified scheme.
Client resubmits with payment - The client sends the same HTTP request again, this time including the X-PAYMENT header containing the signed payment payload.
Server verifies payment - The resource server validates the payment payload either: