Skip to content

CLI

The Limitry command-line interface (CLI) lets you set up your limits and try them from a terminal or a script. You can create a limit, try a check, and see who is using what. It acts as you, in the workspaces you allow.

Terminal window
npm install -g @limitry/cli
Terminal window
limitry login

Your browser opens. Sign in and choose which workspaces the CLI may use. Keep Manage limits, which every command in this guide needs, then click Allow. The CLI creates a personal access token for this computer and stores it in ~/.config/limitry/. The token lasts 90 days. You’ll find the token under Account → Personal access tokens.

On a server or in CI there’s no browser, so pass a token instead. Create it with Manage limits under Account → Personal access tokens. Set it in the environment and the CLI writes nothing to disk, or use login --token to save it the same way a browser sign-in does. A workspace API key works too. It acts in its own workspace, so you don’t choose one.

Terminal window
LIMITRY_TOKEN=pat_… limitry whoami # a personal access token
LIMITRY_TOKEN=lim_test_… limitry limits list # a workspace API key
limitry login --token "$TOKEN" # or save it (or: echo "$TOKEN" | limitry login)

limitry logout revokes the token and forgets it.

Create a limit, in test:

Terminal window
limitry limits create --name "AI budget" --subject '{"kind":"user"}' \
--action ai-call --amount 200 --unit cents --window month

Check a user, as your code would, for a reply that costs 5 cents:

Terminal window
limitry check user:user_123 ai-call --cost 5
# Allowed. AI budget: 195 cents left, resets 2026-11-01T00:00:00.000Z

See where a user stands, without counting anything:

Terminal window
limitry subjects standing user user_123

See who is using a limit now, and its usage over time:

Terminal window
limitry usage subjects --limit-id lmt_123
limitry usage query --limit-id lmt_123 --granularity day

When a limit is right, copy it to live from the Limits page in the app, or create it with --environment live.

Terminal window
limitry workspace list
limitry workspace use acme # the default for later commands
limitry workspace audit-events list --workspace other-co # one call elsewhere

Commands act in test unless you say otherwise, so a mistake changes test limits, never the ones your customers depend on. To act in live, name it for one command, for a shell, or as the default:

Terminal window
limitry limits list --environment live # one command
export LIMITRY_ENVIRONMENT=live # this shell
limitry environment use live # the default from now on
limitry environment # which one, and where it came from
limitry environment unset # back to test

--environment wins over LIMITRY_ENVIRONMENT, which wins over the default you set. After every command that calls the API, it prints Environment: test or Environment: live on stderr, so you always know which side it changed. Stdout stays the command’s output. With --json, an error’s JSON carries environment too. See Test and live.

The commands come in groups, by what they work on:

Terminal window
limitry limits list
limitry limits create --name "AI budget" --subject '{"kind":"user"}' \
--action ai-call --amount 200 --unit cents --window month
limitry checks create --subject '{"kind":"user","id":"user_123"}' \
--action ai-call --cost 5
limitry limits archive lmt_123

Two everyday commands have shortcuts. Each sends the same request as its long form:

Shortcut Long form
limitry check <kind>:<id> <action> limitry checks create --subject '{…}' --action <action>
limitry sync [file] limitry limits sync [file]

limitry check prints one line: allowed or refused, what’s left, and when it resets. It takes --cost, and --shared <kind>:<id> once for each shared subject. A refusal exits 5, so a script can stop on it: limitry check user:user_123 ai-call && run-job. For a reservation, use limitry checks create --mode reserve. limitry sync keeps your limits in a file, as Sync limits from GitHub shows. limitry sync --dry-run shows what a sync would change, and changes nothing. limitry sync - reads the file from standard input. limitry.json has the details.

  • limitry --help lists the groups. limitry limits --help lists the commands in a group. --help after any command lists its options.
  • A list prints one page, and its last line gives the --cursor for the next one. --all prints every page.
  • A field that takes a list takes its flag once for each value, such as --event-type a --event-type b. Commas work too: --event-type a,b.
  • A yes-or-no field takes --x and --no-x. A field you can empty takes --clear-<field>.
  • A command that can’t be undone asks for --yes.

Every command:

General

limitry login
Sign in through the browser, or store a personal access token with --token
limitry logout
Revoke the stored token and forget it
limitry whoami
Show who the token acts as and which workspaces it can use
limitry config
Show the settings in effect, with the token hidden
limitry sync [file]
Short for `limitry limits sync`
limitry check <subject> <action>
Short for `limitry checks create`
limitry api <method> <path>
Call any API endpoint directly, in the selected workspace

Checks

limitry checks create
Check whether a subject may act
limitry checks list
List checks

