# LiveDoc API

建立知識庫、管理資源，並執行語意檢索和路由。

本頁說明既有的 `/v2` Felo APIs，使用 **Felo 帳戶權益與 Pro 點數規則**。是否扣除點數取決於 [操作](https://openapi.felo.ai/zh-TW/docs/faq/billing-and-credits.md#依-v2-能力區分的點數規則)。若要使用平台餘額呼叫，請選擇支援的 [Felo OpenAPI 端點](https://openapi.felo.ai/zh-TW/docs/api-reference/openapi/overview.md)；請求與回應格式可能不同。

LiveDoc 網址使用 `https://felo.ai/livedoc/{short_id}`。可能需要具備對該 LiveDoc 存取權的瀏覽器工作階段。請保留每個端點的 API 欄位名稱：SuperAgent 會回傳 `live_doc_short_id`，而 mindmap 與 PPT 建立則回傳 `livedoc_short_id`。

LiveDoc API 提供 LiveDocs 及其資源的完整 CRUD 操作，包括文件建立、檔案上傳、URL 匯入與語意擷取。

## 與 AI 代理人一起使用

安裝完整的 `felo-ai` 套件，為 Agent 提供 LiveDoc 支援以及所有其他可用的 Felo Skills。安裝程式會動態探索每個包含 `SKILL.md` 的套件目錄，包括未來新增的套件。請將所有探索到的 Skills 安裝到 Agent 的原生目錄：Codex `~/.codex/skills`、Claude Code `~/.claude/skills`、OpenClaw `~/.agents/skills`，或 Hermes Agent `~/.hermes/skills`。 [手動 AI Agent 設定指南](https://openapi.felo.ai/zh-TW/docs/felo-skills.md) 涵蓋各平台不同的 API 金鑰與驗證步驟。


## 驗證

所有請求都需要在 `Authorization` 標頭中提供 API Key：

```
Authorization: Bearer YOUR_API_KEY
```

---

## 1. 建立 LiveDoc

### 端點

```
POST https://openapi.felo.ai/v2/livedocs
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `name` | string | 是 | LiveDoc 名稱 |
| `description` | string | 否 | LiveDoc 描述 |
| `icon` | string | 否 | LiveDoc 圖示 |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "AI Research Notes",
    "description": "Collection of AI research materials"
  }'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": {
    "short_id": "PvyKouzJirXjFdst4uKRK3",
    "name": "AI Research Notes",
    "description": "Collection of AI research materials",
    "icon": null,
    "created_at": "2026-03-09T10:00:00Z",
    "modified_at": "2026-03-09T10:00:00Z"
  }
}
```
### 回應欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `short_id` | string | LiveDoc ID |
| `name` | string | LiveDoc 名稱 |
| `description` | string | LiveDoc 描述 |
| `icon` | string | LiveDoc 圖示 |
| `created_at` | string | 建立時間戳（ISO 8601） |
| `modified_at` | string | 最後修改時間戳（ISO 8601） |
| `is_shared` | boolean | 此 LiveDoc 是否與目前使用者共享（非其擁有） |

---

## 2. 列出 LiveDocs

### 端點

```
GET https://openapi.felo.ai/v2/livedocs
```

### 查詢參數

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `keyword` | string | 否 | 依關鍵字篩選 |
| `page` | integer | 否 | 頁碼（從 1 開始） |
| `size` | integer | 否 | 每頁大小 |

### 範例

```bash
curl 'https://openapi.felo.ai/v2/livedocs?keyword=AI&page=1&size=20' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": {
    "total": 2,
    "page": 1,
    "size": 20,
    "items": [
      {
        "short_id": "PvyKouzJirXjFdst4uKRK3",
        "name": "AI Research Notes",
        "description": "Collection of AI research materials",
        "icon": null,
        "created_at": "2026-03-09T10:00:00Z",
        "modified_at": "2026-03-09T10:05:00Z",
        "is_shared": false,
        "readme": {
          "summary": "AI research notes and papers collection",
          "content": "# AI Research Notes\n\nThis LiveDoc contains..."
        }
      }
    ]
  }
}
```
### 回應欄位

`items` 中的每個項目都包含與 [建立 LiveDoc 回應](#回應欄位) 相同的欄位，另外還有：

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `readme` | object \| null | README 資訊。若不存在 README 則為 `null`。 |
| `readme.summary` | string \| null | 一行式專案描述 |
| `readme.content` | string \| null | README 內容（Markdown） |

---

### 端點

```
PUT https://openapi.felo.ai/v2/livedocs/{short_id}
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `name` | string | 否 | 新 LiveDoc 名稱 |
| `description` | string | 否 | 新 LiveDoc 描述 |

### 範例

```bash
curl -X PUT 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Updated Research Notes"
  }'
```

### 成功回應（200）

回傳更新後的 LiveDoc 物件（結構與建立時相同）。

---

## 4. 刪除 LiveDoc

### 端點

```
DELETE https://openapi.felo.ai/v2/livedocs/{short_id}
```

### 範例

```bash
curl -X DELETE 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": null
}
```
---

## 5. 列出資源

### 端點

```
GET https://openapi.felo.ai/v2/livedocs/{short_id}/resources
```

### 查詢參數

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `resource_types` | string[] | 否 | 依資源類型篩選 |
| `page` | integer | 否 | 頁碼（從 1 開始） |
| `size` | integer | 否 | 每頁大小 |

### 範例

```bash
curl 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources?page=1&size=20' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": {
    "total": 2,
    "page": 1,
    "size": 20,
    "items": [
      {
        "id": "res_001",
        "title": "OpenAI Blog Post",
        "link": "https://openai.com/blog/...",
        "snippet": "Summary of the article...",
        "thumbnail": null,
        "resource_type": "web",
        "resource_key": "key_001",
        "status": "completed",
        "source": "url",
        "created_at": "2026-03-09T10:00:10Z",
        "modified_at": "2026-03-09T10:00:15Z"
      }
    ]
  }
}
```
### 資源回應欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `id` | string | 資源 ID |
| `title` | string | 資源標題 |
| `link` | string | 資源連結 / URL |
| `snippet` | string | 資源摘要 |
| `thumbnail` | string | 縮圖 URL |
| `resource_type` | string | 資源類型（例如 `web`、`ai_doc`、`file`） |
| `resource_key` | string | 資源關聯鍵 |
| `status` | string | 資源狀態 |
| `source` | string | 資源來源 |
| `created_at` | string | 建立時間戳（ISO 8601） |
| `modified_at` | string | 最後修改時間戳（ISO 8601） |

---

## 6. 取得單一資源

### 端點

```
GET https://openapi.felo.ai/v2/livedocs/{short_id}/resources/{resource_id}
```

### 範例

```bash
curl 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/res_001' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

