---
title: "Generate a suggested session leader rotation (MED-906 / E4.0c)"
method: POST
path: "/api/cohorts/{cohortId}/sessions/generate-leader-rotation"
tags: ["Sessions"]
---

# Generate a suggested session leader rotation (MED-906 / E4.0c)

`POST /api/cohorts/{cohortId}/sessions/generate-leader-rotation`

## Request

- Base URL: `https://api.production.yourmedley.com`
- URL: `https://api.production.yourmedley.com/api/cohorts/{cohortId}/sessions/generate-leader-rotation`
- Auth: HTTP bearer

Generates a session-leader rotation order for every group in a
peer_led cohort using IvsE and prep-preference scores extracted on
demand from each participant's intake `form_submissions.raw_payload`.

The proposal is NOT persisted — the FE displays it and lets the CM
review + edit per cell before committing the batch via
`POST /finalize-leader-rotation`. Participants without a completed
intake submission are surfaced under `skipped_participants` and
excluded from the rotation rather than being assigned a neutral
default that would bias the result.

Gated by the `live_session_delivery` feature flag.

## Path parameters

- `cohortId` string, uuid, required

## Response `200`

Rotation proposal generated successfully.

- object
  - `success` boolean
  - `data` object
    - `assignments` object[]
      - `session_id` string, uuid
      - `session_number` integer, nullable
      - `topic_name` string, nullable
      - `scheduled_start` string, nullable
      - `group_id` string, uuid
      - `group_name` string
      - `proposed_leader` object
        - `user_id` string, uuid
        - `first_name` string
        - `last_name` string
        - `ivse_average` number
        - `prep_preference_average` number
    - `skipped_participants` object[]
    - `warnings` object[]

## Other responses

- `401`: Unauthorized
- `404`: Feature flag is off OR cohort has no group_coaching modality.
- `422`: Validation error. Possible `code` values: - `not_peer_led` — cohort's group_coaching modality is not peer_led

---

[API](https://skmtc.dev/withmedley/apis/medley-api.md) - [All operations](https://skmtc.dev/withmedley/apis/medley-api/llms.txt) - [OpenAPI document](https://skmtc.dev/withmedley/apis/medley-api/revisions/40aaac5ca6bd?raw)
