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