# Get project patient counts

Canonical page: https://docs.ovok.com/slim-apis/project/get-project-patient-counts

| Method | Path |
| --- | --- |
| `GET` | `/v1/slim/project/:id/patient-counts` |

[Authentication](/authentication) · [Access policies](/access-policies)

Returns summary counts of the residents in a project by state: active, recently discharged, discharged and archived. Use it for project overview tiles.

**Auth:** Bearer token. The caller's access policy must grant `Patient:search` and `Patient:read` (project admins skip this check).
**Scope:** The project in the path. It must be the caller's project (from the token) or a direct child of it.

## Request [#request]

### Path parameters [#path-parameters]

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | Project id. Your own project or a direct child of it. |

## Behaviour [#behaviour]

- Counts come from the project's live device list, so only residents linked to a device row are counted. A resident without a device is not included.
- Each resident is counted once, even when linked to several devices.
- A row is left out when its device, resident, location or organization belongs to another project.
- The device list is cached, so a change can take a moment to show. If the list fails to build, the last complete list is used. When there is none, the route answers 503. When there is none, the route answers 503.


## Example [#example]

```bash
curl -X GET 'https://api.sandbox.ovok.com/v1/slim/project/b7a3d915-6e20-4c8f-9a14-3d5f7b9c1e68/patient-counts' \
  -H "Authorization: Bearer ${OVOK_TOKEN}"
```

## Successful response [#successful-response]

`200` — Patient counts retrieved successfully.

```json
{
  "projectId": "b7a3d915-6e20-4c8f-9a14-3d5f7b9c1e68",
  "totalPatientCount": 36,
  "activePatientCount": 34,
  "dischargedRecentPatientCount": 2,
  "dischargedPatientCount": 0,
  "archivedPatientCount": 0
}
```

| Field | Type | Description |
| --- | --- | --- |
| `projectId` | `string (uuid)` | The project id from the path. |
| `totalPatientCount` | `integer` | Residents linked to a device. Each is counted once. |
| `activePatientCount` | `integer` | Residents in state `active`. |
| `dischargedRecentPatientCount` | `integer` | Residents in state `discharged-recent`. |
| `dischargedPatientCount` | `integer` | Residents in state `discharged`. |
| `archivedPatientCount` | `integer` | Residents in state `archived`. |

## Errors [#errors]

| Status | Meaning |
| --- | --- |
| [`400`](/errors/malformed-request) | The project is neither the caller's project nor a direct child of it. |
| [`401`](/errors/unauthenticated) | The bearer token is missing or invalid. |
| [`403`](/errors/forbidden) | The session has no profile, or its access policy lacks `Patient:search` or `Patient:read`. |
| [`422`](/errors/validation-failed) | `id` is empty. |
| [`503`](/errors/service-unavailable) | The device list cannot be built and no earlier complete list exists. Retry shortly. |
