# Limits API

> The limits endpoints, each in TypeScript, Python, the CLI and curl.

The limits endpoints, each in TypeScript, Python, the CLI and curl.

## Set up

* TypeScript

  ```bash
  npm install @limitry/sdk
  export LIMITRY_API_KEY="lim_test_…"
  ```

* Python

  ```bash
  pip install limitry
  export LIMITRY_API_KEY="lim_test_…"
  ```

* CLI

  ```bash
  npm install -g @limitry/cli
  limitry login
  ```

* curl

  ```bash
  export LIMITRY_API_KEY="lim_test_…"
  ```

To pass the key yourself, use `createClient({ apiKey: key })` in TypeScript or `Limitry(api_key=key)` in Python.

## List limits

`GET /v1/limits`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/GET/limits)

Scope: `limits:read`.

Lists this environment’s active limits, newest first.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const limits = await limitry.limits.list();
  console.log(limits);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  limits = limitry.limits.list()
  print(limits)
  ```

* CLI

  ```bash
  limitry limits list
  ```

* curl

  ```bash
  curl -X GET "https://api.limitry.com/v1/limits" \
    -H "Authorization: Bearer $LIMITRY_API_KEY"
  ```

**Returns:**

```json
{
  "items": [
    {
      "id": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
      "name": "AI budget",
      "subject": {
        "kind": "user",
        "id": null
      },
      "action": "ai-call",
      "amount": 200,
      "unit": "cents",
      "window": "month",
      "every": 1,
      "start": "calendar",
      "rolling": false,
      "enabled": true,
      "archivedAt": null,
      "failMode": "open",
      "lastCheckedAt": "2026-11-06T12:00:00.000Z",
      "setIn": null,
      "override": null,
      "createdAt": "2026-10-04T12:00:00.000Z",
      "updatedAt": "2026-10-04T12:00:00.000Z"
    }
  ],
  "nextCursor": null
}
```

| Field                       | Description                                      |
| --------------------------- | ------------------------------------------------ |
| `limit` number, query       | Items per page, 1–100 (default 25).              |
| `cursor` string, query      | Opaque token from a previous page's nextCursor.  |
| `subjectKind` string, query | Only limits for this subject kind.               |
| `action` string, query      | Only limits for this action.                     |
| `archived` string, query    | Send `true` to list the archived limits instead. |

More about this endpoint

With `archived=true`, it lists the archived ones instead. Filter by `subjectKind` and `action`, and page through the results with the opaque `nextCursor` token.

## Create a limit

`POST /v1/limits`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/POST/limits)

Scope: `limits:write`.

Creates a limit on how much a subject may use per window, such as 200 cents a month for every `user`.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const limit = await limitry.limits.create({
    name: "AI budget",
    subject: {
      kind: "user",
    },
    action: "ai-call",
    amount: 200,
    unit: "cents",
    window: "month",
    every: 1,
    start: "calendar",
  });
  console.log(limit);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  limit = limitry.limits.create(
      name="AI budget",
      subject={"kind": "user"},
      action="ai-call",
      amount=200,
      unit="cents",
      window="month",
      every=1,
      start="calendar",
  )
  print(limit)
  ```

* CLI

  ```bash
  limitry limits create \
    --name 'AI budget' \
    --subject '{"kind":"user"}' \
    --action ai-call \
    --amount 200 \
    --unit cents \
    --window month \
    --every 1 \
    --start calendar
  ```

* curl

  ```bash
  curl -X POST "https://api.limitry.com/v1/limits" \
    -H "Authorization: Bearer $LIMITRY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"name":"AI budget","subject":{"kind":"user"},"action":"ai-call","amount":200,"unit":"cents","window":"month","every":1,"start":"calendar"}'
  ```

**Returns:**

```json
{
  "id": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
  "name": "AI budget",
  "subject": {
    "kind": "user",
    "id": null
  },
  "action": "ai-call",
  "amount": 200,
  "unit": "cents",
  "window": "month",
  "every": 1,
  "start": "calendar",
  "rolling": false,
  "enabled": true,
  "archivedAt": null,
  "failMode": "open",
  "lastCheckedAt": "2026-11-06T12:00:00.000Z",
  "setIn": null,
  "override": null,
  "createdAt": "2026-10-04T12:00:00.000Z",
  "updatedAt": "2026-10-04T12:00:00.000Z"
}
```

