Open protocol · v0.1 · MIT

x402-mesh

The peer-pricelist and referral layer for safe agentic commerce. When an agent hits your paywall, your 402 shows it the whole market, and pays you when it picks a competitor.

402 · POST /v1/validate
{
  "protocol": "x402-mesh/0.1",
  "self": {
    "vendor_id": "startuphub",
    "price": { "amount_cents": 3, "unit": "per_call" }
  },
  "alternatives": [
    { "vendor_id": "hunter", "price": { "amount_cents": 4 },
      "referral_token": "eyJhbGciOiJFZERTQSIsImtpZCI6..." },
    { "vendor_id": "snov",   "price": { "amount_cents": 2 },
      "referral_token": "eyJhbGciOiJFZERTQSIsImtpZCI6..." }
  ],
  "settle": { "url": "/api/x402-mesh/settle" }
}
402 Payment Required
settled · Base
Peer menu

Your 402 lists competitor offerings in the same category, priced and quality-scored, so the agent can compare at the exact moment of payment.

Signed referrals

Each peer carries an ed25519-signed, single-use referral token. The agent picks a peer, the peer verifies it, and you earn a commission.

Atomic settlement

Commissions clear in USDC on Base in one non-custodial transaction. No escrow, no float, no Stripe account, no KYC. Just a wallet address.

Composable identity

Bring your own identity layer. ACK-ID, WIMSE, auth.md. The token carries an optional actor-chain claim; the mesh settles the money.

One handshake, end to end

From paywall to settled commission, in the same request the agent was already making.

01
Agent requests
hits your paid endpoint
02
402 + peer menu
your price + signed peers
03
Agent compares
picks the best fit
04
Agent pays
card or USDC; the referrer gets its cut
05
Settled
redemption logged

Composes with the stack

A thin layer, not a walled garden. x402-mesh rides on existing rails and identity standards rather than replacing them.

Settlement rails
Coinbase x402
USDC on Base
Cloudflare
Stripe / ACP
PayPal
Visa
Identity (bring your own)
Catena ACK-ID
WorkOS auth.md
IETF WIMSE
OAuth Token Exchange
Google A2A
Cisco AGNTCY

One wrapper. That's the install.

Wrap your paid route in withMesh() with a wallet address: it auto-publishes your /.well-known/x402-mesh.json manifest, pulls peers from the registry, and settles commissions in USDC on Base. No Stripe account, no KYC.

Or let your AI agent do it

In Claude Code or Codex, say: “add x402-mesh to my paid API”, it reads our manifest at /.well-known/x402-mesh.json and wires the wrapper + registration for you.

route.ts
import { withMesh } from 'x402-mesh/next';

export const POST = withMesh({
  category: 'email-validation',
  self: {
    vendor_id: 'your-slug',
    name: 'Your API',
    price: { amount_cents: 3, currency: 'USD', unit: 'per_call' },
  },
  alternatives: 'auto',          // fetch peers from the registry
  handler: async (req) => {
    return Response.json({ ok: true }); // runs only after payment
  },
});

Questions