x402 payment protocol

Pay per request with USDC on Base — no account required. The x402 protocol for machine-to-machine API payments.

Overview

ShopSniffer supports the x402 payment protocol for pay-per-request API access. Send a request without any auth headers, and the server responds with 402 Payment Required and on-chain payment details. Pay the quoted amount in USDC on Base, attach the payment proof to a retry, and your job is created. No account, no API key, no browser session — ideal for autonomous AI agents and one-shot integrations.

At a glance

Protocolx402 (HTTP 402 revival)
Network
TokenUSDC ( 0 USDC )
Recipient 0x7671...a9D9
Price$9.99 per POST /api/jobs call
Auth requiredNone

How the flow works

1

Send request without auth

Send a normal POST /api/jobs request. Do not include X-API-Key or Authorization headers — if you do, the server will use that auth method instead and skip x402 entirely.

2

Receive 402 Payment Required

The server responds with HTTP 402 and an x402 object in the body describing what to pay, where, and in which token:

json
{ "error": "Payment Required", "x402": { "version": "1", "accepts": [{ "scheme": "exact", "network": "base", "maxAmountRequired": "9990000", "resource": "https://shopsniffer.com/api/jobs", "payTo": "0x767131d92c41D56546eC72fecD0F1d63900fa9D9", "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }] } }

asset is the USDC contract address on Base. maxAmountRequired is in the token's smallest unit (USDC has 6 decimals, so 9990000 = $9.99).

3

Make the USDC payment

Use a wallet with USDC on Base. Transfer $9.99 to the payTo address. The x402 spec defines a signed message format you'll construct from the payment details — the x402/client library handles this for you.

4

Retry with the payment proof

Set the X-PAYMENT header with the signed payment proof and repeat the original request. The server verifies the payment on-chain and, if valid, accepts the job.

5

Job created

You receive a normal 201 response with the job object. From here it's identical to any other authenticated job — poll status, subscribe to the WebSocket, fetch the report.

Payment details

All payments settle on . You don't need to hold any specific token as long as you can get USDC onto Base — bridge from Ethereum, Arbitrum, Optimism, or any other L2 if needed.

Token contract: 0x8335...2913

Recipient: 0x7671...a9D9

Amount: 0 USDC per job

Code example

Using the official x402/client helper, the whole flow collapses to a single function call:

typescript
import { withX402Payment } from "x402/client"; const response = await withX402Payment( "https://shopsniffer.com/api/jobs", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ domain: "allbirds.com", webhook_url: "https://your-server.com/callback" }), }, wallet, // EVM wallet with USDC on Base ); const { job } = await response.json(); console.log(`Job ${job.id} created`);

The helper handles the 402 response, builds the signed payment, sends it on-chain, and retries with X-PAYMENT. Your code doesn't need to see any of the wire protocol.

For a full end-to-end walkthrough including wallet setup and debugging failed settlements, see the x402 tutorial.

Only POST /api/jobs accepts x402

x402 is wired on the job creation endpoint only — read endpoints are free and don't need payment. Specifically:

  • POST /api/jobs — accepts x402
  • POST /api/shops, POST /api/api-keys, PATCH /store-detail/:slug/frequency — require a Better Auth session; no x402 path

If you need persistent identity (tracked shops, saved API keys), use an API key or sign up with Better Auth instead.

Next steps

x402 tutorial

End-to-end walkthrough: wallet funding, first 402, paying, debugging.

Learn More
Authentication

Compare x402 with API keys and Better Auth sessions.

Learn More
Jobs API

Full POST /api/jobs reference including the 402 response shape.

Learn More
Buying a report

Stripe and AnySpend alternatives for one-off purchases.

Learn More
Ask a question... ⌘I