Prerequisites
Prerequisites
1. Install the client SDK
- Fetch (TypeScript)
- Axios (TypeScript)
- Go
- Python (httpx)
- Python (requests)
2. Create a wallet signer
The signer authorizes payment transactions from your wallet.- TypeScript (viem)
- Go
- Python
3. Make paid requests
Wrap your HTTP client with x402 payment support. The wrapper automatically detects402 responses, signs a payment with your wallet, and retries the request.
- Fetch (TypeScript)
- Axios (TypeScript)
- Go
- Python (httpx)
- Python (requests)
How it works under the hood
The x402 client wrapper handles the full payment flow transparently:- Your code makes a normal HTTP request.
- If the server responds with
402 Payment Required, the wrapper reads the payment requirements from the response headers. - The wrapper uses your registered scheme and signer to create a signed payment payload.
- The request is retried with the payment attached in a
PAYMENT-SIGNATUREheader. - The server verifies the payment (via the facilitator) and returns the resource.
Error handling
Next steps
- Accepting Payments — add x402 payment middleware to your own API.
- x402 Documentation — full protocol specification and advanced topics.
- x402 Examples — complete working examples on GitHub.