GuideUpdated 2026-07-31

Charge for your API per call

Subscription billing forces you to guess a bundle: 10,000 calls a month, three tiers, an enterprise 'contact us'. Most of your prospective buyers — increasingly, autonomous agents — want one thing: call the endpoint N times, pay for exactly N.

HTTP 402 payments (the x402 protocol) turn each request into its own transaction. No account creation, no key rotation, no dunning emails, no unused-quota resentment.

The mechanics

A request without payment receives a 402 response carrying a challenge: the price in integer cents, the settlement asset, and the facilitator that verifies payment. The buyer signs a payment authorization, retries with an X-PAYMENT header, and the server settles it on-chain before (or as) it serves the response. Settlement on Base costs the seller nothing through the ArisPay facilitator.

Three integration depths

No-code: the hosted proxy fronts your existing deployment. One dependency: the paygate middleware for Express or Fastify, one line per priced route. Scaffolded: `npx paygate init` generates a fresh seller in Express, Fastify, Next.js, Hono, Workers, or FastAPI.

Express — one line per priced route
app.get("/api/quote", pw({ priceCents: 1 }), handler);

Why this beats metered API keys

Metered keys still require the buyer to create an account, add a card, and trust your meter. Per-call payment settles trust cryptographically per request, makes your product callable by software that cannot fill in a signup form, and cuts your billing surface to zero.

Not sure whether agents can already find and pay your service? Run the free readiness scan first — it inspects your public contracts, agent documentation, and payment support in under 30 seconds.

Pricing guidance

  • Start with cost-plus: (upstream + compute cost per call) × 2–5. You can tune it any time — the price lives in the 402 challenge, not in buyers' contracts.
  • One price per route. If callers want bulk discounts, that's a signal to publish a cheaper, coarser endpoint — not to build a discount ladder.

FAQ

What if I also want human customers on subscriptions?
Run both. x402 gates specific routes; your existing auth and billing for human dashboards is untouched.
Is 1 cent the minimum price?
Yes — prices are integer cents by design, which keeps money handling exact and auditable end to end.

Is your service agent-ready?

Run the free readiness scan — it inspects your live endpoint's discoverability, machine-readable contracts, and payment support, then tells you the highest-impact fix.

How to Charge for an API Per Call — Without Subscriptions | ArisPay