Selling products to people and agents? The
Business Checkouts API creates one
checkout with a hosted payment URL for people and an
x402_url for agents. Use it to support
both payment flows without running your own x402 server or facilitator. See
Accept agentic payments with x402.Charging for an MCP tool instead? Follow Charge over MCP. This
quickstart covers HTTP routes.Prerequisites
- A CDP API key. The API key authenticates your server to the CDP Facilitator for verify and settle. It does not decide where funds land.
- A
payToaddress that can receive the asset on each network you advertise. The CDP Facilitator settles on multiple EVM networks and on Solana: one EVM address covers every EVM network you list; Solana needs a separate Solana address. Examples in this guide use a single EVM address on Base Sepolia. See Pay-to address. - Node.js 22 or later.
Pay-to address
SetX402_PAY_TO to an onchain address that can receive the asset. Use one you
already control: a CDP custodial wallet, a
CDP non-custodial wallet,
Coinbase Prime,
Coinbase Business, a Coinbase retail
deposit address, or a wallet you custody. This guide uses Base Sepolia; switch to
a mainnet address in production. See
Configure who receives payment.
1. Install the SDKs
The CDP SDK authenticates the facilitator. The x402 packages handle the protocol and the framework middleware.- TypeScript
- Python
2. Price a route
The following servers charge $0.01 forGET /report and settle to X402_PAY_TO.
- TypeScript
- Python
createX402Server connects to the CDP Facilitator, registers payment schemes, and
returns a server object that any x402 framework adapter accepts. payToConfig with
type: "address" sends funds to the address you provide.routes is protected; everything else stays free. To accept Solana
as well, pass solana on payToConfig (a Solana address, not the EVM one) and include a
solana: network on the route. See
supported networks.Alternative: let CDP provision an API Key Wallet
Alternative: let CDP provision an API Key Wallet
If you do not already have a receiving address, CDP can create one. This replaces
the address path above rather than adding to it: the SDK provisions an
API Key Wallet — the API key variant of CDP
non-custodial wallets — and that wallet’s address becomes your
payTo. It is not
required to sell over x402.Instead of exporting X402_PAY_TO, add a
wallet secret:- TypeScript
- Python
In The rest of the file is unchanged;
server.ts, delete the payTo lookup and its throw, and drop payToConfig
so createX402Server provisions the wallet:server.payToEvmAddress reports the
provisioned address.3. Start the server and confirm x402 is set up
In a new terminal, start the server:- TypeScript
- Python
402 Payment Required response confirms that the route is protected.
4. Test the payment
Choose either testing path:- Ask your agent to use the
Pay for Service skill with
http://localhost:8402/report. - Build a basic client with the buyer quickstart, then point its
request at
http://localhost:8402/report.
HTTP 200.
5. Move to production
After the test payment succeeds, switch the route to a mainnet before accepting real payments:- TypeScript
- Python
networks list switch from Base Sepolia and Solana Devnet to Base
and Solana mainnets.payTo address can receive funds on its mainnet — for example your
Coinbase Business, Prime, or entity deposit address, not a testnet wallet. Dollar prices
such as "$0.01" automatically use the network’s default USDC asset. If you specify a
token address and amount directly, replace any testnet asset address with its mainnet
equivalent and verify its decimals.
See Production configuration for custom networks, assets,
receiving destinations, and payment schemes.
Runnable examples
Complete versions of the server cover more frameworks:What to read next
Your endpoint is priced and paid. The next step is making it discoverable.- What settled your payment? CDP Facilitator covers the supported networks, schemes, and pricing.
- Need production networks, another scheme, or a different receiving destination? See Production configuration.