Knowledge API

把商家知識庫,接進你的 Agent。

一組 Bearer key,跨多個 Profile 讀取、建立與更新知識文件。商家邊界、scope 與 key 權限在 API 層強制執行。

公開入口只開放 webhooks 與 /api/v1/open/*。管理 API 不在公開入口。

GET /api/v1/open/me200 OK
curl -fsS \
  -H "Authorization: Bearer $CHATOLINO_API_KEY" \
  https://chatolino.example.com/api/v1/open/me

{
  "keyName": "Claude - All Businesses",
  "scopes": ["knowledge:read", "knowledge:write"],
  "profiles": [
    { "id": "uuid-a", "name": "Siam Studio" },
    { "id": "uuid-b", "name": "North Coffee" }
  ]
}
Auth

Bearer API key

Profiles

一把 key 對應多個商家

Scopes

Read、write、delete 分開授權

Secret

建立時只顯示一次

不是把管理後台搬上 API,而是給 Agent 一條清楚的路。

你的 Agent 只需要知道自己要處理哪個商家、哪個分類,以及是否被允許寫入。其他邊界由 Chatolino 處理。

01

多商家 key,一次設定

建立 key 時選取一個或多個 Profile。同一個 Agent 可以在不同商家之間切換,不必管理多套憑證。

02

Scope 跟著 key 走

Read 只能查詢,write 只能建立與更新,delete 需要另外授權。缺少 scope 時回傳403 insufficient_scope。

03

文件格式與管理後台一致

標題、Markdown 內容、分類與 tags 都是同一份資料。Agent 寫入後,客服回覆會直接使用最新的知識庫。

04

錯誤可以預期

無效 key、已撤銷 key、scope 不足、商家不存在與 embedding 失敗都有固定 error code 與 HTTP status。

三個請求,開始寫入知識。

先在管理後台的 API access 頁面建立 key,選取 Profile 與 scope,再從這裡開始。

  1. 01

    確認 key 與可存取的商家

    先呼叫 /me,確認 key 名稱、scope 與 Profile 清單,並把 profiles[].id 設為 PROFILE_ID。

    export CHATOLINO_API_KEY='chk_live_xxx'
    export PROFILE_ID='uuid'
    
    curl -fsS \
      -H "Authorization: Bearer $CHATOLINO_API_KEY" \
      "https://chatolino.example.com/api/v1/open/me"
  2. 02

    取得分類的穩定 key

    分類 response 同時提供 id 與 key。Agent 建議使用 key。

    curl -fsS \
      -H "Authorization: Bearer $CHATOLINO_API_KEY" \
      "https://chatolino.example.com/api/v1/open/profiles/$PROFILE_ID/knowledge/categories"
  3. 03

    建立第一份知識文件

    需要 knowledge:write。title 或 body 變更時會重新計算 token 與 embedding。

    curl -fsS -X POST \
      -H "Authorization: Bearer $CHATOLINO_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"title":"退款政策","body":"七日內可申請退貨。","categoryKey":"refund","tags":["policy"]}' \
      "https://chatolino.example.com/api/v1/open/profiles/$PROFILE_ID/knowledge/documents"

端點總覽

所有路徑都接在 /api/v1/open 之後。文件格式與管理 API 相同。

MethodPathScope用途
GET/mekey驗證 key,取得 scope 與 Profiles
GET/profiles/{profileId}/knowledge/categoriesknowledge:read列出七個固定分類
GET/profiles/{profileId}/knowledge/documentsknowledge:read列表,支援 category、tag、limit
POST/profiles/{profileId}/knowledge/documentsknowledge:write建立文件,回傳 Location
GET/profiles/{profileId}/knowledge/documents/{documentId}knowledge:read讀取單一文件
PATCH/profiles/{profileId}/knowledge/documents/{documentId}knowledge:write只更新有提交的欄位
DELETE/profiles/{profileId}/knowledge/documents/{documentId}knowledge:delete刪除文件與向量

列表的 limit 範圍為 1 到 200。未提供時回傳全部符合文件。V1 尚未提供 cursor pagination。

認證與授權

Key 只接受 Authorization header,不接受 query string。撤銷後立即失效。

knowledge:read
讀取分類、文件列表與單一文件。
knowledge:write
建立文件、更新 title、body、category 或 tags。
knowledge:delete
刪除文件,同時清除 embedding 與向量。

Request header

Authorization: Bearer chk_live_xxx
Content-Type: application/json

Key 建立時只回傳一次明碼。之後只保留 prefix 與末四碼,無法再次查看。

錯誤回應

所有錯誤都使用同一個 envelope,Agent 可以依 code 決定重試或轉人工。

{
  "error": {
    "code": "insufficient_scope",
    "message": "The API key does not grant this scope.",
    "requestId": "req_..."
  }
}
HTTPCode
401invalid_api_key, api_key_revoked, api_key_expired
403insufficient_scope
404not_found
422invalid_request, document_too_large
502embedding_failed
503embedding_not_configured
Ready when you are

讓 Agent 維護知識,讓客服專注對話。

API key 在 Chatolino 管理後台的 API access 頁面建立。選取 Profile 與 scope 後,就可以從/me 開始。