Back to Academy
Level 1-210 min
Quickstart Guide
Make your first x402 payment in 3 steps. Discover, call, pay.
What is x402?
HTTP status 402 means "Payment Required". The x402 protocol uses this to create a payment flow: your agent calls an API, gets a 402 response with pricing info, signs a USDC payment using EIP-712 typed data, and retries with the signed payment in the X-PAYMENT header. The server verifies the signature, settles the payment on Base L2, and returns the API response.
No API keysNo subscriptionsInstant settlement
1
Discover a service
Search the marketplace for what your agent needs. Discovery is always free.
TypeScript
const res = await fetch('https://402bazaar.com/api/v1/discover?q=weather');
const { services } = await res.json();
const service = services[0]; // { slug: "weather-api", priceUsdc: "0.001" }2
Call the proxy
Call the service through the 402bazaar.com proxy. You'll get a 402 Payment Required response.
TypeScript
const res = await fetch(`https://402bazaar.com/api/v1/proxy/${service.slug}`);
// → 402 Payment Required
// → X-PAYMENT-REQUIRED header with pricing details3
Sign USDC and retry
Sign an EIP-712 USDC payment and send it in the X-PAYMENT header. Done!
TypeScript
const payment = await signUsdcPayment(service.priceUsdc);
const res = await fetch(`https://402bazaar.com/api/v1/proxy/${service.slug}`, {
headers: { 'X-PAYMENT': btoa(JSON.stringify(payment)) }
});
const data = await res.json(); // → Weather data!