When limits reset
A limit’s allowance resets at the end of each period. Three settings decide when:
| Setting | Decides | Example |
|---|---|---|
window |
The unit: minute, hour, day, week, month or year |
month |
every |
How many units a period lasts (default 1) | every: 3 with month is a quarter |
start |
Where each period begins | calendar, billing_date or first_use |
How often your customers pay doesn’t matter here. An annual plan can still reset its allowance every month. You can’t change any of the three settings once a limit exists. To change one, create a new limit and archive the old one. See What can change.
The examples on this page give each team credits that its members spend on reports, at 25 credits a report. These credits come back each period. A prepaid balance is different, because it never resets. See Pools, balances and budgets.
On the calendar
Section titled “On the calendar”start: "calendar" is the default. Periods begin on UTC boundaries,
the same for every subject.
dayat midnight,weekon Monday,monthon the 1st,yearon 1 January.every: 3withmonthresets on 1 January, April, July and October.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();
const limit = await limitry.limits.create({ name: "Quarterly credits", subject: { kind: "team" }, action: "report", amount: 15000, unit: "credits", window: "month", every: 3,});console.log(limit.id);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()
limit = limitry.limits.create( name="Quarterly credits", subject={"kind": "team"}, action="report", amount=15000, unit="credits", window="month", every=3,)print(limit.id)limitry limits create --name "Quarterly credits" --subject '{"kind":"team"}' \ --action report --amount 15000 --unit credits --window month --every 3curl -X POST https://api.limitry.com/v1/limits \ -H "Authorization: Bearer $LIMITRY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name":"Quarterly credits","subject":{"kind":"team"},"action":"report", "amount":15000,"unit":"credits","window":"month","every":3}'On each subject’s billing date
Section titled “On each subject’s billing date”start: "billing_date" resets each subject on its own date, its
billing date. A team that subscribed on 17 March resets on the 17th
of every month. Set a subject’s billing date when its subscription
starts, usually from your billing webhook. Send it as billingAnchorAt to
PATCH /v1/subjects/{subjectKind}/{subjectId}.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();
const limit = await limitry.limits.create({ name: "Monthly credits", subject: { kind: "team" }, action: "report", amount: 5000, unit: "credits", window: "month", start: "billing_date",});console.log(limit.id);
// When the team's subscription starts (Stripe's start_date is in seconds)const subject = await limitry.subjects.update("team", "team_42", { billingAnchorAt: new Date(1773757800 * 1000).toISOString(),});console.log(subject);from datetime import datetime, timezone
from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()
limit = limitry.limits.create( name="Monthly credits", subject={"kind": "team"}, action="report", amount=5000, unit="credits", window="month", start="billing_date",)print(limit.id)
# When the team's subscription starts (Stripe's start_date is in seconds)subject = limitry.subjects.update( "team", "team_42", billing_anchor_at=datetime.fromtimestamp(1773757800, tz=timezone.utc).isoformat(),)print(subject)- No billing date yet: the day of the subject’s first counted check
becomes its billing date, so
billing_datelimits work before you set one. A reservation counts as a check here, even one you release later. - Annual plans: an annual subscription that started on 17 March still resets a monthly allowance on the 17th of every month. Set the billing date once, when the subscription starts.
- Month ends: a billing date on the 31st resets on the last day of shorter months, then on the 31st again. A billing date on 29 February resets on 28 February in other years.
- A new billing date never hands out a fresh allowance. The current period runs on until the new date, and what the subject used in it still counts. From then on, periods follow the new date. To start a fresh period now, for an upgrade or a re-subscribe, set the new date and then reset now.
limitry subjects get team team_42 shows a subject’s billingAnchorAt, the moment its periods start from. In
the SDKs, it’s limitry.subjects.get("team", "team_42").
From first use
Section titled “From first use”start: "first_use" starts a period at a subject’s first check and
resets it a period later. Nothing runs while the subject is idle. This
is how AI chat products allow “45 messages per 5 hours, starting from
your first message”.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();
const limit = await limitry.limits.create({ name: "Messages per 5 hours", subject: { kind: "user" }, action: "chat", amount: 45, window: "hour", every: 5, start: "first_use",});console.log(limit.id);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()
limit = limitry.limits.create( name="Messages per 5 hours", subject={"kind": "user"}, action="chat", amount=45, window="hour", every=5, start="first_use",)print(limit.id)Before a subject’s first check, its resetsAt is null. The check
that starts the period already tells you when that period ends. A
reservation starts the period too, even one you release later.
Reset now
Section titled “Reset now”Reset a subject’s allowance at once, for goodwill, a promotion or
support. Name one limit, or send {} to reset every limit on the
subject.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();
const reset = await limitry.subjects.reset( "team", "team_42", { limitId: "lmt_3f0c…" }, { idempotencyKey: "ticket-8812" },);console.log(reset);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()
reset = limitry.subjects.reset( "team", "team_42", limit_id="lmt_3f0c…", idempotency_key="ticket-8812",)print(reset)- The schedule doesn’t move, and the next reset is still the usual one.
- A balance (
total) goes back to its amount. Credits added before the reset no longer count. - A reset leaves
concurrentlimits alone. Their slots belong to work that’s still running. - With an idempotency key, a repeated request resets once.
In the app, the owner and admins can click Reset next to a subject on the Usage page, and members can in test.
Stacking limits
Section titled “Stacking limits”Every limit that matches a check applies, and each resets on its own schedule. A $2 AI budget a month with a daily cap against abuse is two limits.
| Limit | amount (cents) |
window |
start |
|---|---|---|---|
| AI budget | 200 | month |
billing_date |
| Daily cap | 50 | day |
calendar |
Once a user has spent 50 cents in a day, Limitry says no until the next day. That’s true even with budget left for the month. See Offer a free plan with a daily cap.
What responses show
Section titled “What responses show”A check’s limits[].resetsAt and
subjects.standing say when that subject’s
own period ends. For billing_date and first_use limits, that’s
different for every subject. The Usage page’s Right
now table shows each subject’s use and refusals in its own current
period, resets included.