回傳單一資源物件（結構與列出資源中的 items 相同）。

---

## 7. 更新資源

更新資源的 `title`、`snippet` 或 `thumbnail`。只會更新有提供的欄位；未提供的欄位會保留目前值。

### 端點

```
PUT https://openapi.felo.ai/v2/livedocs/{short_id}/resources/{resource_id}
```

### 請求主體

所有欄位都是選填。

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `title` | string | 否 | 新資源標題（最多 500 個字元） |
| `snippet` | string | 否 | 新資源摘要（最多 2000 個字元） |
| `thumbnail` | string | 否 | 新縮圖 URL（最多 2000 個字元） |

### 範例

```bash
curl -X PUT 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/res_001' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "title": "Updated Title",
    "snippet": "Updated summary of the resource."
  }'
```

### 成功回應（200）

回傳更新後的資源物件（結構與列出資源中的 items 相同）。

---

## 8. 更新資源內容

更新 `ai_doc` 資源的 Markdown 內容。僅支援 `resource_type == ai_doc` 的資源。`snippet` 欄位會根據新內容的前 2000 位元組自動更新。

### 端點

```
PUT https://openapi.felo.ai/v2/livedocs/{short_id}/resources/{resource_id}/content
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `content` | string | 是 | 資源的新 Markdown 內容 |

### 範例

```bash
curl -X PUT 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/res_001/content' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "content": "# Updated Document\n\nThis is the new content."
  }'
```

### 成功回應（200）

回傳更新後的資源物件（結構與列出資源中的 items 相同）。

---

## 9. 建立文件資源

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/resources/doc
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `title` | string | 否 | 文件標題（預設為 "New Document"） |
| `content` | string | 是 | Markdown 文件內容；純文字也可視為有效 Markdown |

這會建立一個 `ai_doc` 資源。請在 JSON 字串中以 Markdown 傳送標題、清單與連結，並將換行以 `\n` 轉義。格式化的文件內容請使用 Markdown。

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/doc' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "title": "My Research Notes",
    "content": "# Research Notes\n\n## Key findings\n\n- First finding\n- Second finding"
  }'
```

