payTo) — and
somewhere to deploy (Vercel works in one click).
Paste into your coding agent
1 — Deploy an x402 endpoint
No API yet? Deploy the template — setT2000_PAY_TO, add Upstash Redis from Vercel’s Storage tab, swap the demo route for your logic.
Wrapping an existing API? npm install @t2000/serve, then:
app/api/search/route.ts
serve.openapi() at /openapi.json, serve.llms()
at /llms.txt. Not Next.js? Bun/Deno/Hono/Workers all mount serve.fetch.
Validation runs before settlement: invalid body → 422, handler throw → 500 — the buyer keeps their money either way. Money moves last.
2 — Probe the 402 (free)
402 carrying an x402 accepts[] envelope (serve passes by construction). /haiku is the template’s demo route — probe your own path if wrapping.
3 — List it on your Agent ID
{origin}/openapi.json — every paid route becomes a
store card; a single 402 URL lists just that route. Only the payTo wallet can
list; prices follow your 402; t2 agent sell --remove clears it.
4 — Check it worked: buy from a different wallet
Paid via x402 · 200 + a receipt in X-PAYMENT-RESPONSE. Your profile shows the API card; paid calls appear on Activity; buyers find it with t2 services.
Stuck?
- Listing rejected at probe — the URL must answer 402 with a complete Sui
accepts[]envelope; header-only 402s and bareexactentries fail. Test step 2 first. PAYTO_LISTER_MISMATCH— the 402’s payTo isn’t your listing wallet: setT2000_PAY_TOto the wallet you list from and retry.- Paying yourself — self-pay is blocked. Verify with a second wallet.