Limits

limitry limits archive <limit-id>
Archive a limit
limitry limits create
Create a limit
limitry limits credits create <limit-id>
Add credits to a balance
limitry limits credits get <limit-id> <credit-id>
Get a credit
limitry limits credits list <limit-id>
List a balance's credits
limitry limits get <limit-id>
Get a limit
limitry limits list
List limits
limitry limits restore <limit-id>
Restore an archived limit
limitry limits sync [file]
Make your limits match a file (shortcut: limitry sync)
limitry limits update <limit-id>
Change a limit

Usage

limitry usage overview
Get every limit's usage at once
limitry usage query
Get a limit's usage over time
limitry usage subjects
List who is using a limit

Subjects

limitry subjects get <subject-kind> <subject-id>
Get a subject
limitry subjects import
Name many subjects
limitry subjects list
List subjects
limitry subjects names delete <subject-kind> <subject-id>
Erase a subject's name and labels
limitry subjects reset <subject-kind> <subject-id>
Reset a subject's limits
limitry subjects standing <subject-kind> <subject-id>
Get where a subject stands
limitry subjects update <subject-kind> <subject-id>
Update a subject

Reservations

limitry reservations commit <reservation-id>
Commit a reservation
limitry reservations extend <reservation-id>
Extend a reservation
limitry reservations get <reservation-id>
Get a reservation
limitry reservations release <reservation-id>
Release a reservation

Environment

limitry environment list
Show the environment commands act in
limitry environment use <name>
Make <name> the default environment for commands
limitry environment unset
Forget the environment you chose and use the workspace's default

Workspace and team

limitry workspace list
List the workspaces the token can act in
limitry workspace use <slug>
Make <slug> the default workspace for workspace commands
limitry workspace approval-actions list
List the actions you can ask approval for
limitry workspace approval-requests create
Ask a person to approve an action
limitry workspace approval-requests get <approval-request-id>
Check an approval request
limitry workspace approval-requests redeem <request-id>
Collect an approved secret once, into an env file (never printed)
limitry workspace audit-events list
List workspace audit events
limitry workspace event-types list
List event types
limitry workspace get
Get the current workspace
limitry workspace invitations list
List pending invitations
limitry workspace members list
List workspace members
limitry workspace plan-usage get
Show your plan's usage this period
limitry workspace teams list
List teams
limitry workspace webhook-deliveries list <endpoint-id>
List an endpoint's deliveries
limitry workspace webhook-deliveries redeliver <endpoint-id> <delivery-id>
Redeliver an event
limitry workspace webhook-endpoints create
Add a webhook endpoint
limitry workspace webhook-endpoints delete <endpoint-id>
Remove a webhook endpoint
limitry workspace webhook-endpoints enable <endpoint-id>
Re-enable a webhook endpoint
limitry workspace webhook-endpoints get <endpoint-id>
Get a webhook endpoint
limitry workspace webhook-endpoints list
List webhook endpoints
limitry workspace webhook-endpoints test <endpoint-id>
Send a test event
limitry workspace webhook-endpoints update <endpoint-id>
Update a webhook endpoint

Personal access tokens

limitry user me
Get the current user
limitry user revoke-token
Revoke the token making this request

Add --json to any command, and it prints exactly the JSON the API returns to stdout. Errors then go to stderr as JSON, in the API’s error envelope plus the HTTP status:

Terminal window
limitry limits list --json | jq '.items[].name'
{
"error": {
"code": "forbidden",
"message": "…",
"status": 403,
"requestId": "…",
"docs": "https://limitry.com/docs/errors/#forbidden"
}
}

When the API refused a field, the error’s details says what is wrong with each one. Without --json, the CLI prints each detail and the docs link on stderr.

The exit code says how a command ended:

Code Meaning
0 Success.
1 A failure, such as the API refusing the call.
2 Wrong usage, such as a missing flag or an unknown command.
4 You aren’t logged in, or the API refused your token.
5 Limitry refused a limitry check.

Every command calls the same public API your code uses, signed in with your personal access token.

  • A command that calls one API operation links to it in the list above. Under Endpoints, each operation shows its command next to the same call in TypeScript, Python and curl.
  • Ids in an operation’s path become the command’s arguments, and its other inputs become flags. --data '{…}' sends a whole JSON body.
  • Every write sends an idempotency key. If an attempt fails, the CLI retries it with the same key. To run a command again without repeating its writes, pass the same --idempotency-key <key> both times.
  • limitry api <method> <path> calls any endpoint directly.
  • --base-url <url>, or the LIMITRY_BASE_URL environment variable, points the CLI at another API address. Give the address without /v1.