Understanding x402
What is x402?
What is x402?
Is x402 a Coinbase product?
Is x402 a Coinbase product?
Why not use API keys or a checkout page?
Why not use API keys or a checkout page?
Do my customers need to know anything about crypto?
Do my customers need to know anything about crypto?
Is x402 ready for production?
Is x402 ready for production?
Can I run x402 alongside my existing billing?
Can I run x402 alongside my existing billing?
Cost and money movement
What does x402 cost me end to end?
What does x402 cost me end to end?
What counts as one billable facilitator transaction?
What counts as one billable facilitator transaction?
Who pays network gas?
Who pays network gas?
Where do payments land, and how do I get to USD?
Where do payments land, and how do I get to USD?
payTo address configured on the route. CDP never holds your
revenue, so converting to fiat is a separate step: see
Offramp for withdrawing to a bank account, or
Coinbase for Agents for converting USDC to USD inside a
Coinbase account.How do refunds work? What about disputes and chargebacks?
How do refunds work? What about disputes and chargebacks?
exact or upto are irreversible once settled, so there are no
chargebacks. That protects sellers from fraud reversals and puts the burden on buyers to
choose who they pay, which is why spend limits matter on the buyer side. To refund, send a
transfer back to the payer address from the settlement record.How do I handle receipts and accounting?
How do I handle receipts and accounting?
PAYMENT-RESPONSE header on the successful
response carries the transaction reference for that payment. The cleanest place to record it is
a lifecycle hook: onAfterSettle on a server, or the client’s post-payment hook. There is no
invoicing or reconciliation product in CDP today.For signed, auditable records rather than log lines, the protocol’s offer-receipt extension
has the server sign the offer and the receipt. It works with the CDP Facilitator, because it is
negotiated between client and server and does not involve the facilitator, but you register it
yourself: the CDP SDK does not enable it by default.Compliance and trust
What screening does the CDP Facilitator run?
What screening does the CDP Facilitator run?
kyt_risk_detected, so the buyer never
loses funds and the seller never delivers the resource. Screening runs at both verification and
settlement, and checks the payer and the recipient. See
A payment was declined by screening.Can a facilitator alter or redirect my payment?
Can a facilitator alter or redirect my payment?
Do I have to hold or expose a private key?
Do I have to hold or expose a private key?
Getting started
Which path should I use?
Which path should I use?
Do I need to run a server to sell something?
Do I need to run a server to sell something?
x402_url that an agent or x402 client can pay
directly, with no server, wallet, or facilitator setup on your side. See
Accept x402 payments.Why do I need three credentials?
Why do I need three credentials?
CDP_API_KEY_ID and CDP_API_KEY_SECRET authenticate your application to the CDP Facilitator
for verification and settlement. CDP_WALLET_SECRET lets the SDK provision and sign with a
CDP-managed wallet, which is why both quickstarts need it. Sellers who receive to an address
they already control can set payToConfig to address and skip the wallet secret.Where do I get test funds?
Where do I get test funds?
requestFaucet in the SDK. Use the CDP
faucet rather than a third-party one: it funds the same wallets the CDP Facilitator settles
against. One faucet request covers a long testing session, since a typical test route costs a
cent or less per call.What is eip155:8453? (CAIP-2 network IDs)
What is eip155:8453? (CAIP-2 network IDs)
eip155:{chainId}, so Base is eip155:8453
and Base Sepolia is eip155:84532. Solana networks are solana:{genesisHash}. The discovery
APIs also accept the older plain names such as base and normalize them. The full list of
networks CDP supports is in
the facilitator’s advanced section.Do I use the CDP SDK or the @x402 packages?
Do I use the CDP SDK or the @x402 packages?
@x402 packages own the protocol mechanics and the framework
adapters. On TypeScript, CdpX402Client and createX402Server wrap the two together, so most
integrations never touch the @x402 packages directly. Reach for them yourself when you are
fitting CDP into code you already have:
buyer,
seller.Does x402 work with POST requests and request bodies?
Does x402 work with POST requests and request bodies?
402
response. If you want agents to find and call a POST route through the Bazaar, describe the
body with an explicit schema so they can construct a valid request. See
Add richer discovery metadata.Language and framework support
Which languages and frameworks are supported?
Which languages and frameworks are supported?
x402 packages and pass a CDP-managed
wallet and create_facilitator_config() into it, which is what the Python tabs in both
quickstarts show. Go can use the x402 Go SDK against the CDP Facilitator, but the CDP SDK has
no x402 helpers and no Go examples, which is why the quickstarts have no Go tab.Framework support comes from the x402 packages: Express, Hono, Next.js, and Fastify on
TypeScript; FastAPI and Flask on Python; Gin, Echo, and net/http on Go. Clients cover Fetch
and Axios on TypeScript, httpx and requests on Python, and net/http on Go.Why does the Python client use EthAccountSigner?
Why does the Python client use EthAccountSigner?
ExactEvmScheme expects an x402 signer interface, and an eth_account object declares
sign_typed_data differently. EthAccountSigner adapts one to the other. The scheme applies
the same wrap for you if you pass an eth_account object directly, so writing it out is a
matter of making the adaptation visible rather than a requirement. See
step 2 of the buyer quickstart.Can I implement x402 in another language?
Can I implement x402 in another language?
Pricing and payment schemes
How should I price my endpoint?
How should I price my endpoint?
upto instead of guessing
an average.Should I use exact, upto, or batch-settlement?
Should I use exact, upto, or batch-settlement?
exact when you know the price before the request runs, which covers most endpoints. Use
upto when cost depends on the work done, such as tokens generated or compute time: the buyer
authorizes a ceiling and you settle the actual amount. batch-settlement is for workloads
where per-request settlement is itself too expensive, and it costs you a payment channel to
operate, so reach for it only when volume justifies that.createX402Server does not register batch-settlement today. Server support was withdrawn
because the scheme registered without running the channel settle lifecycle, which could accept
a buyer’s payment without paying the receiver. Buyer-side support is unaffected. Configuration
for the other two is in
Choose a payment scheme.Which schemes work on which networks?
Which schemes work on which networks?
exact, upto, and
batch-settlement. On Solana it handles exact. upto is defined only for EVM in the
protocol itself, so that limit is not specific to CDP. The current matrix is in
the facilitator’s advanced section.Will every buyer be able to pay my route?
Will every buyer be able to pay my route?
CdpX402Client
registers exact and upto on Base by default, or Base Sepolia in development. A buyer paying
on Polygon, Arbitrum, World, or Solana, or paying with batch-settlement, has to opt in
through networkSchemes. If you accept payment on more than one network, the buyer picks from
what your route advertises and what their client registered. See
payment schemes.Which tokens can I accept?
Which tokens can I accept?
Can I mix free and paid routes on one server?
Can I mix free and paid routes on one server?
routes require payment, and every other path on the server
is untouched. Route keys are method and path pairs such as GET /reports, so you can charge
for one method on a path and leave another free.Can I do subscriptions, invoicing, or holds?
Can I do subscriptions, invoicing, or holds?
upto for
variable charges within a ceiling, and issuing prepaid credits in your system that an x402
payment tops up.Buyers and agents
Do agents need wallets?
Do agents need wallets?
How do spend limits work?
How do spend limits work?
CdpX402Client accepts spend controls that cap a single payment (maxAmountPerPayment) and
total spend over a rolling window (maxCumulativeSpend with maxCumulativeSpendWindow), and
that restrict which networks, assets, and payees the agent may pay. Spend is reserved before
the payment goes out and confirmed or released once settlement is known. If the outcome is
unclear, the reservation stands, so the guardrail errs toward the agent spending less than its
limit rather than more.A blocked payment throws SpendControlError with a code of per_payment_cap,
cumulative_cap, network_not_allowed, asset_not_allowed, payee_not_allowed,
amount_unparseable, already_applied, configuration_invalid, or
ledger_capacity_exceeded. Spend controls are TypeScript only; there is no Python equivalent.
See Set spend limits.How do I know a Bazaar listing is safe to pay?
How do I know a Bazaar listing is safe to pay?
validate_endpoint before paying an unfamiliar resource, and set spend limits so a bad listing
costs a bounded amount rather than a wallet balance. See
Discover with the Bazaar MCP server
and Set spend limits.Should my agent pay over HTTP or MCP?
Should my agent pay over HTTP or MCP?
PAYMENT-REQUIRED and PAYMENT-SIGNATURE headers, while MCP returns a
tool result with isError: true and carries the payment in _meta["x402/payment"]. Nothing
about pricing, schemes, or settlement changes between the two.Can I sign a payment without making an HTTP request?
Can I sign a payment without making an HTTP request?
signX402Payment(paymentRequired, acceptedIndex),
which returns a signed payload you can send over any transport. Smart accounts support exact
only and cannot sign Permit2 payloads. There is no runnable example for this path yet, so the
SDK reference is the best source.What can Coinbase for Agents do today?
What can Coinbase for Agents do today?
Discovery and the Bazaar
How do I get my endpoint listed?
How do I get my endpoint listed?
createX402Server declares Bazaar metadata for your routes
automatically; deploy the endpoint on public HTTPS, validate it, and complete one successful
paid call through the CDP Facilitator. See the
Get discovered checklist.Does my endpoint need discovery metadata?
Does my endpoint need discovery metadata?
How long until my endpoint appears? Are testnet endpoints indexed?
How long until my endpoint appears? Are testnet endpoints indexed?
Can MCP tools be discovered in the Bazaar?
Can MCP tools be discovered in the Bazaar?
type to return one or the other. Indexing works the same way it
does for HTTP: a settled payment triggers it, and the facilitator opens a session against your
server to read the payment requirements. createX402Server only declares Bazaar metadata
automatically for HTTP routes, so an MCP server declares its own. See
Charging for tool calls.How do I update or remove my listing?
How do I update or remove my listing?
402. The next successful payment indexes the
resource again with the new metadata, so there is nothing to submit and no cache to clear by hand.There is no delisting mechanism. An endpoint that stops receiving traffic ranks lower over time
and eventually stops appearing in search results, and an endpoint that stops responding to the
facilitator’s periodic checks is marked inactive.Should I discover services with the SDK, the REST API, or MCP?
Should I discover services with the SDK, the REST API, or MCP?
Going to production
What changes between development and production?
What changes between development and production?
environment to "production", which moves the server to Base and Solana mainnet and the
client to Base mainnet. Note that "production" is the default: omitting the option entirely
means real funds, not testnet. Then fund the receiving wallet, serve over public HTTPS, move
your API key and wallet secret into real secret storage, and revalidate the endpoint so the
Bazaar indexes the mainnet resource. On Python there is no environment switch, so update the
CAIP-2 network IDs on each registration by hand. See
Choose your environment.Where should payments land?
Where should payments land?
payToConfig takes three forms. eoa, the default, has CDP provision and hold the keys for a
standard account. smart uses a CDP Smart Contract Wallet, which supports owner rotation and
policy controls and needs an owner account. address sends payments to an address you already
control, including a multi-signature wallet or an exchange deposit address, and does not need
CDP_WALLET_SECRET at all. EVM and Solana are separate addresses in every case. See
Configure who receives payment.How do I know a payment settled?
How do I know a payment settled?
PAYMENT-RESPONSE header with the settlement result, including
the transaction reference and, for upto, the amount actually charged. For server-side
logging and alerting, the hooks that matter are onAfterSettle and onSettleFailure; add
onVerifyFailure if you want to see rejected payments. See
Lifecycle hooks.Can a retry charge the buyer twice?
Can a retry charge the buyer twice?
exact, so a second attempt with the same authorization fails at verification or settlement
instead of moving funds again. Retrying is safe.What a retry cannot tell you is whether the first attempt succeeded, since a settlement that
times out may still have landed onchain. Resolve that by confirming the transaction reference
rather than by counting attempts. See
Settlement problems.If you want request-level idempotency on top of that, so that a repeated call returns the
original response rather than an error, the protocol’s payment-identifier extension gives the
client an idempotency key to send. It works with the CDP Facilitator, because it is negotiated
between client and server, but you register it yourself: the CDP SDK does not enable it by
default.Are there rate limits or an SLA on verify and settle?
Are there rate limits or an SLA on verify and settle?
429 if you exceed
it, but ordinary payment traffic does not approach the limit. If you expect a burst large enough
to worry about, talk to us in Discord.Protocol details
What headers does x402 use?
What headers does x402 use?
X-PAYMENT and X-PAYMENT-RESPONSE and put requirements in the
response body. Seeing those names in an error usually means a version mismatch between client
and server.What are extensions, and which does CDP support?
What are extensions, and which does CDP support?
createX402Server registers them by default,
so most sellers get discovery without configuring anything.Extensions that only involve the client and the server work with the CDP Facilitator too, since
the facilitator never sees them. That includes sign-in-with-x, payment-identifier, and
offer-receipt, all implemented in the x402 SDKs. You register those yourself.Can I use a different facilitator, or run my own?
Can I use a different facilitator, or run my own?
Where is the specification?
Where is the specification?