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

# Delete Thread

Deletes a thread and its full descendant tree (all subthreads), including all associated messages and thread storage.

<Warning>
  This action is irreversible. The selected thread and all descendant subthreads are permanently deleted.
</Warning>

<ParamField path="threadId" type="string" required>
  The unique thread identifier (UUID)
</ParamField>

<ResponseField name="success" type="boolean" required>
  Whether the deletion was successful
</ResponseField>

<ResponseField name="threadId" type="string" required>
  The root thread ID that was requested for deletion
</ResponseField>

<ResponseField name="deletedThreadIds" type="array[string]" required>
  Thread IDs deleted in child-first order
</ResponseField>

<ResponseField name="deletedCount" type="number" required>
  Total number of deleted threads (root + descendants)
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000
  ```

  ```typescript JavaScript theme={null}
  const response = await fetch(
    'https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000',
    { method: 'DELETE' }
  );
  const result = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "threadId": "550e8400-e29b-41d4-a716-446655440000",
    "deletedThreadIds": [
      "4dcf9e6e-9b72-4435-bf1a-b402f488f012",
      "c3ba3a6a-0cc7-4f90-a8e8-9cd664f9fe11",
      "550e8400-e29b-41d4-a716-446655440000"
    ],
    "deletedCount": 3,
    "message": "Thread and subthreads deleted successfully"
  }
  ```

  ```json 404 theme={null}
  {
    "error": "Thread not found"
  }
  ```
</ResponseExample>
