---
title: "Assign or reassign the session leader (MED-812 / E4.0a)"
method: PUT
path: "/cohorts/{cohortId}/sessions/{sessionId}/leader"
tags: ["Sessions"]
---

# Assign or reassign the session leader (MED-812 / E4.0a)

`PUT /cohorts/{cohortId}/sessions/{sessionId}/leader`

## Request

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

Designates a peer leader for a single session in a group_coaching
cohort with `coaching_sub_type = 'peer_led'`. Used by the CM portal's
Sessions list/card inline edit.

**Gating:**
- Endpoint returns 404 when the `live_session_delivery` feature flag
  is disabled (indistinguishable from a non-existent route).
- The session's modality must be group_coaching + peer_led. Other
  modalities receive 422 `not_peer_led`.

**Lock cutoff:** Reassignment is blocked once `now() >= scheduled_start`.
After that boundary the API returns 422 `session_already_started`.

**Roster validation:** The designated user must be a current member of
the session's group (`group_members` row with `left_at IS NULL` and
`is_deleted = false`). Otherwise 422 `participant_not_in_group`.

**Audit:** Each successful designation writes a `session_audit_log`
row with action `leader_designated` (first assignment, previous was
null) or `leader_reassigned` (subsequent changes). The `changes` jsonb
includes the before/after values of `session_leader_id`.

## Path parameters

- `cohortId` string, uuid, required
- `sessionId` string, uuid, required

## Request body

- object
  - `session_leader_id` string, uuid, required: User ID of the peer leader to assign. Must be a current member of the session's group.

## Response `200`

Leader designated; returns the updated session row.

## Other responses

- `401`: Unauthorized
- `404`: Either the feature flag is off, the cohort/session was not found, or the session was soft-deleted.
- `422`: Validation error. Possible `code` values: - `not_peer_led` — session modality is not group_coaching + peer_led - `session_not_in_cohort` — sessionId does not belong to cohortId - `session_already_started` — now() is at/after scheduled_start - `participant_not_in_group` — designated user is not a current group member

---

[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)
