# Subjects, names and links

> Give subjects optional names and labels, see who your checks name, and walk from a subject to the ones it's checked with.

A subject is anyone or anything your checks name, such as a user, a team, an API key or an agent. A check names it by its kind and ID. A subject needs no setup: it exists once a check names it.

## Names and labels

You can give a subject a name people can read, and labels to filter by. Both are optional, and checks never need them. Names don’t have to be unique, so the app always shows the ID beside a name.

| Field    | What it holds                                                                              |
| -------- | ------------------------------------------------------------------------------------------ |
| `name`   | Up to 200 characters, such as “Design team”.                                               |
| `labels` | Up to 20 keys of up to 40 characters, each with a value of up to 200, such as `plan: pro`. |

Set them with `PATCH /v1/subjects/{subjectKind}/{subjectId}`, never on a check. A field you leave out stays as it is. `null` clears it. Labels you send replace the subject’s labels.

```bash
curl -X PATCH https://api.limitry.com/v1/subjects/team/team_42 \
  -H "Authorization: Bearer $LIMITRY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Design team", "labels": {"plan": "pro"}}'
```

From the CLI:

```bash
limitry subjects update team team_42 --name "Design team" --labels '{"plan": "pro"}'
```

To name many subjects at once, such as when you first connect your user list, send up to 1,000 to `POST /v1/subjects/import`. Limitry checks every item before it saves any.

## Erasing names and labels

`DELETE /v1/subjects/{subjectKind}/{subjectId}/names` erases a subject’s name and labels. It answers `204`, with no body. Its limits, usage and billing date stay, because Limitry keeps them by its ID. Use it when one of your users asks you to delete their data.

You can leave names and labels out and send only IDs, such as `user_123`. Every limit works the same. Please don’t put email addresses or sensitive data in names or labels.

## Who

The **Who** page lists every subject your checks have named in the environment, and every one you named. The most recently checked come first. Filter it by kind or by a label, such as `plan:pro`, and search by name or ID. Click a subject to open its own page.

## A subject’s page

A subject’s page shows:

| Card                                | What it shows                                                                                                 |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| Above and Below, or one card a kind | The subjects its checks name beside it, and what each spent within each budget this period.                   |
| Budgets                             | Every limit on it, and how much of each it has used.                                                          |
| Name and labels                     | Its name and labels. Owners, admins and members can change them in test. In live, only owners and admins can. |
| Recent checks                       | The checks of the last 3 days that named it.                                                                  |

Every subject on the page links to its own page, so you can walk from a user to its team and on to the team’s account.

Limitry learns which subjects your checks name together from the checks, so there’s nothing to set up. When a check names a user and shares a team’s budget, the user’s page lists the team, and the team’s page lists the user. Each budget’s period is its own, such as the team’s month. A minute or hour budget counts by the day in UTC.

A workspace sending a new ID with almost every check could add links without end. Past 20,000 new links in a day, Limitry counts the rest as **Others**.

## From your code or the CLI

| What                                  | API                                                   | CLI                                          |
| ------------------------------------- | ----------------------------------------------------- | -------------------------------------------- |
| List and search subjects              | `GET /v1/subjects`                                    | `limitry subjects list --q design`           |
| One subject: names, budgets and links | `GET /v1/subjects/{subjectKind}/{subjectId}`          | `limitry subjects get team team_42`          |
| Name a subject                        | `PATCH /v1/subjects/{subjectKind}/{subjectId}`        | `limitry subjects update team team_42 …`     |
| Name many subjects                    | `POST /v1/subjects/import`                            | `limitry subjects import --data '…'`         |
| Erase a subject’s name and labels     | `DELETE /v1/subjects/{subjectKind}/{subjectId}/names` | `limitry subjects names delete team team_42` |
| Where a subject stands                | `GET /v1/subjects/{subjectKind}/{subjectId}/standing` | `limitry subjects standing team team_42`     |
| The last 3 days’ checks               | `GET /v1/checks`                                      | `limitry checks list`                        |

`GET /v1/subjects` filters by `kind` and by one `label` as `key:value`, and searches the name or ID with `q`. `GET /v1/checks` takes a `subject` as `kind:id`, and `refused=true` for refused checks only. Both return a page at a time (see [Pagination](/docs/pagination/)). A subject’s `links` say what it spent within each other subject’s budget this period (`within`), and what others spent within its own (`member`).

## Kinds

On **Settings → General**, the **Kinds** card sets how the app names each kind your checks use, such as “Cost center” and “Cost centers” for `cost-center`. Without a name, the app shows the kind as you send it, starting with a capital letter.

The card also puts the kinds in order, from the top level down. With an order, a subject’s page splits the subjects it’s checked with into **Above** and **Below**. Without one, it groups them by kind. The names and the order are labels only: checks and the API keep using the kinds themselves. Owners and admins can change them. To keep them in your repository, list them in `limitry.json` (see [limitry.json](/docs/limitry-json/#kinds)). The card is then locked, except for an override until the next sync.

Names and labels never go in `limitry.json`: a repository’s history would keep a name after you erase it.
