> ## Documentation Index
> Fetch the complete documentation index at: https://docs.medera.info/llms.txt
> Use this file to discover all available pages before exploring further.

# /sessions endpoint

> WSS · real-time stateful live therapy capture with 2-speaker diarization.

`wss://api.medera.info/sessions` is the **stateful, diarized live-capture WebSocket** for therapy sessions. Same engine, same calibration, same structured output as `/transcribe` and `/transcripts` — but architected for the full 50-minute encounter with 2-speaker diarization, in-line C-SSRS markers, and structured instrument-score emission.

## Connection

```text theme={"system"}
wss://api.medera.info/sessions?session_id=<id>&token=<jwt>
```

## Configuration (client → server)

```json theme={"system"}
{ "type": "configure", "language": "en-US", "diarization": true, "speakers": 2, "interim_results": true, "instruments": ["phq-9", "gad-7", "audit-c", "c-ssrs"], "vocabulary": { "formulary": ["sertraline", "escitalopram", "lamotrigine"], "programs": ["IOP", "PHP", "PHP-step-down"], "clinicians": ["Dr. Khalil", "Dr. Patel"] }, "features": ["soap", "codes", "span_anchors", "crisis_markers"]
}
```

## Events (server → client)

| Event                    | Schema                                                                   |
| :----------------------- | :----------------------------------------------------------------------- |
| `transcript.partial`     | `{ text, speaker, start_ms, end_ms }`                                    |
| `transcript.final`       | `{ text, speaker: "clinician" \| "patient", start_ms, end_ms, span_id }` |
| `instrument.item_scored` | `{ instrument, item, score, transcript_anchor }`                         |
| `instrument.completed`   | `{ instrument, total_score, severity, items, anchors }`                  |
| `crisis.detected`        | `{ band, criteria, transcript_anchor, escalation_id }` (C-SSRS)          |
| `note.section.update`    | `{ section, text, anchors: [span_id] }`                                  |
| `code.suggestion`        | `{ system, code, display, anchor }` (ICD-10, CPT)                        |
| `audio.event`            | `{ kind: "silence" \| "clipping" \| "low_snr" }`                         |
| `error`                  | `{ code, message, recoverable }`                                         |

## Lifecycle

```text theme={"system"}
client opens WS → server: { connected, session_id } → client: { configure,... } → server: { configured } → client: <PCM binary frames>... → server: { transcript.partial }, { transcript.final } → server: { instrument.item_scored } (continuous) → server: { instrument.completed } → server: { crisis.detected } ← never gated → server: { note.section.update } → server: { code.suggestion } → client: { close } → server: { finalized, session_id }
```

## Audio

* 16 kHz 16-bit PCM mono recommended

* Opus at 32 kbps for bandwidth-constrained edges

* 20 ms frames (320 samples at 16 kHz)

* See [Audio Configuration](/multimodal/stt/audio) for full formats

## What you get back at session close

```json theme={"system"}
{ "session_id": "ses_abc", "transcript": { "segments": [...], "spans": [...] }, "diarization": { "speakers": 2, "speaker_time_ms": { "clinician": 1820000, "patient": 720000 } }, "instruments": { "phq-9": { "total": 14, "severity": "moderate", "items": [...] }, "gad-7": { "total": 11, "severity": "moderate" }, "c-ssrs": { "risk_band": "low", "items": [...] } }, "codes": { "icd10": [...], "cpt": [...] }, "notes": { "soap": {...} }, "crisis_events": []
}
```

<Warning>
  **C-SSRS crisis markers are non-bypassable.** When `crisis.detected` fires, the practice escalation tree is invoked immediately. The agent cannot gate, suppress, or delay the event.
</Warning>

***

## What's next

<CardGroup cols={2}>
  <Card title="/transcribe" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/mic.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=2fa5bf2e6c0f7c96c6db63c83d109eb1" href="/multimodal/stt/transcribe" width="40" height="40" data-path="icons/ui/mic.svg">
    Stateless between-visit dictation.
  </Card>

  <Card title="/transcripts" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/file-audio.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=eacfd37e12781948fb536566b95f8bd5" href="/multimodal/stt/transcripts" width="40" height="40" data-path="icons/ui/file-audio.svg">
    Async batch processing.
  </Card>

  <Card title="Diarization" icon="https://mintcdn.com/medera-357fd587/n1mgcc3nR2sq_PoL/icons/ui/users.svg?fit=max&auto=format&n=n1mgcc3nR2sq_PoL&q=85&s=6cfd2d71e676953927a6cd89be0a86d5" href="/multimodal/stt/diarization" width="40" height="40" data-path="icons/ui/users.svg">
    2-speaker separation.
  </Card>

  <Card title="Audio configuration" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/settings.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=d4e5b78d0364e67249682468c3175436" href="/multimodal/stt/audio" width="40" height="40" data-path="icons/ui/settings.svg">
    Formats and frame size.
  </Card>
</CardGroup>
