Skip to main content
You are building a wallet, an agent, or a script that pays for services. By the end of this page you will have found a paid endpoint on the Bazaar, paid for it, received the resource, and seen what a failure looks like. Everything else in the buyer docs expands on the pieces this page introduces.

Prerequisites

  • Node.js 22+ (or an equivalent runtime with the @stellarx402/client SDK)
  • A Stellar wallet keypair funded with Testnet USDC (faucet)
  • The facilitator URL (https://facilitator.stellarx402.com for the hosted version)

1. Install the client SDK

2. Search the Bazaar

3. Pay for the resource

That is a complete paid request. fetchWithPayment handles the 402 challenge, builds and signs the payment, retries with the X-Payment header, and returns the resource response.

4. Handle a rejection

Not every payment will succeed, and the difference between “you are out of budget” and “that endpoint no longer exists” matters when nobody is watching your agent. Every rejection has a stable machine-readable code:
Full list: Error & Rejection Codes.

Where to go next

Searching the Bazaar

Filters, ranking, and pagination for the discovery API.

Handling Rejections

Every machine-readable reason a payment can fail, and how an agent should react to each one.

Budgets & the Upto Scheme

Cap what an agent can spend across a session or per-tool, using smart account contracts.

MCP Integration for Agents

Wire the Bazaar and the payment client into an MCP-speaking agent runtime.