How I put a data product behind x402 so AI agents can buy it with USDC
Description and use
Agents cannot complete subscriptions, so the author uses HTTP 402 with payment terms so they can pay with USDC and receive data without accounts.
Problem
AI agents cannot complete traditional subscription sign‑ups or fill out billing forms, making it hard to sell paid data products to them.
Outcome
Agents can purchase data products using only a wallet, without accounts or API keys, by leveraging HTTP 402 responses that encode payment terms and a retry loop.
Workflow
- 1. Agent requests a paid resource without payment. 2. Server responds 402 with machine‑readable payment terms. 3. Agent builds and signs a USDC transfer per the terms, sends it in an X‑Payment header. 4. Server verifies the on‑chain payment and serves the resource. 5. Agent receives the data (JSON leads).
Evidence
Agents can't fill out billing forms. So I put the product behind x402: HTTP 402 "Payment Required", resurrected as a machine checkout.
The 402 body isn't an error page. It's an offer.
Re-verify on every retry.
The MCP server reads the same catalog the 402 endpoint uses, so the menu and the checkout can never disagree.
- Record date: 2026-10-02T03:41:19.120Z