### 成功回應（200）

回傳已建立的資源物件。
---

## 10. 將檔案上傳為文件

上傳檔案並將其轉換為文件資源（`ai_doc` 類型）。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/resources/upload-doc
```

### Content-Type

`multipart/form-data`

### 請求部分

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `file` | file | 是 | 要上傳的檔案 |
| `title` | string | 否 | 文件標題 |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/upload-doc' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -F 'file=@document.pdf' \
  -F 'title=My PDF Document'
```

### 成功回應（200）

回傳已建立的資源物件。

---

## 11. 上傳檔案資源

上傳檔案並保留其原始格式。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/resources/upload
```

### Content-Type

`multipart/form-data`

### 請求部分

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `file` | file | 是 | 要上傳的檔案 |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/upload' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -F 'file=@report.xlsx'
```

### 成功回應（200）

回傳已建立的資源物件。
---

## 12. 新增 URL 資源

將一或多個 URL 作為資源新增到 LiveDoc。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/resources/urls
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `urls` | array | 是 | 要新增的 URL 項目清單（1–10）。每個項目可以是純字串，或是包含 `url` 與選填 `title` 的物件。 |

#### URL 項目格式

`urls` 中的每個項目可以是以下任一種：

- 純字串：`"https://example.com/article"`
- 物件：`{"url": "https://example.com/article", "title": "Custom Title"}`

| 欄位 | 類型 | 必填 | 說明 |
|-------|------|----------|-------------|
| `url` | string | 是 | 要新增的 URL（5–2000 個字元） |
| `title` | string | 否 | 資源的自訂標題（最多 1000 個字元）。若省略，標題會自動從頁面產生。 |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/urls' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "urls": [
      "https://example.com/article-1",
      {"url": "https://example.com/article-2", "title": "My Custom Title"}
    ]
  }'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": [
    {
      "url": "https://example.com/article-1",
      "status": "success",
      "fail_reason": null,
      "resource_id": "res_003"
    },
    {
      "url": "https://example.com/article-2",
      "status": "existed",
      "fail_reason": null,
      "resource_id": "res_004"
    }
  ]
}
```

### URL 結果欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `url` | string | 已處理的 URL |
| `status` | string | 結果狀態：`success`、`failed` 或 `existed` |
| `fail_reason` | string | 失敗原因（成功時為 null） |
| `resource_id` | string | 已建立的資源 ID |

---

## 13. 刪除資源

### 端點

```
DELETE https://openapi.felo.ai/v2/livedocs/{short_id}/resources/{resource_id}
```

### 範例

```bash
curl -X DELETE 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/res_001' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": null
}
```

---

## 14. 擷取（語意搜尋）

對 LiveDoc 中的資源執行語意擷取。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/resources/retrieve
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `query` | string | 是 | 語意搜尋的查詢內容 |
| `resource_ids` | string[] | 否 | 要在其中搜尋的特定資源 ID（1–50）。若省略，相關資源會根據查詢自動路由 |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/retrieve' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "latest developments in large language models",
    "resource_ids": ["res_001", "res_002"]
  }'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": [
    {
      "id": "res_001",
      "title": "LLM Research Paper",
      "content": "Relevant content excerpt...",
      "score": 0.92,
      "metadata": {}
    }
  ]
}
```

### 擷取結果欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `id` | string | 資源 ID |
| `title` | string | 資源標題 |
| `content` | string | 符合的內容 |
| `score` | number | 相關性分數 |
| `metadata` | object | 其他中繼資料 |

---

## 15. 路由資源

根據查詢，將 LiveDoc 中的相關資源進行路由。回傳可傳給擷取端點的資源 ID 清單。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/resources/route
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `query` | string | 是 | 路由用的查詢內容 |
| `max_resources` | integer | 否 | 要回傳的資源 ID 最大數量 |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/route' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "latest developments in large language models",
    "max_resources": 5
  }'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": ["res_001", "res_003", "res_007"]
}
```

---

## 16. 下載資源來源檔案

取得資源的來源檔案。會回傳一個 `302` 重新導向到預簽章下載 URL。

僅支援具有相關來源檔案的資源（例如已上傳的文件）。

### 端點

```
GET https://openapi.felo.ai/v2/livedocs/{short_id}/resources/{resource_id}/download
```

### 查詢參數

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `expires_in` | integer | 否 | URL 逾時秒數（預設：3600） |

### 範例

```bash
curl -L 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/res_001/download' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 回應

