在所有會話中搜尋,根據會話資料中的字串內容尋找匹配項目。
基礎 URL
搜尋會話
POST /project/{projectId}/integration/api/session/search
路徑參數
請求標頭
使用您的 API 金鑰進行 Bearer 令牌認證
請求主體
要在會話資料中搜尋的字串。這將匹配所有會話內容,包括變數、訊息和其他儲存的資訊。
curl -X POST https://api.pathors.com/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 降冪排序(最新的在前)
- 分頁: 使用
limit 和 offset 來分頁瀏覽大量結果集
- 效能: 對於大型資料集,建議使用更具體的搜尋字串以提高查詢效能
錯誤回應
| 狀態碼 | 描述 |
| 400 | 缺少或無效的 search_string |
| 401 | 無效的認證 |
| 500 | 內部伺服器錯誤 |
錯誤回應範例:
400 請求錯誤:
{
"error": "search_string is required"
}
401 身份驗證失敗:
{
"error": {
"message": "Invalid authentication"
}
}
相關 API