POST
/
api
/
project
/
{projectId}
/
integration
/
api
/
session
/
search
搜尋會話
curl --request POST \
  --url https://app.pathors.com/api/project/{projectId}/integration/api/session/search \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "search_string": "<string>",
  "limit": 123,
  "offset": 123
}'
{
  "results": [
    {
      "sessionId": "<string>",
      "data": {},
      "createdAt": "<string>",
      "updatedAt": "<string>"
    }
  ],
  "pagination": {
    "limit": 123,
    "offset": 123,
    "total": 123
  }
}
在所有會話中搜尋,根據會話資料中的字串內容尋找匹配項目。

搜尋會話

POST /api/project/{projectId}/integration/api/session/search

路徑參數

projectId
string
required
您的專案 ID

請求標頭

Authorization
string
required
使用您的 API 金鑰進行 Bearer 令牌認證

請求主體

search_string
string
required
要在會話資料中搜尋的字串。這將匹配所有會話內容,包括變數、訊息和其他儲存的資訊。
limit
number
要返回的最大結果數。預設值:50
offset
number
分頁時要跳過的結果數。預設值:0

回應

results
array
匹配的會話陣列,按最近更新時間排序
pagination
object
分頁資訊

範例

請求

curl -X POST https://app.pathors.com/api/project/{projectId}/integration/api/session/search \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "search_string": "王小明",
    "limit": 10,
    "offset": 0
  }'

回應

{
  "results": [
    {
      "sessionId": "user-123-session-456",
      "data": {
        "variables": {
          "userName": "王小明",
          "userRole": "admin"
        },
        "messages": [
          {
            "role": "user",
            "content": "你好"
          },
          {
            "role": "assistant",
            "content": "您好,王小明!有什麼可以幫助您的嗎?"
          }
        ]
      },
      "createdAt": "2024-01-15T10:30:00.000Z",
      "updatedAt": "2024-01-15T10:35:00.000Z"
    },
    {
      "sessionId": "user-456-session-789",
      "data": {
        "variables": {
          "userName": "王小明",
          "userRole": "user"
        },
        "messages": []
      },
      "createdAt": "2024-01-14T15:20:00.000Z",
      "updatedAt": "2024-01-14T15:25:00.000Z"
    }
  ],
  "pagination": {
    "limit": 10,
    "offset": 0,
    "total": 2
  }
}

使用說明

  • 搜尋字串: 搜尋區分大小寫,並匹配會話資料的整個 JSON 內容
  • 排序: 結果按 updatedAt 降冪排序(最新的在前)
  • 分頁: 使用 limitoffset 來分頁瀏覽大量結果集
  • 效能: 對於大型資料集,建議使用更具體的搜尋字串以提高查詢效能

錯誤回應

狀態碼描述
400缺少或無效的 search_string
401無效的認證
500內部伺服器錯誤
錯誤回應範例: 400 請求錯誤:
{
  "error": "search_string is required"
}
401 身份驗證失敗:
{
  "error": {
    "message": "Invalid authentication"
  }
}

相關 API