npm packages are not installable yet: [email protected] can be published after 2026-09-16 10:30 UTC. Details
Tollstile

Let subscribers through without paying

Give active subscribers free access to paid routes while everyone else pays per call.

Public Beta · early access
import { payPerCall, subscriber } from "tollstile";
import { tollstile } from "@tollstile/hono";

const subscribers = subscriber({
  active: async (principal) => plans.isActive(principal.id),
});

app.get(
  "/v1/search",
  tollstile(toll.price("$0.01", { access: [subscribers, payPerCall()] }), {
    principal: (c) => (c.get("user") ? { id: c.get("user").id } : null),
  }),
  search,
);
  • Policies run in order. The first that grants access wins; payPerCall() asks for payment.
  • Callers without a principal are skipped by subscriber().
  • If access is set and no policy grants access or asks for payment, the request is denied with 403.
  • Subscriber access records no charge — there is no economic effect.

Combine with credits: access: [subscribers, credits({ balance }), payPerCall()].

Retries

Subscriber grants create no charge, so Idempotency-Key does not prevent a free request from running again. Requests that fall through to credits or a rail follow Idempotency.

On this page