# Delete Thread

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

Before anything is deleted, each of those threads stops accepting work: it refuses new messages with `423`, starts no execution, and creates no child thread. An execution in flight is aborted, and `state.execution.abortSignal` fires in the running tool or hook. Queued messages and scheduled effects are discarded.

Every open stream connection to a deleted thread is closed with WebSocket close code `1000` before the response is returned.

If the deletion fails part-way, the response is `500`. The remaining threads stay unavailable to new work. Send the same request again to complete the deletion.

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

- threadId (string), required

  The unique thread identifier (UUID)

* success (boolean), required

  Whether the deletion was successful

- threadId (string), required

  The root thread ID that was requested for deletion

* deletedThreadIds (array\[string]), required

  Thread IDs deleted in child-first order

- deletedCount (number), required

  Total number of deleted threads (root + descendants)

```bash cURL
curl -X DELETE https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer $STANDARD_AGENTS_API_KEY"
```

```typescript JavaScript
const response = await fetch(
  'https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000',
  { method: 'DELETE', headers: { Authorization: `Bearer ${token}` } }
);
const result = await response.json();
```

```json 200
{
  "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
{
  "error": {
    "code": "not_found",
    "message": "Thread not found: 550e8400-e29b-41d4-a716-446655440000"
  },
  "requestId": "0b3c1f0e-7f0a-4a55-9c58-2f6f5a0f6f0e"
}
```
