> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pathors.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 建立資料集

> 上傳檔案並在知識庫中建立資料集

上傳檔案作為新的資料集。上傳後檔案會以非同步方式切割成區塊並嵌入 — 請輪詢 [列出資料集](/zh-Hant/api-reference/v1/datasets/list-datasets) 並觀察 `isParsed`，以得知何時可供查詢。

## 請求

```bash theme={null}
POST https://api.pathors.com/v1/projects/{projectId}/knowledgebases/{knowledgebaseId}/datasets
```

### 路徑參數

<ParamField path="projectId" type="string" required>專案 ID</ParamField>
<ParamField path="knowledgebaseId" type="string" required>要上傳至的知識庫</ParamField>

### 標頭

<ParamField header="Authorization" type="string" required>
  使用您的 Developer Key 進行 Bearer 令牌認證
</ParamField>

<ParamField header="Content-Type" type="string" required>
  必須為 `multipart/form-data`
</ParamField>

### 請求主體

<ParamField body="dataset" type="file" required>
  要上傳的檔案。支援格式：PDF、TXT、DOCX 及其他以文字為基礎的格式。
</ParamField>

## 回應

```json theme={null}
{
  "message": "Dataset Uploaded successfully, currently embedding in the background",
  "success": true
}
```

### 範例

```bash theme={null}
curl -X POST https://api.pathors.com/v1/projects/{projectId}/knowledgebases/kb_abc123/datasets \
  -H "Authorization: Bearer dk_your_key" \
  -F "dataset=@/path/to/your/file.pdf"
```
