npm packages are not installable yet: [email protected] can be published after 2026-09-16 10:30 UTC. Details
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

Tollstile and its rails are implemented and tested against fakes, published test vectors, and reference implementations. The API and payment behavior may change before v1.0, and some rails are still experimental and may be unstable in production. Use the test rail during development and introduce live rails gradually. Nothing is on npm yet; 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