查询 UI 协议会话消息¶
按 ID 游标读取当前用户的消息,返回消息数组。
POST https://api.moi.matrixorigin.cn/v5/messages/session/list
调用前准备¶
BASE_URL 使用产品 API 前缀 https://api.moi.matrixorigin.cn/v5;专有部署填写对应的产品 API 地址。
配置同环境的身份、工作区和数值记录 ID。该入口采用普通产品身份认证,附加的任务运行期授权头会被拒绝。
请求¶
curl --request POST \
"$BASE_URL/messages/session/list" \
--header "X-API-Key: $MOI_KEY" \
--header "X-Workspace-ID: $WORKSPACE_ID" \
--header "Content-Type: application/json" \
--data-raw '{"session_id":41,"after":0,"limit":50}'
若上一页末条消息 ID 为 71,下一页使用以下完整请求:
curl --request POST \
"$BASE_URL/messages/session/list" \
--header "X-API-Key: $MOI_KEY" \
--header "X-Workspace-ID: $WORKSPACE_ID" \
--header "Content-Type: application/json" \
--data-raw '{"session_id":41,"after":71,"limit":50}'
参数 |
位置 |
类型 |
必填 |
说明 |
|---|---|---|---|---|
|
请求头 |
string |
是 |
目标工作区 ID。 |
|
请求体 |
integer |
是 |
本服务的正整数会话 ID,JSON 中使用数值。 |
|
请求体 |
integer |
否 |
返回 ID 大于该值的消息;非正值按 0。 |
|
请求体 |
integer |
否 |
默认 50;非正值或超过 100 时按 50。 |
|
请求体 |
string |
否 |
user/system/assistant 参与筛选;其他字符串按不筛选。 |
|
请求体 |
string |
否 |
记录状态筛选,去掉前后空白。 |
|
请求体 |
string |
否 |
绑定接收但不参与当前筛选。 |
|
请求体 |
string |
否 |
绑定接收但不参与当前筛选。 |
data 直接是消息数组,没有 messages、total 或 next_cursor 包装。消息按 ID 升序,下一页 after 取末条消息 ID,读到空数组结束。空结果不独立证明会话存在。角色是字符串,不是工作区协议的整数。内部 agent_tool 角色在此响应中映射为 user。
成功响应¶
{
"code": "OK",
"msg": "OK",
"data": [
{
"id": 71,
"user_id": "user-example",
"session_id": 41,
"source": "moi",
"role": "assistant",
"original_content": "",
"content": "已有消息",
"model": "",
"status": "completed",
"config": "",
"response": "已有回答",
"modified_response": "",
"tags": [],
"created_at": 1794445200,
"updated_at": 1794445200
}
]
}
字段 |
类型 |
说明 |
|---|---|---|
|
string |
成功为 OK;HTTP 状态码为 200。 |
|
string |
成功为 OK。 |
|
array(对象数组) |
当前页消息对象,无匹配项时为空数组。 |
错误响应¶
错误格式和结果确认区分会话详情的 not-found 与其他入口的通用服务错误。