# 刪除知識版本

此 API 用於刪除指定的 Fileset，並一併移除該 Fileset 與檔案之間的關聯。檔案本身不會被刪除；關聯移除後，若檔案不再屬於任何 Fileset，即可透過「刪除單一檔案」API 刪除。  
**限制條件**：當 Fileset 狀態為 `queued` 或 `processing` 時無法刪除，會回傳 `FILESET_021`（409）；請等待處理結束，或先以「取消 Commit 知識版本」API 取消 Commit。其餘狀態（`draft`、`completed`、`failed`、`partial_failed`、`cancelled`）皆可刪除。

```bash
curl -X 'DELETE' \
  'http://127.0.0.1:8000/v1/filesets/{fileset_id}' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer $PRIVAI_API_KEY"
```

#### Request Headers

| Key | Value |
| --- | --- |
| Request Method | DELETE |
| accept | application/json |
| Authorization | `Bearer $PRIVAI_API_KEY` |

#### Path Parameters

| Field | Type | Note | Required |
| --- | --- | --- | --- |
| fileset_id | string | uuid | true |

#### Response Body

```json
{
  "detail": "Delete fileset with ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

#### 常見錯誤代碼

| Error Code | HTTP Status | 情境 |
| --- | --- | --- |
| FILESET_001 | 404 | 指定的 Fileset 不存在 |
| FILESET_021 | 409 | Fileset 狀態為 `queued`／`processing`，回應中帶 `state` |

身份驗證錯誤（`AUTH_001`～`AUTH_003`）詳見「錯誤代碼說明-身份驗證類」章節；知識版本相關錯誤碼完整說明請參考 [錯誤代碼說明-知識版本管理類](https://privstation-docs.apmic.ai/latest/privai-400/錯誤代碼說明-知識版本管理類.md)。