回傳 `302 Found`，並帶有指向預簽章 S3 下載 URL 的 `Location` 標頭。支援重新導向的 HTTP 用戶端（例如 `curl -L`）會自動跟隨重新導向並直接下載檔案。

---

## 17. 取得資源內容

取得資源的擷取後文字內容。支援大多數資源類型（document、web、video、ai_doc、ai_ppt、text、voice、mindmap 等）。對 `image` 之類不支援的類型會回傳 400。

### 端點

```
GET https://openapi.felo.ai/v2/livedocs/{short_id}/resources/{resource_id}/content
```

### 範例

```bash
curl 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/res_001/content' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": {
    "title": "Q4 Financial Report",
    "type": "document",
    "content": "Full extracted text content of the resource..."
  }
}
```

### 回應欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `title` | string | 資源標題 |
| `type` | string | 資源類型 |
| `content` | string | 資源內容；其解讀方式取決於 `type`，如下所述 |

### 資源內容格式

`data.content` 是字串。請使用 `data.type` 決定如何讀取：

| 資源類型 | 內容格式 | 讀取步驟 |
|---|---|---|
| `ai_doc` | Markdown | 將字串以文件方式呈現或儲存；這也包含 SuperAgent 研究報告 |
| `mindmap` | JSON 編碼物件 | 解碼一次以讀取 `layout` 與 `text` 中以 Markdown 標題表示的大綱 |
| `ai_ppt` | 含有 `slides` 的 JSON 編碼物件 | 解碼一次，然後若每張投影片的 `content` 字串包含 JSON，則再解碼一次 |
| 其他含文字類型 | 擷取文字 | 依你的應用程式需求顯示文字 |

解碼後的 mindmap 內容範例：

```json
{
  "layout": "mindMap",
  "text": "# Topic\n## Branch\n### Leaf"
}
```

解碼後的 PPT 內容範例：

```json
{
  "slides": [
    {
      "page": 1,
      "title": "Introduction",
      "content": "{\"coreIdea\":\"Introduce the topic\",\"slideOverview\":\"Overview of key points\",\"themeDescription\":\"Light background\"}",
      "theme": "light",
      "url": "https://example.com/slide-preview?signature=..."
    }
  ]
}
```

投影片欄位取決於生成器，可能不存在或包含額外資訊。請將 `coreIdea`、`slideOverview` 與 `themeDescription` 視為選填的簡報中繼資料。若投影片的 `content` 是純文字，請直接顯示。