| Field                      | Description                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` string              | The limit's name, unique among the environment's active limits. By default, it's the sentence the limit reads as, such as "200 cents per user per month". If another limit already has that name, you get a 409, so send a name of your own.                                                                                                                                                                   |
| `subject` object, required | Who the limit applies to. `{"kind": "user"}` covers every user, and `{"kind": "user", "id": "user_123"}` covers one.                                                                                                                                                                                                                                                                                           |
| `action` string            | The action to limit. Default: `*`, every action.                                                                                                                                                                                                                                                                                                                                                               |
| `amount` number, required  | How many units each subject may use per window.                                                                                                                                                                                                                                                                                                                                                                |
| `unit` string              | What the amount counts, in words. Default: units.                                                                                                                                                                                                                                                                                                                                                              |
| `window` string, required  | The kind of period. `minute`, `hour`, `day`, `week`, `month` and `year` count a period of `every` windows, which resets where `start` says, or rolls when `rolling` is true. `total` is a balance that never resets, and credits raise it. `concurrent` allows at most `amount` open reservations at once.                                                                                                     |
| `every` number             | How many `window` units one period lasts. For example, `window: "month", every: 3` is a quarter, and `window: "hour", every: 5` is five hours. Default: 1.                                                                                                                                                                                                                                                     |
| `start` string             | Where each period begins. `calendar` uses UTC boundaries: midnight, Monday, the 1st or 1 January. `billing_date` counts from the subject's billing date. You set it with `subjects.update`. An annual plan can then still reset monthly. Until a subject has a billing date, its first check stands in for it. `first_use` starts a period at the first check after the previous one ended. Default: calendar. |
| `rolling` boolean          | Whether to count the last `every` windows up to the moment of each check, rather than fixed periods. Only `minute`, `hour` and `day` limits can roll. Default: false.                                                                                                                                                                                                                                          |
| `enabled` boolean          | Whether checks enforce the limit. Default: true.                                                                                                                                                                                                                                                                                                                                                               |
| `failMode` string          | What your code should do when it can't reach Limitry. `open` allows and `closed` refuses. Default: open.                                                                                                                                                                                                                                                                                                       |

More about this endpoint

You only need to send `subject.kind`, `amount` and `window`. `action` defaults to every action (`*`), `unit` to units, and `name` to the sentence the limit reads as. The next check enforces the new limit. You can’t change a limit’s subject, action, unit, window, every, start or rolling after you create it. With a personal access token, the owner and admins can call this. Members can call it in test only, and guests can’t. A workspace API key with this scope can.

## Get a limit

`GET /v1/limits/{limitId}`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/GET/limits/{limitId})

Scope: `limits:read`.

Returns one limit, with who it applies to, its action, its amount and its window.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const limit = await limitry.limits.get("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34");
  console.log(limit);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  limit = limitry.limits.get("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34")
  print(limit)
  ```

* CLI

  ```bash
  limitry limits get lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34
  ```

* curl

  ```bash
  curl -X GET "https://api.limitry.com/v1/limits/lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34" \
    -H "Authorization: Bearer $LIMITRY_API_KEY"
  ```

**Returns:**

```json
{
  "id": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
  "name": "AI budget",
  "subject": {
    "kind": "user",
    "id": null
  },
  "action": "ai-call",
  "amount": 200,
  "unit": "cents",
  "window": "month",
  "every": 1,
  "start": "calendar",
  "rolling": false,
  "enabled": true,
  "archivedAt": null,
  "failMode": "open",
  "lastCheckedAt": "2026-11-06T12:00:00.000Z",
  "setIn": null,
  "override": null,
  "createdAt": "2026-10-04T12:00:00.000Z",
  "updatedAt": "2026-10-04T12:00:00.000Z"
}
```

| Field                            | Description                                                                                                                                        |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limitId` string, path, required | The limit's ID, or its name, such as `AI budget` (URL-encoded). A name matches an active limit in this environment, exactly or else ignoring case. |

## Change a limit

`PATCH /v1/limits/{limitId}`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/PATCH/limits/{limitId})

Scope: `limits:write`.

Changes a limit’s name, amount, fail mode or whether it’s enabled.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const limit = await limitry.limits.update("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34", {
    name: "AI budget",
    amount: 300,
    subject: {
      kind: "user",
    },
    override: {
      reason: "Support incident: raised for a customer",
    },
  });
  console.log(limit);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  limit = limitry.limits.update(
      "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
      name="AI budget",
      amount=300,
      subject={"kind": "user"},
      override={
          "reason": "Support incident: raised for a customer",
      },
  )
  print(limit)
  ```

