- Building an agent that autonomously pays for API services.
- Adding x402 payments to an application backend.
- Building a managed wallet or payment flow for your users.
Building a browser or full-stack payment flow? Use
x402 payments with Embedded Wallets when users should pay
from their own self-custodial wallets.Want an agent to pay without writing payment code? Start with
Agentic Accounts.
402 response, and the payment that follows.
Prerequisites
- A CDP API key and wallet secret. The wallet secret lets the SDK sign payments with your CDP wallet.
- Node.js 22 or later.
1. Install the SDKs
The CDP SDK handles the wallet. The x402 packages handle the protocol.- TypeScript
- Python
2. Write the client
The client resolves a CDP-managed wallet, prints the address that pays, and then requests a protected endpoint. The wrapper handles the402 response, payment, and retry.
- TypeScript
- Python
CdpX402Client provisions the wallet and registers payment schemes for you, then plugs
into wrapFetchWithPayment from @x402/fetch.3. (Optional) Fund the wallet
Run the client once:- TypeScript
- Python
- TypeScript
- Python
4. Make the paid call
Wait for the faucet transaction to confirm, then run the client again:HTTP 200 means the payment was verified and settled, and you received the protected resource.
You paid for an API without an account, an invoice, or a card.
Runnable examples
Complete versions of the client include faucet funding and settlement details:- TypeScript
- Python
What to read next
You paid a service you already knew about. To find services you don’t, browse the catalog in Discover services. Where you go next depends on what you are building:- Building an app. Let your users pay from their own wallets with x402 payments in Embedded Wallets.
- Building an agent. Start with an Agentic Wallet, or carry discovery and payment over MCP with Discover & pay over MCP.
- Need spend limits or an existing x402 client? See Client configuration.