投影片 `url` 值是暫時性的簽名連結。其有效期會在發出時決定；當連結過期時，請重新擷取資源內容。若要下載 PPTX，請使用獨立的 [PPT 匯出工作流程](https://openapi.felo.ai/zh-TW/docs/api-reference/ppt-tasks.md#匯出-pptx)，其回應包含 `expires_at`。

---

## 18. PPT 頁面擷取

對 PPT 資源的特定頁面執行深度內容擷取。會抓取投影片頁面並回傳排序後的內容區塊。回應格式與 [擷取](#14-擷取-語意搜尋) 端點相同。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/resources/ppt-retrieve
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `resource_id` | string | 是 | PPT 資源 ID |
| `page_number` | integer | 是 | 要擷取的頁碼（從 1 開始） |
| `query` | string | 是 | 描述要尋找內容的查詢 |
| `max_chunk` | integer | 否 | 要回傳的最大區塊數（預設：3） |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/resources/ppt-retrieve' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "resource_id": "res_001",
    "page_number": 3,
    "query": "product pricing information",
    "max_chunk": 3
  }'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": [
    {
      "id": "res_001_page_3_chunk_1",
      "title": "Q4 Product Deck",
      "content": "Relevant slide content excerpt...",
      "score": null,
      "metadata": {
        "resource_id": "res_001",
        "page_number": 3,
        "index": 1
      }
    }
  ]
}
```

### 回應欄位

與 [擷取結果欄位](#擷取結果欄位) 相同。

---

## 錯誤代碼


| 代碼 | HTTP 狀態 | 說明 |
|------|-------------|-------------|
| `INVALID_API_KEY` | 401 | API Key 無效或已撤銷 |
| `LIVEDOC_CREATE_FAILED` | 502 | 建立 LiveDoc 失敗 |
| `LIVEDOC_UPDATE_FAILED` | 502 | 更新 LiveDoc 失敗 |
| `LIVEDOC_DELETE_FAILED` | 502 | 刪除 LiveDoc 失敗 |
| `LIVEDOC_NOT_FOUND` | 404 | 找不到 LiveDoc |
| `LIVEDOC_LIST_FAILED` | 502 | 列出 LiveDocs 失敗 |
| `LIVEDOC_RESOURCE_CREATE_FAILED` | 502 | 建立資源失敗 |
| `LIVEDOC_RESOURCE_UPLOAD_FAILED` | 502 | 上傳資源失敗 |
| `LIVEDOC_RESOURCE_DELETE_FAILED` | 502 | 刪除資源失敗 |
| `LIVEDOC_RESOURCE_NOT_FOUND` | 404 | 找不到資源 |
| `LIVEDOC_RESOURCE_LIST_FAILED` | 502 | 列出資源失敗 |
| `LIVEDOC_RESOURCE_RETRIEVE_FAILED` | 502 | 擷取資源失敗 |
| `LIVEDOC_RESOURCE_ADD_URLS_FAILED` | 502 | 新增 URL 資源失敗 |

---

## 19. 取得 README

取得 LiveDoc 的 README 內容。若未設定 README，則回傳空字串。

### 端點

```
GET https://openapi.felo.ai/v2/livedocs/{short_id}/readme
```

### 範例

```bash
curl 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/readme' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": {
    "summary": "A brief one-line description of the project.",
    "content": "# My LiveDoc\n\nThis is the README content in Markdown."
  }
}
```

### 回應欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `summary` | string \| null | 一行式專案描述。最多 2000 個字元。 |
| `content` | string | README 內容（Markdown）。若未設定則為空字串。 |

---

## 20. 建立或更新 README

建立或更新 LiveDoc 的 README（upsert 語意）。

### 端點

```
PUT https://openapi.felo.ai/v2/livedocs/{short_id}/readme
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `summary` | string | 否 | 一行式專案描述（最多 2000 個字元） |
| `content` | string | 否 | README 內容（Markdown） |

> **注意：** 必須至少提供 `summary` 或 `content` 其中之一。

### 範例

```bash
curl -X PUT 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/readme' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "summary": "A brief one-line description of the project.",
    "content": "# My LiveDoc\n\nThis is the README content in Markdown."
  }'
```

### 成功回應（200）

回傳更新後的 README 物件（結構與取得 README 相同）。

---

## 21. 附加至 README

將內容附加到既有 README 的結尾。若不存在 README，則會以提供的內容建立新的 README。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/readme/append
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `content` | string | 是 | 要附加的內容（Markdown） |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/readme/append' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "content": "\n\n## New Section\n\nAdditional content appended to README."
  }'
