Tollstile

Introduction

Tollstile is open-source payment middleware for APIs, MCP tools, and AI agents.

Public Beta · early access

Tollstile adds paid access to any API route or MCP tool. Define who pays, how much, and which payment protocols you accept — Tollstile handles quotes, verification, replay protection, receipts, refunds, and reconciliation, without taking custody of your funds or your data.

import { createTollstile, memoryLedger, testRail } from "tollstile";
import { tollstile } from "@tollstile/hono";

const toll = createTollstile({ rails: [testRail()], ledger: memoryLedger() });

app.get("/weather", tollstile(toll.price("$0.01")), (c) => c.json({ forecast: "clear" }));

An agent that calls /weather without paying gets 402 Payment Required with a signed quote and an offer for every rail you accept. An agent that pays gets the response, and your ledger records the charge.

Public Beta — early access

Every package is on npm at 0.1.2. The API and payment behavior may change before v1.0. x402 and MPP's Stripe rail have been verified against real providers in test environments, on Base Sepolia and in Stripe test mode; the other rails are tested against fakes, published test vectors, and reference implementations, and some are still experimental. Use the test rail during development and introduce live rails gradually — each rail's page states its verification status.

What you get

How it fits

request ─► adapter ─► access policies ─► rail verification ─► requirements ─► handler
                        subscriber           x402 · MPP ·         limit ·
                        credits              L402 · KYAPay        verifiedAgent ·
                        payPerCall                                userMandate
                                   │
                                   ▼
                     ledger: authorizations · charges · claims
  • Rails decide how an agent pays.
  • Access policies decide whether a caller has to pay.
  • Requirements add conditions every admitted request must meet.
  • The ledger is your operational record, reconciled with each provider.

Tutorials

Using a coding agent?

Point it at /llms.txt and the coding agents guide, or ask it directly:

Add $0.05 pay-per-call pricing to this Hono endpoint using Tollstile.

On this page