Checks API
The checks endpoints, each in TypeScript, Python, the CLI and curl.
Set up
Section titled “Set up”npm install @limitry/sdkexport LIMITRY_API_KEY="lim_test_…"pip install limitryexport LIMITRY_API_KEY="lim_test_…"npm install -g @limitry/clilimitry loginexport LIMITRY_API_KEY="lim_test_…"To pass the key yourself, use createClient({ apiKey: key }) in TypeScript or Limitry(api_key=key) in Python.
Check whether a subject may act
Section titled “Check whether a subject may act”POST /v1/checks Try it in the API playground (opens in a new tab) Scope: checks:write.
Asks whether subject may do action at cost, given every enabled limit that applies.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();const check = await limitry.checks.create({ subject: { kind: "user", id: "user_123", }, action: "ai-call", cost: 5,});console.log(check);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()check = limitry.checks.create( subject={"kind": "user", "id": "user_123"}, action="ai-call", cost=5,)print(check)Day to day: limitry check <kind>:<id> <action>. This endpoint’s own command:
limitry checks create \ --subject '{"kind":"user","id":"user_123"}' \ --action ai-call \ --cost 5curl -X POST "https://api.limitry.com/v1/checks" \ -H "Authorization: Bearer $LIMITRY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"subject":{"kind":"user","id":"user_123"},"action":"ai-call","cost":5}'Returns:
{ "allowed": true, "reason": null, "limits": [ { "limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34", "limitName": "AI budget", "unit": "cents", "window": "month", "rolling": false, "failMode": "open", "amount": 200, "remaining": 195, "resetsAt": "2026-12-01T00:00:00.000Z" } ], "retryAfterSeconds": null, "reservation": { "id": "rsv_WyJ1c2VyIiwidXNlcl8xMjMiXQ_9f2c4e1a7b3d4c8e9a0f1b2c3d4e5f6a", "expiresAt": "2026-11-06T12:05:00.000Z" }}| Field | Description |
|---|---|
subject | Who is acting, such as {"kind": "user", "id": "user_123"}. |
shared | Shared subjects the check also draws from, such as a team's, an organization's or a project's pool. Send at most 4. Every limit on every subject must fit, and Limitry charges either all of them or none. |
action | What the subject wants to do. |
cost | The units the action would use. Default: 1. |
mode | How the check counts. consume decides and counts, and is the default. preview decides without counting anything. reserve decides and holds cost, your estimate, until you commit the actual amount or release it. The response's reservation names what it holds. Only a reservation takes a slot of a concurrent limit. |
ttlSeconds | With reserve, how many seconds the reservation lasts before it releases itself. Default: 300. At most 3600. |
More about this endpoint
In consume mode, it also counts the use. Every decision returns 200, whether it’s allowed or refused, so read allowed. limits shows what’s left on each limit, and retryAfterSeconds says when to try again. With an Idempotency-Key header, a retried check gets the same decision for an hour and counts only once. We cache its API key check briefly for speed. A revoked key can keep working here for up to 60 seconds.
List checks
Section titled “List checks”GET /v1/checks Try it in the API playground (opens in a new tab) Scope: limits:read.
Lists the checks of the last 3 days, newest first, with every subject each one named and whether Limitry allowed it.
import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.const limitry = createClient();const checks = await limitry.checks.list();console.log(checks);from limitry import Limitry
# Uses the LIMITRY_API_KEY environment variable.limitry = Limitry()checks = limitry.checks.list()print(checks)limitry checks listcurl -X GET "https://api.limitry.com/v1/checks" \ -H "Authorization: Bearer $LIMITRY_API_KEY"Returns:
{ "items": [ { "checkedAt": "2026-11-21T14:32:08.000Z", "action": "ai-call", "cost": 5, "unit": "cents", "mode": "consume", "subjects": [ { "kind": "user", "id": "user_123", "name": "Sara Khan" } ], "allowed": false, "refusedBy": { "limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34", "limitName": "Team AI budget", "subject": { "kind": "user", "id": "user_123", "name": "Sara Khan" } } } ], "nextCursor": null}| Field | Description |
|---|---|
limit | Items per page, 1–100 (default 25). |
cursor | Opaque token from a previous page's nextCursor. |
before | Start from this moment: items older than it, newest first. Ignored with cursor, which already says where to go on. |
subject | Only checks that named this subject, as kind:id. |
refused | true for only refused checks. |
More about this endpoint
A refused check says whose budget refused it. Name a subject as kind:id for only the checks that named it, or set refused for only refused ones. Send before to start from a moment. Limitry keeps the last 3 days, and at most 100,000 checks in each environment. Results come a page at a time.