---
title: "Cleanup Orphaned Threads"
method: POST
path: "/api/channels/{channel}/cleanup-orphaned"
tags: ["channels", "channels", "channel-accounts"]
---

# Cleanup Orphaned Threads

`POST /api/channels/{channel}/cleanup-orphaned`

## Request

- Base URL: `https://api.dialogbrain.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.dialogbrain.com/api/channels/{channel}/cleanup-orphaned`
- Auth: none declared

Clean up orphaned threads from deleted channel accounts.

Finds threads in workspace DB that reference channel_account_ids
that no longer exist in the shared DB, and deletes them along
with their messages.

This is useful after:
- Account deletion that failed to clean up properly
- Database migration issues
- Manual account removal

Args:
    channel: Channel name to clean up

Returns:
    Cleanup statistics

## Path parameters

- `channel` string, required

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/dialogbrain/apis/dialogbrain-v2-api-gateway.md) · [All operations](https://skmtc.dev/dialogbrain/apis/dialogbrain-v2-api-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/dialogbrain/apis/dialogbrain-v2-api-gateway/revisions/d84e7dc9977d?raw)
