---
title: "Purge all AI-generated data for a cohort (internal admin only)"
method: POST
path: "/cohorts/{id}/purge-ai-data"
tags: ["Cohorts"]
---

# Purge all AI-generated data for a cohort (internal admin only)

`POST /cohorts/{id}/purge-ai-data`

## Request

- Base URL: `https://api.production.yourmedley.com`
- URL: `https://api.production.yourmedley.com/cohorts/{id}/purge-ai-data`
- Auth: HTTP bearer

MED-1196 (B3) — manual retention purge. Deletes every persisted
AI-OUTPUT store for the cohort, across all of its sessions: session
transcripts, airtime aggregates, discussion themes, and recap email
drafts. Issues real deletes per store (does not rely on the sessions FK
cascade, which a soft-delete does not trip). Does NOT touch core cohort,
session, participant-entered, or configuration data — including the kept
pre-session synthesis, prep AI-Note suggestions, and prep AI-prompt
selections.

Authorization is `internal_admin` persona only, enforced server-side.
Coaches, cohort managers (`internal_user`), and participants cannot
invoke it. The endpoint is gated behind the `live_session_delivery`
feature flag and returns 404 when the flag is off. Idempotent: a cohort
with no persisted AI data returns success with zero counts.

## Path parameters

- `id` string, uuid, required

## Response `200`

AI data purged (or nothing to purge)

- object
  - `success` boolean
  - `data` object
    - `cohortId` string, uuid
    - `sessionCount` integer: Sessions the purge fanned out over (incl. soft-deleted).
    - `deleted` object
      - `transcripts` integer
      - `airtime` integer
      - `themes` integer
      - `recapDrafts` integer
    - `totalDeleted` integer: Sum of rows removed across all stores.

## Other responses

- `401`: Unauthorized (not authenticated)
- `403`: Forbidden (caller is not an internal admin)
- `404`: Cohort not found, or the live_session_delivery flag is off
- `422`: Validation error

---

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