# Labels

Labels: the ones in use, and adding and removing them on a task.

## List labels

`GET /orgs/{org}/labels`

Scope: `tasks:read`

The labels in use on tasks you can open, in alphabetical order, each with how many of those tasks carry it. q narrows them to labels containing the text.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]

### Query parameters

- `limit` (integer): How many items a page holds, 1 to 200. [from 1 to 200; default 50]
- `cursor` (string): The next_cursor of the previous page; leave it out for the first page. [at most 1000 characters]
- `q` (string): Only labels containing this text. [at most 255 characters]

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/labels" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "items": [
    {
      "name": "pricing",
      "tasks": 4
    }
  ],
  "next_cursor": null
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Get a task's labels

`GET /orgs/{org}/tasks/{task}/labels`

Scope: `tasks:read`

The labels on the task.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `task` (string, required): The task's id or key (WEB-12). [1 to 60 characters]

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/labels" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "labels": [
    "pricing",
    "q1"
  ]
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Add and remove a task's labels

`PATCH /orgs/{org}/tasks/{task}/labels`

Scope: `tasks:write`

Adds and removes labels without reading them first, as editing the Labels field in the app: needs Edit tasks, the Labels field on the task's type, and the task not archived. Written in History; watchers are told.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `task` (string, required): The task's id or key (WEB-12). [1 to 60 characters]

### Body

- `add` (array of string): Labels to add. [at most 100 items]
- `remove` (array of string): Labels to remove. [at most 100 items]

### Request

```sh
curl -X PATCH "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/labels" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "add": [
    "string"
  ],
  "remove": [
    "string"
  ]
}'
```

### Answer: 200

```json
{
  "labels": [
    "pricing",
    "q1"
  ]
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation. refused: The token's person can see the thing but may not do this; the message says why. read_only: The organisation is read-only (over the Free plan's people, or a payment is overdue).
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 409 `archived`: archived: The item (or its project) is archived, so it can't be changed.
- 413 `too_large`: too_large: The body or a file is larger than allowed.
- 415 `unsupported_media_type`: unsupported_media_type: The body isn't JSON.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).
