# 取得所有知識版本列表

此 API 用於取得目前所有的 Fileset（知識版本）清單。每個 Fileset 都包含其唯一 ID、名稱、狀態、建立與提交時間，以及檔案統計資訊，可用於挑選要查詢的知識版本、確認 commit 進度或執行維運管理。

```bash
curl -X 'GET' \
  'http://127.0.0.1:8000/v1/filesets?limit=20&order=desc' \
  -H 'accept: application/json' \
  -H "Authorization: Bearer $PRIVAI_API_KEY"
```

#### Request Headers

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

#### Query Parameters

| Field | Type | Note | Required |
| --- | --- | --- | --- |
| limit | int | 1 - 10000，預設為 10000 | false |
| order | string | 依 `created_at` 排序，`asc` 或 `desc`，預設為 `desc` | false |
| after | string | uuid，分頁游標（Fileset ID），取得此 Fileset 之後的資料。不可與 `before` 同時使用 | false |
| before | string | uuid，分頁游標（Fileset ID），取得此 Fileset 之前的資料。不可與 `after` 同時使用 | false |

#### Response Body

```json
{
  "object": "list",
  "data": [
    {
      "object": "fileset",
      "id": "c7ea032b-eb16-4ccb-94a6-88af66db5d22",
      "name": "Company Policy Files v1.0",
      "metadata": {
        "tag": ["policy", "operation"],
        "embedding_model": "apmic-embedding-v1",
        "parsing_mode": "HQ"
      },
      "state": "completed",
      "created_at": "2025-01-01T00:00:00.000Z",
      "committed_at": "2025-01-01T00:10:00.000Z",
      "updated_at": "2025-01-01T00:15:00.000Z",
      "file_counts": {
        "draft": 0,
        "queued": 0,
        "processing": 0,
        "completed": 1,
        "failed": 0,
        "total": 1
      }
    }
  ],
  "first_id": "c7ea032b-eb16-4ccb-94a6-88af66db5d22",
  "last_id": "c7ea032b-eb16-4ccb-94a6-88af66db5d22",
  "has_more": false
}
```

**Field Explanation**

| Field | Detail |
| --- | --- |
| object | 固定為 `list` |
| data[] | 請參考「[知識版本物件](https://privstation-docs.apmic.ai/latest/privai-400/知識版本物件.md)」章節列表 |
| first_id | 本頁第一個知識版本的 ID，無資料時為 null |
| last_id | 本頁最後一個知識版本的 ID，無資料時為 null |
| has_more | 是否還有更多的知識版本 |

備註：`file_counts` 是依據 **Fileset File State** 計算，而非 File 物件本身的解析狀態。

#### 常見錯誤代碼

| Error Code | HTTP Status | 情境 |
| --- | --- | --- |
| VAL_001 | 422 | 同時帶入 `after` 與 `before` |
| VAL_002 | 404 | `after`／`before` 指定的 Fileset ID 不存在 |

身份驗證錯誤（`AUTH_001`～`AUTH_003`）詳見「錯誤代碼說明-身份驗證類」章節；參數驗證錯誤請參考 [錯誤代碼說明-傳遞參數驗證類](https://privstation-docs.apmic.ai/latest/privai-400/錯誤代碼說明-傳遞參數驗證類.md)。