```

### 成功回應（200）

回傳附加後的完整 README 物件（結構與取得 README 相同）。

---

## 22. 刪除 README

刪除 LiveDoc 的 README。

### 端點

```
DELETE https://openapi.felo.ai/v2/livedocs/{short_id}/readme
```

### 範例

```bash
curl -X DELETE 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/readme' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": null
}
```

---

## 23. 列出任務

取得 LiveDoc 中任務的分頁清單。結果依 `sort` 升冪、`status` 升冪、`created_at` 降冪排序。

### 端點

```
GET https://openapi.felo.ai/v2/livedocs/{short_id}/tasks
```

### 查詢參數

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `status` | integer | 否 | 依狀態篩選：`0`=TODO、`1`=IN_PROGRESS、`2`=DONE |
| `labels` | string[] | 否 | 依標籤篩選（任務必須包含所有指定標籤） |
| `page` | integer | 否 | 頁碼（從 1 開始） |
| `size` | integer | 否 | 每頁大小 |

### 範例

```bash
curl 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/tasks?status=0&page=1&size=20' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": {
    "total": 1,
    "page": 1,
    "size": 20,
    "items": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "title": "Write documentation",
        "description": "Write API documentation for the new endpoints",
        "status": 0,
        "sort": 0,
        "labels": ["docs", "priority-high"],
        "created_at": "2026-03-19T10:00:00Z",
        "modified_at": "2026-03-19T10:00:00Z"
      }
    ]
  }
}
```

### 任務回應欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `id` | string | 任務 ID（UUID） |
| `title` | string | 任務標題 |
| `description` | string | 任務描述 |
| `status` | integer | 任務狀態：`0`=TODO、`1`=IN_PROGRESS、`2`=DONE |
| `sort` | integer | 排序順序（非負） |
| `labels` | string[] | 標籤清單 |
| `operated_by` | string | 操作人簽章，例如 `claude-code`、`openclaw` |
| `created_at` | string | 建立時間戳（ISO 8601） |
| `modified_at` | string | 最後修改時間戳（ISO 8601） |

---

## 24. 建立任務

在 LiveDoc 中建立新任務。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/tasks
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `title` | string | 是 | 任務標題 |
| `description` | string | 否 | 任務描述 |
| `status` | integer | 是 | 任務狀態：`0`=TODO、`1`=IN_PROGRESS、`2`=DONE |
| `sort` | integer | 是 | 排序順序（非負整數） |
| `labels` | string[] | 否 | 標籤清單（最多 10 個，每個最多 50 個字元） |
| `operated_by` | string | 否 | 操作人簽章，例如 `claude-code`、`openclaw`（最多 100 個字元） |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/tasks' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "title": "Write documentation",
    "description": "Write API documentation for the new endpoints",
    "status": 0,
    "sort": 0,
    "labels": ["docs", "priority-high"]
  }'
```

### 成功回應（200）

回傳已建立的任務物件（結構與列出任務中的 items 相同）。

---

## 25. 更新任務

部分更新任務。只會更新有提供的欄位；未提供的欄位會保留目前值。

### 端點

```
PATCH https://openapi.felo.ai/v2/livedocs/{short_id}/tasks/{task_id}
```

### 請求主體

所有欄位都是選填。

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `title` | string | 否 | 新任務標題 |
| `description` | string | 否 | 新任務描述 |
| `status` | integer | 否 | 新狀態：`0`=TODO、`1`=IN_PROGRESS、`2`=DONE |
| `sort` | integer | 否 | 新排序順序（非負） |
| `labels` | string[] | 否 | 新標籤清單（最多 10 個，每個最多 50 個字元） |
| `operated_by` | string | 否 | 操作人簽章，例如 `claude-code`、`openclaw`（最多 100 個字元） |

### 範例

```bash
curl -X PATCH 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/tasks/550e8400-e29b-41d4-a716-446655440000' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "status": 1
  }'
```

### 成功回應（200）

回傳更新後的任務物件（結構與列出任務中的 items 相同）。

---

## 26. 刪除任務

軟刪除任務。

### 端點

```
DELETE https://openapi.felo.ai/v2/livedocs/{short_id}/tasks/{task_id}
```

### 範例

```bash
curl -X DELETE 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/tasks/550e8400-e29b-41d4-a716-446655440000' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": null
}
```

---

## 27. 列出任務紀錄

取得任務的紀錄分頁清單（留言與變更歷史），依 `created_at` 升冪排序。

### 端點

```
GET https://openapi.felo.ai/v2/livedocs/{short_id}/tasks/{task_id}/records
```

### 查詢參數

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `record_type` | string | 否 | 依紀錄類型篩選：`comment`、`edit`、`status_change` |
| `page` | integer | 否 | 頁碼（從 1 開始） |
| `size` | integer | 否 | 每頁大小 |

### 範例

```bash
curl 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/tasks/550e8400-e29b-41d4-a716-446655440000/records' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

### 成功回應（200）

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "req_example",
  "message": null,
  "data": {
    "total": 2,
    "page": 1,
    "size": 20,
    "items": [
      {
        "id": "rec_001",
        "record_type": "comment",
        "content": "This is a comment",
        "meta": null,
        "task_id": "550e8400-e29b-41d4-a716-446655440000",
        "created_at": "2026-03-19T10:05:00Z",
        "modified_at": "2026-03-19T10:05:00Z"
      },
      {
        "id": "rec_002",
        "record_type": "status_change",
        "content": null,
        "meta": {"from": 0, "to": 1},
        "task_id": "550e8400-e29b-41d4-a716-446655440000",
        "created_at": "2026-03-19T10:10:00Z",
        "modified_at": "2026-03-19T10:10:00Z"
      }
    ]
  }
}
```

