# Count requests (https://notert.io/docs/api/reference/count-requests)

`GET /api/v1/insights/request-counts`

How many of the workspace's requests the filters keep, as its team's list holds them, in all and broken down by status, board, tag or owner, the most first.

Access: A token with requests:read.

## Query parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | No | Words every request counted holds in its title, its details or its author's name. Empty counts them all. At most 200 characters. |
| `statuses` | string or string[] | No | Only the requests in these statuses. Repeat it for several, as statuses=planned&statuses=in_progress. One of: `pending`, `in_review`, `planned`, `in_progress`, `completed`, `closed`. Default []. |
| `boardIds` | string or string[] | No | Only the requests on any of these boards. Repeat it for several, up to 50. Default []. |
| `tagIds` | string or string[] | No | Only the requests wearing any of these tags. Repeat it for several, up to 50. Default []. |
| `ownerIds` | string or string[] | No | Only the requests any of these teammates own, by their m_ id from GET /teammates. Repeat it for several, up to 50. Default []. |
| `wantedBy` | string | No | Only the requests this person filed or voted for, by their id from the people list: m_ and a member's user id, or c_ and a contact's id. |
| `createdAfter` | date-time | No | Only the requests filed at or after this moment, ISO 8601 with its offset. |
| `createdBefore` | date-time | No | Only the requests filed before this moment, ISO 8601 with its offset. |
| `groupBy` | string | No | What to count them by: status (the default), board, tag or owner. A request with several tags or owners counts under each. One of: `status`, `board`, `tag`, `owner`. Default "status". |

## Response 200

| Field | Type | Description |
| --- | --- | --- |
| `total` | integer | How many requests the filters keep in all. |
| `groups` | object[] | Each group's count, the most first. A board, tag or owner with none is left out, and a request with several tags or owners counts under each. |
| `groups.id` | string or null | The group's status, or its board's, tag's or teammate's id. Null for the requests with no tag or no owner. |
| `groups.name` | string | What the app calls the group: a status's label, or the board's, tag's or teammate's name. |
| `groups.count` | integer | How many of the requests are in the group. |

## Errors

| Status | Code | Message |
| --- | --- | --- |
| 400 | `BAD_REQUEST` | Input validation failed. |
| 401 | `UNAUTHORIZED` | Send a valid API token as a Bearer token. |
| 403 | `HOLDER_NOT_ALLOWED` | The teammate who holds this API token's secret can't do this in the workspace now. A teammate who can should roll it in the workspace's settings. |
| 403 | `INSUFFICIENT_SCOPE` | This API token can't read requests, boards, tags and statuses. Create one that may in the workspace's settings. |
| 403 | `NETWORK_NOT_ALLOWED` | This API token works only from the networks it was made for. Call from one of them, or create a token for this one in the workspace's settings. |
| 429 | `TOO_MANY_REQUESTS` | Too Many Requests. Its data holds `retryAfter`. |

## Example request

```sh
curl "https://app.notert.io/api/v1/insights/request-counts?groupBy=board" \
  -H "Authorization: Bearer $NOTERT_API_TOKEN"
```

## Example response 200

```json
{
  "total": 86,
  "groups": [
    {
      "id": "2d9a7c41-6b3e-4e8f-a1c5-0f4b8d2e6a17",
      "name": "Integrations",
      "count": 24
    }
  ]
}
```
