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

# Update Transcription

> Replace the transcription for a specific appointment.

## Overview

Replaces the transcription stored for a specific appointment, looked up by `appointment_id`. The supplied array fully replaces the existing transcription, the appointment status is set to `processing`, and its error reason is cleared.

<Info>
  This endpoint finds the transcription by appointment ID and replaces its content. The appointment status is set to `processing` and its error reason is cleared.
</Info>

## Authentication

<ParamField header="Authorization" type="string" required>
  Bearer JWT token. The calling user is derived from the token.

  ```
  Authorization: Bearer <JWT>
  ```
</ParamField>

## Path Parameters

<ParamField path="appointmentId" type="string" required>
  The appointment ObjectId whose transcription is updated (looked up by `appointment_id`).

  ```
  665f8a1b2c3d4e5f6789012f3
  ```
</ParamField>

## Body Parameters

<ParamField body="transcription" type="array" required>
  Replacement array of transcript segment objects, e.g. `{ "sender": "speaker_0", "message": "...", "start_time": "00:00:05,800" }`. This fully replaces the existing transcription array. A non-array value is rejected (`500`).
</ParamField>

## Response

<ResponseField name="success" type="boolean" required>
  Indicates whether the transcription was updated successfully.
</ResponseField>

<ResponseField name="data" type="object">
  The updated transcription record.

  <Expandable title="Transcription Object">
    <ResponseField name="_id" type="string">
      Unique transcription identifier.
    </ResponseField>

    <ResponseField name="appointment_id" type="string">
      The associated appointment ObjectId.
    </ResponseField>

    <ResponseField name="transcription" type="array">
      The updated array of transcript segment objects.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      Creation timestamp (ISO 8601).
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      Last-update timestamp (ISO 8601).
    </ResponseField>
  </Expandable>
</ResponseField>

<Info>
  Additional fields (for example `__v`) may appear on the transcription object. Treat any field not documented here as opaque.
</Info>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT \
    'https://app.medisync.me/api/transcriptions/update/665f8a1b2c3d4e5f6789012f3' \
    -H 'Authorization: Bearer <JWT>' \
    -H 'Content-Type: application/json' \
    -d '{
      "transcription": [
        { "sender": "speaker_0", "message": "Guten Tag, was fuehrt Sie zu mir?", "start_time": "00:00:01,200" },
        { "sender": "speaker_1", "message": "Ich habe seit heute Morgen Brustschmerzen, korrigiert.", "start_time": "00:00:05,800" }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://app.medisync.me/api/transcriptions/update/665f8a1b2c3d4e5f6789012f3',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer <JWT>',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        transcription: [
          { sender: 'speaker_0', message: 'Guten Tag, was fuehrt Sie zu mir?', start_time: '00:00:01,200' },
          { sender: 'speaker_1', message: 'Ich habe seit heute Morgen Brustschmerzen, korrigiert.', start_time: '00:00:05,800' }
        ]
      })
    }
  );

  const result = await response.json();
  ```

  ```python Python theme={null}
  import requests

  data = {
      "transcription": [
          {"sender": "speaker_0", "message": "Guten Tag, was fuehrt Sie zu mir?", "start_time": "00:00:01,200"},
          {"sender": "speaker_1", "message": "Ich habe seit heute Morgen Brustschmerzen, korrigiert.", "start_time": "00:00:05,800"}
      ]
  }

  headers = {
      'Authorization': 'Bearer <JWT>',
      'Content-Type': 'application/json'
  }

  response = requests.put(
      'https://app.medisync.me/api/transcriptions/update/665f8a1b2c3d4e5f6789012f3',
      headers=headers,
      json=data
  )

  result = response.json()
  ```
</CodeGroup>

## Example Response

```json Success (200) theme={null}
{
  "success": true,
  "data": {
    "_id": "665f8a1b2c3d4e5f6789012f7",
    "appointment_id": "665f8a1b2c3d4e5f6789012f3",
    "transcription": [
      { "sender": "speaker_0", "message": "Guten Tag, was fuehrt Sie zu mir?", "start_time": "00:00:01,200" },
      { "sender": "speaker_1", "message": "Ich habe seit heute Morgen Brustschmerzen, korrigiert.", "start_time": "00:00:05,800" }
    ],
    "createdAt": "2026-06-30T10:30:00.000Z",
    "updatedAt": "2026-06-30T11:15:00.000Z"
  }
}
```

## Error Responses

```json 401 Unauthorized theme={null}
{
  "success": false,
  "message": "Unauthorized"
}
```

```json 404 Transcription Not Found theme={null}
{
  "success": false,
  "error": "Transcription not found"
}
```

```json 404 Associated Appointment Not Found theme={null}
{
  "success": false,
  "error": "Associated appointment not found."
}
```

<Note>
  The `Unauthorized` response uses the `message` field; handler-level errors use the `error` field. Unexpected server errors — including sending a non-array `transcription` value — return `500 { "success": false, "error": "<message>" }`.
</Note>

## Behavior Notes

* **Full replacement**: The supplied array completely replaces the existing transcription.
* **Update order**: The transcription is updated first; if the appointment is then not found, the endpoint returns `404 Associated appointment not found.` (the transcription is still updated).
* **Status reset**: The appointment status is set to `processing` unconditionally and its error reason is cleared.
* **Note generation**: Updating a transcription may re-trigger clinical note generation in the background; this does not change the HTTP response.