* CLI

  ```bash
  limitry limits update \
    lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34 \
    --name 'AI budget' \
    --amount 300 \
    --subject '{"kind":"user"}' \
    --override '{"reason":"Support incident: raised for a customer"}'
  ```

* curl

  ```bash
  curl -X PATCH "https://api.limitry.com/v1/limits/lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34" \
    -H "Authorization: Bearer $LIMITRY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"name":"AI budget","amount":300,"subject":{"kind":"user"},"override":{"reason":"Support incident: raised for a customer"}}'
  ```

**Returns:**

```json
{
  "id": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
  "name": "AI budget",
  "subject": {
    "kind": "user",
    "id": null
  },
  "action": "ai-call",
  "amount": 200,
  "unit": "cents",
  "window": "month",
  "every": 1,
  "start": "calendar",
  "rolling": false,
  "enabled": true,
  "archivedAt": null,
  "failMode": "open",
  "lastCheckedAt": "2026-11-06T12:00:00.000Z",
  "setIn": null,
  "override": null,
  "createdAt": "2026-10-04T12:00:00.000Z",
  "updatedAt": "2026-10-04T12:00:00.000Z"
}
```

| Field                            | Description                                                                                                                                                                                                                                |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `limitId` string, path, required | The limit's ID, or its name, such as `AI budget` (URL-encoded). A name matches an active limit in this environment, exactly or else ignoring case.                                                                                         |
| `name` string                    | A new name, unique among the environment's active limits.                                                                                                                                                                                  |
| `amount` number                  | How many units each subject may use per window.                                                                                                                                                                                            |
| `enabled` boolean                | Whether checks enforce the limit.                                                                                                                                                                                                          |
| `failMode` string                | What your code should do when it can't reach Limitry. `open` allows and `closed` refuses.                                                                                                                                                  |
| `subject` object                 | Who the limit applies to. You set it when you create the limit. To change it later, create a new limit and archive this one.                                                                                                               |
| `action` string                  | The action the limit applies to. You set it when you create the limit. To change it later, create a new limit and archive this one.                                                                                                        |
| `unit` string                    | What the amount counts. You set it when you create the limit. To change it later, create a new limit and archive this one.                                                                                                                 |
| `window` string                  | The kind of period. You set it when you create the limit. To change it later, create a new limit and archive this one.                                                                                                                     |
| `every` number                   | How many windows one period lasts. You set it when you create the limit. To change it later, create a new limit and archive this one.                                                                                                      |
| `start` string                   | Where each period begins. You set it when you create the limit. To change it later, create a new limit and archive this one.                                                                                                               |
| `rolling` boolean                | Whether the limit counts the last windows up to each check. You set it when you create the limit. To change it later, create a new limit and archive this one.                                                                             |
| `override` object                | Changes a limit a sync sets, until the next sync puts its values back. Only owners and admins, or a workspace API key, can override. Without it, changing such a limit gets a 409. You can't rename it, because the sync finds it by name. |

More about this endpoint

Checks use the new rule at once. You can’t change a limit’s subject, action, unit, window, every, start or rolling, and a request that tries gets a 400. To count something different, create a new limit and archive this one. A limit a sync sets (its `setIn`) changes only through the sync. A request to change one gets a 409 that names where the sync came from, unless it sends `override` with a reason. An override lasts until the next sync. With a personal access token, the owner and admins can call this. Members can call it in test only, and guests can’t. A workspace API key with this scope can.

## Archive a limit

`POST /v1/limits/{limitId}/archive`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/POST/limits/{limitId}/archive)

Scope: `limits:write`.

Archives a limit, so checks stop enforcing it at once and it leaves the list.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const result = await limitry.limits.archive("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34");
  console.log(result);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  result = limitry.limits.archive("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34")
  print(result)
  ```

* CLI

  ```bash
  limitry limits archive lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34
  ```

* curl

  ```bash
  curl -X POST "https://api.limitry.com/v1/limits/lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34/archive" \
    -H "Authorization: Bearer $LIMITRY_API_KEY"
  ```

**Returns:**

```json
{
  "id": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
  "name": "AI budget",
  "subject": {
    "kind": "user",
    "id": null
  },
  "action": "ai-call",
  "amount": 200,
  "unit": "cents",
  "window": "month",
  "every": 1,
  "start": "calendar",
  "rolling": false,
  "enabled": true,
  "archivedAt": null,
  "failMode": "open",
  "lastCheckedAt": "2026-11-06T12:00:00.000Z",
  "setIn": null,
  "override": null,
  "createdAt": "2026-10-04T12:00:00.000Z",
  "updatedAt": "2026-10-04T12:00:00.000Z"
}
```

| Field                            | Description                                                                                                                                        |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limitId` string, path, required | The limit's ID, or its name, such as `AI budget` (URL-encoded). A name matches an active limit in this environment, exactly or else ignoring case. |