### 任務紀錄回應欄位

| 欄位 | 類型 | 說明 |
|-------|------|-------------|
| `id` | string | 紀錄 ID |
| `record_type` | string | 紀錄類型：`comment` / `edit` / `status_change` |
| `content` | string | 留言文字（僅適用於 `comment` 類型） |
| `meta` | object | 變更詳細資訊（適用於 `edit` 與 `status_change` 類型） |
| `task_id` | string | 父層任務 ID |
| `operated_by` | string | 操作人簽章，例如 `claude-code`、`openclaw` |
| `created_at` | string | 建立時間戳（ISO 8601） |
| `modified_at` | string | 最後修改時間戳（ISO 8601） |

---

## 28. 新增任務留言

為任務新增留言。

### 端點

```
POST https://openapi.felo.ai/v2/livedocs/{short_id}/tasks/{task_id}/comments
```

### 請求主體

| 參數 | 類型 | 必填 | 說明 |
|-----------|------|----------|-------------|
| `content` | string | 是 | 留言內容 |
| `operated_by` | string | 否 | 操作人簽章，例如 `claude-code`、`openclaw`（最多 100 個字元） |

### 範例

```bash
curl -X POST 'https://openapi.felo.ai/v2/livedocs/PvyKouzJirXjFdst4uKRK3/tasks/550e8400-e29b-41d4-a716-446655440000/comments' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "content": "This task is now in progress."
  }'
```

### 成功回應（200）

回傳已建立的紀錄物件（結構與列出任務紀錄中的 items 相同）。

---

## 更新後的錯誤代碼

| 代碼 | HTTP 狀態 | 說明 |
|------|-------------|-------------|
| `INVALID_API_KEY` | 401 | API Key 無效或已撤銷 |
| `LIVEDOC_CREATE_FAILED` | 502 | 建立 LiveDoc 失敗 |
| `LIVEDOC_UPDATE_FAILED` | 502 | 更新 LiveDoc 失敗 |
| `LIVEDOC_DELETE_FAILED` | 502 | 刪除 LiveDoc 失敗 |
| `LIVEDOC_NOT_FOUND` | 404 | 找不到 LiveDoc |
| `LIVEDOC_LIST_FAILED` | 502 | 列出 LiveDocs 失敗 |
| `LIVEDOC_RESOURCE_CREATE_FAILED` | 502 | 建立資源失敗 |
| `LIVEDOC_RESOURCE_UPLOAD_FAILED` | 502 | 上傳資源失敗 |
| `LIVEDOC_RESOURCE_DELETE_FAILED` | 502 | 刪除資源失敗 |
| `LIVEDOC_RESOURCE_NOT_FOUND` | 404 | 找不到資源 |
| `LIVEDOC_RESOURCE_LIST_FAILED` | 502 | 列出資源失敗 |
| `LIVEDOC_RESOURCE_RETRIEVE_FAILED` | 502 | 擷取資源失敗 |
| `LIVEDOC_RESOURCE_ADD_URLS_FAILED` | 502 | 新增 URL 資源失敗 |
| `LIVEDOC_README_GET_FAILED` | 502 | 取得 README 失敗 |
| `LIVEDOC_README_UPDATE_FAILED` | 502 | 建立或更新 README 失敗 |
| `LIVEDOC_README_DELETE_FAILED` | 502 | 刪除 README 失敗 |
| `LIVEDOC_README_NOT_FOUND` | 404 | 找不到 README |
| `LIVEDOC_TASK_LIST_FAILED` | 502 | 列出任務失敗 |
| `LIVEDOC_TASK_CREATE_FAILED` | 502 | 建立任務失敗 |
| `LIVEDOC_TASK_UPDATE_FAILED` | 502 | 更新任務失敗 |
| `LIVEDOC_TASK_DELETE_FAILED` | 502 | 刪除任務失敗 |
| `LIVEDOC_TASK_NOT_FOUND` | 404 | 找不到任務 |
| `LIVEDOC_TASK_RECORD_LIST_FAILED` | 502 | 列出任務紀錄失敗 |
| `LIVEDOC_TASK_COMMENT_CREATE_FAILED` | 502 | 建立任務留言失敗 |
