> ## 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.

# Delete Recording

> Delete an appointment's recording, removing both the stored file and the database record.

## Overview

Deletes the recording stored for a specific appointment. The recording is located by `appointment_id`. The stored file is removed and the database record is deleted; the deleted record is returned in the response.

<Warning>
  **Permanent deletion.** This operation removes both the stored file and the database record and cannot be undone.
</Warning>

## 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 recording should be deleted. The recording is located by `appointment_id`.

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

## Response

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

<ResponseField name="data" type="object">
  The deleted recording record.

  <Expandable title="Deleted Recording Object">
    <ResponseField name="_id" type="string">
      Unique recording identifier.
    </ResponseField>

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

    <ResponseField name="recording_url" type="string">
      URL of the deleted recording file.
    </ResponseField>

    <ResponseField name="recording_key" type="string">
      Storage key of the deleted recording file.
    </ResponseField>

    <ResponseField name="append_recordings" type="array">
      Additional recording segments that were attached to this recording.
    </ResponseField>

    <ResponseField name="file_size_bytes" type="number">
      File size in bytes. May be `null`.
    </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 `merged_recording`, `replaced_recording`, `duration_seconds`, `__v`) may appear on the returned object. Treat any field not documented here as opaque.
</Info>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE \
    'https://app.medisync.me/api/recordings/665f8a1b2c3d4e5f6789012f3' \
    -H 'Authorization: Bearer <JWT>'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://app.medisync.me/api/recordings/665f8a1b2c3d4e5f6789012f3',
    {
      method: 'DELETE',
      headers: {
        'Authorization': 'Bearer <JWT>'
      }
    }
  );

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

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

  headers = {'Authorization': 'Bearer <JWT>'}

  response = requests.delete(
      'https://app.medisync.me/api/recordings/665f8a1b2c3d4e5f6789012f3',
      headers=headers
  )

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

## Example Response

```json Success (200) theme={null}
{
  "success": true,
  "data": {
    "_id": "665f8a1b2c3d4e5f6789012f4",
    "appointment_id": "665f8a1b2c3d4e5f6789012f3",
    "recording_url": "https://storage.medisync.me/recordings/665f8a1b2c3d4e5f6789012f3_recording.wav",
    "recording_key": "665f8a1b2c3d4e5f6789012f3_recording.wav",
    "append_recordings": [],
    "file_size_bytes": 4831200,
    "createdAt": "2026-06-30T10:30:00.000Z",
    "updatedAt": "2026-06-30T10:30:00.000Z"
  }
}
```

## Error Responses

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

```json 400 No Recording On File theme={null}
{
  "success": false,
  "error": "Cannot read properties of null (reading 'recording_key')"
}
```

```json 400 Storage Delete Failed theme={null}
{
  "success": false,
  "error": "Access Denied"
}
```

<Note>
  The `Unauthorized` response uses the `message` field; handler-level errors use the `error` field. If there is no recording on file for the appointment, the request currently fails with a `400` error rather than a clean `404`, so confirm a recording exists (via `GET /recordings/{appointmentId}`) before deleting. Storage-delete failures also surface as a `400` with the raw storage error message.
</Note>

## Behavior Notes

* **Lookup by appointment**: The recording is located by `appointment_id`.
* **File then record**: The stored file is removed before the database record is deleted; the deleted record is returned in `data`.
* **Confirm first**: Deleting when no recording exists returns a `400` error, so verify existence beforehand.