More about this endpoint

Archiving erases nothing. Limitry keeps the limit’s usage history and credits, and `POST /v1/limits/{limitId}/restore` brings it back. With a personal access token, the owner and admins can call this. Members can call it in test only, and guests can’t. A workspace API key with this scope can.

## Restore an archived limit

`POST /v1/limits/{limitId}/restore`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/POST/limits/{limitId}/restore)

Scope: `limits:write`.

Brings an archived limit back.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const result = await limitry.limits.restore("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34");
  console.log(result);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  result = limitry.limits.restore("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34")
  print(result)
  ```

* CLI

  ```bash
  limitry limits restore lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34
  ```

* curl

  ```bash
  curl -X POST "https://api.limitry.com/v1/limits/lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34/restore" \
    -H "Authorization: Bearer $LIMITRY_API_KEY"
  ```

**Returns:**

```json
{
  "id": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
  "name": "AI budget",
  "subject": {
    "kind": "user",
    "id": null
  },
  "action": "ai-call",
  "amount": 200,
  "unit": "cents",
  "window": "month",
  "every": 1,
  "start": "calendar",
  "rolling": false,
  "enabled": true,
  "archivedAt": null,
  "failMode": "open",
  "lastCheckedAt": "2026-11-06T12:00:00.000Z",
  "setIn": null,
  "override": null,
  "createdAt": "2026-10-04T12:00:00.000Z",
  "updatedAt": "2026-10-04T12:00:00.000Z"
}
```

| Field                            | Description                                                                                                                                        |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limitId` string, path, required | The limit's ID, or its name, such as `AI budget` (URL-encoded). A name matches an active limit in this environment, exactly or else ignoring case. |

More about this endpoint

Checks enforce it again if it’s enabled. The API refuses it while an active limit has the same name. With a personal access token, the owner and admins can call this. Members can call it in test only, and guests can’t. A workspace API key with this scope can.

## Sync limits from a list

`POST /v1/limits/sync`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/POST/limits/sync)

Scope: `limits:write`.

Makes the environment’s limits match the list in `limits`, pairing them up by name.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const result = await limitry.limits.sync({
    limits: [
      {
        name: "AI budget",
        subject: {
          kind: "user",
        },
        action: "ai-call",
        amount: 200,
        unit: "cents",
        window: "month",
      },
    ],
    source: "limitry.json",
  });
  console.log(result);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  result = limitry.limits.sync(
      limits=[
          {
              "name": "AI budget",
              "subject": {"kind": "user"},
              "action": "ai-call",
              "amount": 200,
              "unit": "cents",
              "window": "month",
          },
      ],
      source="limitry.json",
  )
  print(result)
  ```

* CLI

  Day to day: `limitry sync [file]`. This endpoint’s own command:

  ```bash
  limitry limits sync \
    --limits '[{"name":"AI budget","subject":{"kind":"user"},"action":"ai-call","amount":200,"unit":"cents","window":"month"}]' \
    --source limitry.json
  ```

* curl

  ```bash
  curl -X POST "https://api.limitry.com/v1/limits/sync" \
    -H "Authorization: Bearer $LIMITRY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"limits":[{"name":"AI budget","subject":{"kind":"user"},"action":"ai-call","amount":200,"unit":"cents","window":"month"}],"source":"limitry.json"}'
  ```

**Returns:**

```json
{
  "dryRun": false,
  "created": [
    "Team credits"
  ],
  "updated": [
    {
      "name": "AI budget",
      "changes": {
        "amount": {
          "from": 200,
          "to": 300
        }
      }
    }
  ],
  "archived": [],
  "unchanged": [
    "API requests per minute"
  ],
  "restored": [],
  "kinds": null
}
```

| Field                    | Description                                                                                                                                                                                                                                                                                                                                                                           |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limits` array, required | Every limit you want, each described in full. An omitted field takes its default, as on create. A sync matches limits by name, so each name must be unique in the list. You can't change a limit's subject, action, unit, window, every, start or rolling under the same name. To change one of them, rename the entry, which creates a new limit. The list holds at most 200 limits. |
| `archiveMissing` boolean | Whether to archive the environment's active limits whose names aren't in `limits`. You can restore them later. Default: false, which leaves them alone.                                                                                                                                                                                                                               |
| `dryRun` boolean         | Whether to report what the sync would do without changing anything. Default: false.                                                                                                                                                                                                                                                                                                   |
| `source` string          | Where these limits come from, such as the file's name or your deploy's. The app and the 409 name it on every limit the sync sets, as in "Set by limitry.json". The CLI sends the file's name. Default: `a sync`.                                                                                                                                                                      |
| `kinds` array            | The workspace's kinds, from the top level down: how the app names each and the order its subject pages use for Above and Below. They replace the workspace's kinds, for test and live alike, so only owners and admins (or a workspace key) can send them. Leave this out to leave the kinds alone. Labels only: checks and the API keep using the kinds themselves.                  |

