Pools, balances and budgets
Pools, balances and budgets aren’t separate features. Each one is an ordinary limit, used in a particular way. Pools and balances use one example. Customers buy credits that their whole team spends, at 25 credits a report.
Pools: an allowance a team shares
Section titled “Pools: an allowance a team shares”Put the limit on the shared subject, for example 5,000 credits a month
for each team. Then name the team on each user’s check.
{ "subject": { "kind": "user", "id": "user_123" }, "shared": [{ "kind": "team", "id": "team_42" }], "action": "report", "cost": 25}The check must fit every limit on the user and every limit on the team. It charges all of them, or none. However many of the team’s users check at the same moment, nobody can overspend the pool. This holds even when Limitry spreads a busy workspace’s counts across several of its servers. A check whose subjects sit on different servers is still all or nothing. It takes about 40 to 60 milliseconds longer, because it saves on each server in turn. You can name up to 4 shared subjects, such as a team, its organization and a project.
When a shared subject’s limit refuses the check, reason.subject in
the answer names it, and reason.message says so. On the Usage page,
the user’s row names it too. A check counts once on your plan, however
many subjects it names.
Balances: prepaid credits
Section titled “Balances: prepaid credits”Set the window to total. The amount is the starting balance, and it
never resets. When a team buys 5,000 credits, add them to its balance.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();
const credit = await limitry.limits.credits.create("lmt_3f0c…", { subject: { kind: "team", id: "team_42" }, amount: 5000, note: "October credits",});console.log(credit);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()
credit = limitry.limits.credits.create( "lmt_3f0c…", subject={"kind": "team", "id": "team_42"}, amount=5000, note="October credits",)print(credit)limitry limits credits create lmt_3f0c… --subject '{"kind":"team","id":"team_42"}' \ --amount 5000 --note "October credits"curl -X POST https://api.limitry.com/v1/limits/$LIMIT_ID/credits \ -H "Authorization: Bearer $LIMITRY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "subject": { "kind": "team", "id": "team_42" }, "amount": 5000, "note": "October credits" }'In the app, open the balance’s ⋮ menu on the Limits page and
choose Credits. Limitry keeps a record of every credit you add or
take back. The dialog shows the latest five, and See all credits
lists every one by day. limitry limits credits list <limit-id> lists
them too.
When a balance runs out, the check’s retryAfterSeconds is null,
because waiting won’t help and only more credits will. The owner and
admins can add credits, and members can in test. An AI agent connected
through MCP asks instead, and someone who could add the credits
approves the limit.credit request. A coding agent that
uses your own token or the command line acts as you.
To take credits back after a refund or a chargeback, send a negative amount with a note that says why.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();
const credit = await limitry.limits.credits.create("lmt_3f0c…", { subject: { kind: "team", id: "team_42" }, amount: -5000, note: "Refund of order 1042",});console.log(credit);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()
credit = limitry.limits.credits.create( "lmt_3f0c…", subject={"kind": "team", "id": "team_42"}, amount=-5000, note="Refund of order 1042",)print(credit)limitry limits credits create lmt_3f0c… --subject '{"kind":"team","id":"team_42"}' \ --amount -5000 --note "Refund of order 1042"curl -X POST https://api.limitry.com/v1/limits/$LIMIT_ID/credits \ -H "Authorization: Bearer $LIMITRY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "subject": { "kind": "team", "id": "team_42" }, "amount": -5000, "note": "Refund of order 1042" }'If the customer already spent those credits, the balance goes below zero. Checks then get a no until more credits bring it back above zero. In the app, choose Take back in the Credits dialog.
Top-ups: more for this period
Section titled “Top-ups: more for this period”A limit that resets can take credits too. Say each team gets 5,000 runs a month, and a team buys a pack of 5,000 more. Add the pack to the limit the same way, and it tops up the team’s current month.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();
const topUp = await limitry.limits.credits.create( "lmt_9a2e…", { subject: { kind: "team", id: "team_42" }, amount: 5000, note: "Pack of 5,000 runs", }, { idempotencyKey: "cs_live_a1B2c3" },);console.log(topUp.periodEnd);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()
top_up = limitry.limits.credits.create( "lmt_9a2e…", subject={"kind": "team", "id": "team_42"}, amount=5000, note="Pack of 5,000 runs", idempotency_key="cs_live_a1B2c3",)print(top_up.period_end)limitry limits credits create lmt_9a2e… --subject '{"kind":"team","id":"team_42"}' \ --amount 5000 --note "Pack of 5,000 runs" --idempotency-key cs_live_a1B2c3curl -X POST https://api.limitry.com/v1/limits/$LIMIT_ID/credits \ -H "Authorization: Bearer $LIMITRY_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: cs_live_a1B2c3" \ -d '{ "subject": { "kind": "team", "id": "team_42" }, "amount": 5000, "note": "Pack of 5,000 runs" }'| Rule | What happens |
|---|---|
| Which period | The subject’s current one, the period that holds when Limitry adds the credits. On a limit that starts on a billing date, it’s the subject’s own period. |
| What it adds | The credits add to that period alone. What the team already used still counts: 4,800 used of 5,000, plus a 5,000 top-up, leaves 5,200. |
| When it ends | At the period’s reset. Credits left over don’t carry into the next period. periodEnd in the answer says when that is. |
| Bought near the end | The credits still end at the reset. If you sell packs, tell your customer when they end. |
| Paying twice | Use the payment’s id as the idempotency key, such as a Stripe Checkout Session’s id. Limitry keeps the key, so a webhook delivered twice adds the credits once. |
| Which limits | A limit with a fixed period, such as day, month or year. A rolling or concurrent limit can’t take credits. On a limit that starts at first use, the period must have started. |
A subject’s standing (limitry.standing()) keeps amount as the
limit’s own number and adds credited, this period’s top-ups. The period
allows amount plus credited, and remaining already counts them. To
show “4,800 of 10,000 runs used”, show used of amount + credited.
On the Usage page, what each team used stays the same after a top-up, and its credits show in what’s left. The Credits dialog on the limit’s ⋮ menu lists each top-up with the day it ends. To take a top-up back after a refund, send a negative amount with a note, as for a balance. It comes off the current period.
Budgets: a spending cap for an agent
Section titled “Budgets: a spending cap for an agent”A budget is a limit counted in money. For example, you might give every AI agent in your product $5 a day, across everything it spends on models and paid tools.
| Field | Value |
|---|---|
| Subject | agent (every agent, or one) |
| Action | * |
| Unit | cents |
| Amount | 500 |
| Window | day, or total for one-off |
Each check passes the step’s price in cents as cost, with an action
such as tool. When you don’t know the price up front,
reserve what it will probably cost and commit
what the call actually cost. Once the agent has used up its budget,
every check gets a no until the window resets. For a balance, that
lasts until you add credits. With a total budget, the agent can ask a
person for more credits through the limit.credit approval.
The Give AI agents a budget guide puts this together end to end.