---
title: "Patients with N completed sessions in date range"
method: GET
path: "/api/analytics/patients-with-n-sessions"
tags: ["analytics"]
---

# Patients with N completed sessions in date range

`GET /api/analytics/patients-with-n-sessions`

Returns patients who have exactly (or at least) min_sessions completed appointments in [from_date, to_date], optionally filtered by type (psychologist / nutritionist). From patients_with_n_sessions.

## Query parameters

- `from_date` string, date, required — Start date (YYYY-MM-DD).
- `to_date` string, date, required — End date (YYYY-MM-DD).
- `min_sessions` integer, required — Minimum (or exact) number of completed sessions.
- `type` string, nullable — Filter by appointment type: psychologist, nutritionist (lowercase), or omit for both.
- `exact` boolean — If true, only patients with exactly min_sessions; if false, patients with >= min_sessions.
- `per_page` integer — Page size.
- `page` integer — Page number (1-based).

## Response `200`

Successful Response

- PatientsWithNSessionsResponse — Patients with N sessions response model.
  - `items` PatientsWithNSessionsRow[], required — Paginated patients, ordered by sessions_count descending
    - `patient_id` string, uuid, required — Patient UUID
    - `first_name` string, nullable — First name
    - `last_name` string, nullable — Last name
    - `email` string, nullable — Email
    - `phone` string, nullable — Phone
    - `sessions_count` integer, required — Completed sessions count in the date range
    - `psychologist_status` string, nullable — Psychologist status at end date
    - `nutritionist_status` string, nullable — Nutritionist status at end date
  - `total` integer, required — Total number of rows before pagination
  - `per_page` integer, required — Page size
  - `page` integer, required — Page number.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/corabea/apis/corabea-api.md) · [All operations](https://skmtc.dev/corabea/apis/corabea-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/corabea/corabea-api/revisions/13c1bce1bdc4/schema)