More about this endpoint

It creates the limits that are missing and changes the ones that differ, where an omitted field means its default. With `archiveMissing`, it also archives the active limits the list doesn’t name. Running it twice changes nothing the second time. Limitry checks the whole list before writing anything. If any entry has a problem, nothing changes, and the 400 lists each problem in `details`. Otherwise Limitry writes every change at once. You can’t change a limit’s subject, action, unit, window, every, start or rolling under the same name, so rename the entry to do that. With `dryRun`, it returns what it would do without writing anything. What a sync sets is locked in the app until the next sync, which names its `source`. This is the call behind `limitry sync`, for keeping your limits in a file in your repository. With a personal access token, the owner and admins can call this. Members can call it in test only, and guests can’t. A workspace API key with this scope can.

## Get a credit

`GET /v1/limits/{limitId}/credits/{creditId}`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/GET/limits/{limitId}/credits/{creditId})

Scope: `limits:read`.

Returns one credit added to a subject’s balance on this limit.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const credit = await limitry.limits.credits.get("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34", "crd_5a8d3f2b-9c1e-4b7a-8f6d-2e0c9b4a1d73");
  console.log(credit);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  credit = limitry.limits.credits.get(
      "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
      "crd_5a8d3f2b-9c1e-4b7a-8f6d-2e0c9b4a1d73",
  )
  print(credit)
  ```

* CLI

  ```bash
  limitry limits credits get \
    lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34 \
    crd_5a8d3f2b-9c1e-4b7a-8f6d-2e0c9b4a1d73
  ```

* curl

  ```bash
  curl -X GET "https://api.limitry.com/v1/limits/lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34/credits/crd_5a8d3f2b-9c1e-4b7a-8f6d-2e0c9b4a1d73" \
    -H "Authorization: Bearer $LIMITRY_API_KEY"
  ```

**Returns:**

```json
{
  "id": "crd_5a8d3f2b-9c1e-4b7a-8f6d-2e0c9b4a1d73",
  "limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
  "subject": {
    "kind": "user",
    "id": "user_123"
  },
  "amount": 5000,
  "note": "October credits",
  "createdByUserId": "usr_9b1d4e7a-2c5f-4a8b-b3e6-7f0d1c2a5e94",
  "createdAt": "2026-11-05T09:00:00.000Z",
  "periodStart": "2026-11-01T00:00:00.000Z",
  "periodEnd": "2026-12-01T00:00:00.000Z"
}
```

| Field                             | Description                                                                                                                                        |
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limitId` string, path, required  | The limit's ID, or its name, such as `AI budget` (URL-encoded). A name matches an active limit in this environment, exactly or else ignoring case. |
| `creditId` string, path, required | The credit's ID.                                                                                                                                   |

## List a balance’s credits

`GET /v1/limits/{limitId}/credits`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/GET/limits/{limitId}/credits)

Scope: `limits:read`.

