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

# Delete Document

> Permanently delete a document and its associated files.

**DELETE** `/api/v1/documents/{id}`

Delete a document and all its associated files (original upload and processed output). This action is permanent and cannot be undone.

## Request

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token authentication. Example: `Bearer YOUR_API_KEY`
</ParamField>

### Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier (UUID) of the document to delete
</ParamField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://api.doctly.ai/api/v1/documents/123e4567-e89b-12d3-a456-426614174000 \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

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

  doc_id = "123e4567-e89b-12d3-a456-426614174000"
  headers = {"Authorization": "Bearer YOUR_API_KEY"}

  response = requests.delete(
      f"https://api.doctly.ai/api/v1/documents/{doc_id}",
      headers=headers
  )

  if response.status_code == 200:
      print("Document deleted successfully")
  else:
      print(f"Error: {response.json()}")
  ```

  ```javascript JavaScript theme={null}
  const docId = '123e4567-e89b-12d3-a456-426614174000';

  const response = await fetch(
    `https://api.doctly.ai/api/v1/documents/${docId}`,
    {
      method: 'DELETE',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY'
      }
    }
  );

  if (response.ok) {
    console.log('Document deleted successfully');
  } else {
    const error = await response.json();
    console.error('Error:', error);
  }
  ```
</CodeGroup>

## Response

<ResponseField name="message" type="string">
  Success confirmation message
</ResponseField>

## Example Responses

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "message": "Document deleted successfully"
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "detail": "Document not found"
  }
  ```

  ```json 422 Unprocessable Entity theme={null}
  {
    "detail": [
      {
        "loc": ["path", "id"],
        "msg": "value is not a valid uuid",
        "type": "type_error.uuid"
      }
    ]
  }
  ```
</ResponseExample>

<Warning>
  **This action is permanent.** Deleting a document removes:

  * The original uploaded file
  * The processed output (Markdown or extraction result)
  * All associated metadata

  Make sure to download any files you need before deleting.
</Warning>

## Bulk Deletion Example

<CodeGroup>
  ```python Python theme={null}
  import requests

  headers = {"Authorization": "Bearer YOUR_API_KEY"}

  # Get documents older than 30 days
  from datetime import datetime, timedelta
  cutoff = (datetime.now() - timedelta(days=30)).isoformat()

  response = requests.get(
      "https://api.doctly.ai/api/v1/documents",
      headers=headers,
      params={"date_to": cutoff}
  )

  old_docs = response.json()["data"]

  # Delete each document
  for doc in old_docs:
      requests.delete(
          f"https://api.doctly.ai/api/v1/documents/{doc['id']}",
          headers=headers
      )
      print(f"Deleted: {doc['file_name']}")
  ```

  ```javascript JavaScript theme={null}
  const headers = { 'Authorization': 'Bearer YOUR_API_KEY' };

  // Get documents older than 30 days
  const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString();

  const response = await fetch(
    `https://api.doctly.ai/api/v1/documents?date_to=${cutoff}`,
    { headers }
  );

  const { data: oldDocs } = await response.json();

  // Delete each document
  for (const doc of oldDocs) {
    await fetch(
      `https://api.doctly.ai/api/v1/documents/${doc.id}`,
      { method: 'DELETE', headers }
    );
    console.log(`Deleted: ${doc.file_name}`);
  }
  ```
</CodeGroup>
