Skip to main content
Checkouts created with the Coinbase Business Checkouts API return an x402_url — a payment endpoint an AI agent or x402 client can pay programmatically. Paying it authorizes a gasless USDC payment on Base (EIP-3009); Coinbase then captures and settles it server-side, with no hosted page, wallet pop-up, or human required. This guide walks through the end-to-end flow: create a checkout, pay its x402_url as an agent, and confirm the checkout completes.
Checkouts use an authorize-then-capture flow. Paying the x402_url authorizes (escrows) the funds; Coinbase captures and settles them server-side. Treat the checkout reaching COMPLETED as the source of truth for settlement — see Confirm settlement.

Prerequisites

  • A Coinbase Business account with a CDP API key. See Authentication.
  • On the paying (agent) side: a CDP account and API keys, and a wallet funded with USDC on Base. The examples below use CdpX402Client, which provisions and signs with a CDP-managed wallet, so no raw private keys are needed.
  • Node.js and npm.

1. Create a checkout

Create a checkout with the Create Checkout endpoint. Authenticate with a JWT Bearer token signed with your CDP API key secret; the rat#view scope is required (see Authentication).
The response includes both a hosted url (for humans) and an x402_url (for agents):

2. Pay the x402_url as an agent

Point an x402 client at the x402_url. It is a POST endpoint: the first request returns 402 Payment Required with the payment requirements, and the client retries with the signed payment. With @x402/fetch, wrapFetchWithPayment handles that challenge-and-retry automatically.
1

Install the client packages

2

Pay the checkout

CdpX402Client defaults to Base mainnet. To test on Base Sepolia, construct it with new CdpX402Client({ environment: "development" }) (or set CDP_X402_CLIENT_ENVIRONMENT=development; the explicit option takes precedence). Only fund the address with the amount you intend to pay.
A successful response means the payment was authorized, not yet settled. Coinbase captures it server-side, moving the checkout ACTIVE → PROCESSING → COMPLETED. Confirm the checkout reaches COMPLETED (next step) rather than treating the HTTP response alone as final. Prefer to pay as a human instead? Open the checkout’s hosted url in a browser, connect a wallet on Base, and approve the (gasless) USDC authorization.

3. Confirm settlement

After the agent authorizes, the checkout transitions ACTIVE → PROCESSING → COMPLETED as Coinbase captures the funds. Poll the Get Checkout endpoint until it reaches a terminal status:
On success, status is COMPLETED and transactionHash holds the on-chain settlement transaction. If the payment cannot be captured, the checkout ends FAILED and any authorization hold is released when the capture window expires. You can also subscribe to webhooks for real-time notifications instead of polling.

Refunds

A COMPLETED or PARTIALLY_REFUNDED checkout can be refunded (fully or partially, up to the remaining amount) with the Refund Checkout endpoint. Refunds are asynchronous — poll the checkout to watch refundedAmount and status (REFUNDED or PARTIALLY_REFUNDED).

Next steps