---
title: "Delete Collection Api"
method: DELETE
path: "/api/kb/collections/{collection_name}"
tags: ["kb"]
---

# Delete Collection Api

`DELETE /api/kb/collections/{collection_name}`

Delete a collection and all its data.

This function ensures data consistency by attempting physical file deletion
before database deletion. If physical deletion fails, the operation is
aborted to prevent inconsistent state.

Args:
    collection_name: Name of the collection to delete

Returns:
    Deletion result with status, affected documents, and cleanup information

Raises:
    HTTPException: If physical deletion fails (prevents database deletion)

## Path parameters

- `collection_name` string, required

## Response `200`

Successful Response

- CollectionOperationResult — Response payload for collection-level management operations.
  - `status` string, required — Operation status: success|partial_success|error
  - `collection` string, required — Collection identifier affected by the operation
  - `message` string, required — Human-readable summary of the collection operation
  - `warnings` string[] — Non-fatal issues encountered while processing the collection
  - `affected_documents` CollectionOperationDetail[] — Subset of documents impacted by the collection operation
    - `doc_id` string, required — Document identifier affected by the operation
    - `status` 'pending' | 'running' | 'chunked' | 'partially_embedded' | 'success' | 'failed' | 'cancelled', required — States representing document ingestion lifecycle.
    - `message` string, nullable — Optional message describing individual document handling
  - `deleted_counts` object — Aggregated deletion counts per table when applicable

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/xorbitsai/apis/xagent.md) · [All operations](https://skmtc.net/xorbitsai/apis/xagent/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/xorbitsai/xagent/revisions/33e4ba4936ad/schema)