Lists the credits added to subjects’ balances on this limit, including any taken back, newest first.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const credits = await limitry.limits.credits.list("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34");
  console.log(credits);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  credits = limitry.limits.credits.list("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34")
  print(credits)
  ```

* CLI

  ```bash
  limitry limits credits list lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34
  ```

* curl

  ```bash
  curl -X GET "https://api.limitry.com/v1/limits/lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34/credits" \
    -H "Authorization: Bearer $LIMITRY_API_KEY"
  ```

**Returns:**

```json
{
  "items": [
    {
      "id": "crd_5a8d3f2b-9c1e-4b7a-8f6d-2e0c9b4a1d73",
      "limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
      "subject": {
        "kind": "user",
        "id": "user_123"
      },
      "amount": 5000,
      "note": "October credits",
      "createdByUserId": "usr_9b1d4e7a-2c5f-4a8b-b3e6-7f0d1c2a5e94",
      "createdAt": "2026-11-05T09:00:00.000Z",
      "periodStart": "2026-11-01T00:00:00.000Z",
      "periodEnd": "2026-12-01T00:00:00.000Z"
    }
  ],
  "nextCursor": null
}
```

| Field                            | Description                                                                                                                                        |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limitId` string, path, required | The limit's ID, or its name, such as `AI budget` (URL-encoded). A name matches an active limit in this environment, exactly or else ignoring case. |
| `limit` number, query            | Items per page, 1–100 (default 25).                                                                                                                |
| `cursor` string, query           | Opaque token from a previous page's nextCursor.                                                                                                    |
| `before` string, query           | Start from this moment: items older than it, newest first. Ignored with `cursor`, which already says where to go on.                               |
| `subjectId` string, query        | Only the credits for this subject.                                                                                                                 |

More about this endpoint

Page through them with the opaque `nextCursor`. `before` starts from a moment, and `subjectId` keeps one subject’s credits.

## Add credits to a balance

`POST /v1/limits/{limitId}/credits`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/limits/POST/limits/{limitId}/credits)

Scope: `limits:write`.

Adds `amount` credits for one subject on a limit.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  // Uses the LIMITRY_API_KEY environment variable.
  const limitry = createClient();
  const credit = await limitry.limits.credits.create("lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34", {
    subject: {
      kind: "team",
      id: "team_42",
    },
    amount: 5000,
    note: "October credits",
  });
  console.log(credit);
  ```

* Python

  ```python
  from limitry import Limitry

  # Uses the LIMITRY_API_KEY environment variable.
  limitry = Limitry()
  credit = limitry.limits.credits.create(
      "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
      subject={"kind": "team", "id": "team_42"},
      amount=5000,
      note="October credits",
  )
  print(credit)
  ```

* CLI

  ```bash
  limitry limits credits create \
    lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34 \
    --subject '{"kind":"team","id":"team_42"}' \
    --amount 5000 \
    --note 'October credits'
  ```

* curl

  ```bash
  curl -X POST "https://api.limitry.com/v1/limits/lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34/credits" \
    -H "Authorization: Bearer $LIMITRY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"subject":{"kind":"team","id":"team_42"},"amount":5000,"note":"October credits"}'
  ```

**Returns:**

```json
{
  "id": "crd_5a8d3f2b-9c1e-4b7a-8f6d-2e0c9b4a1d73",
  "limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
  "subject": {
    "kind": "user",
    "id": "user_123"
  },
  "amount": 5000,
  "note": "October credits",
  "createdByUserId": "usr_9b1d4e7a-2c5f-4a8b-b3e6-7f0d1c2a5e94",
  "createdAt": "2026-11-05T09:00:00.000Z",
  "periodStart": "2026-11-01T00:00:00.000Z",
  "periodEnd": "2026-12-01T00:00:00.000Z"
}
```

| Field                            | Description                                                                                                                                        |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limitId` string, path, required | The limit's ID, or its name, such as `AI budget` (URL-encoded). A name matches an active limit in this environment, exactly or else ignoring case. |
| `subject` object, required       | Who gets the credits, such as `{"kind": "team", "id": "team_42"}`.                                                                                 |
| `amount` number, required        | The credits to add, or a negative number to take them back. It can't be 0.                                                                         |
| `note` string                    | Why you added or took back credits. It's required when `amount` is negative.                                                                       |

More about this endpoint

On a balance, a limit whose window is `total`, the credits stay until they’re spent. On a limit that resets, such as one with a `month` window, the credits top up the subject’s current period and end when it resets. That period follows the subject’s billing date when the limit starts there, and the answer’s `periodEnd` says when it ends. A rolling or concurrent limit can’t take credits. A negative `amount` takes credits back, such as after a refund or a chargeback, and needs a `note` saying why. The balance can go below zero, and Limitry then refuses checks until you add more credits. With a personal access token, the owner and admins can add credits. Members can add them in test only. A workspace API key with this scope can add them too. An agent connected through MCP asks a person instead, through the `limit.credit` approval. Limitry keeps a credit’s `Idempotency-Key` forever, so never reuse one for a new credit.
