Query session messages¶
Read saved messages in visible sessions. This interface is read-only; new messages are written by the A2A runtime called by the agent and are not created through this interface.
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/conversations/{conversation_id}/messages
Preparation before calling¶
First query session details or create session] to obtain the session ID. Prepare the personal access token, target workspace ID, and session ID that have access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$CONVERSATION_ID: The session ID of the message to be queried.$AGENT_ID: Optional agent filter ID.
Request example¶
curl --get "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/conversations/$CONVERSATION_ID/messages" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
--data-urlencode "agent_id=$AGENT_ID" \
--data-urlencode "role=assistant" \
--data-urlencode "limit=50"
Path parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Current workspace ID, must be consistent with |
|
string |
Yes |
The session ID of the message to be queried. |
Query parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
No |
Only queries sessions belonging to the specified agent. Does not filter by agent ID when not provided. |
|
string |
No |
ID of the workspace to which the agent belongs. When |
|
string |
No |
Filter by message role. |
|
integer |
No |
Single return quantity. |
|
integer |
No |
Returns the offset. |
Successful response¶
Returns 200 on success. data.items is a saved message on this page. It provides related information and content segmentation according to the session message sequence number.
{
"code": 0,
"data": {
"items": [
{
"id": "msg_01",
"workspace_id": "ws_01",
"conversation_id": "conv_01",
"task_id": "task_01",
"agent_id": "agent_01",
"role": "assistant",
"parts": [
{
"kind": "text",
"text": "分析已完成"
}
],
"seq": 2,
"created_at": "2026-01-02T15:04:05Z"
}
],
"total": 1,
"limit": 50,
"offset": 0
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
object[] |
List of messages on this page. |
|
string |
Message ID. |
|
string |
ID of the workspace to which the message belongs. |
|
string |
The session ID to which the message belongs. |
|
string |
Associated task ID; does not return if there is no associated task. |
|
string |
Associated agent ID; not returned if there is no associated agent. |
|
string |
Associated runtime manifest ID; not returned if there is no associated manifest. |
|
string |
Message role. |
|
object[] |
Message content segments. The fields of each element are determined by the message segment type. |
|
string |
Parent message ID; does not return if there is no parent message. |
|
integer |
Message sequence number within the session. |
|
string |
Message creation time, in RFC 3339 format. |
|
integer |
The total number of messages that meet the filter conditions. |
|
integer |
The upper limit of the actual return quantity used this time. |
|
integer |
The offset actually used this time. |
[] after a type denotes an array. [] in a field path denotes each item in an array.
Error response¶
{
"code": 3,
"message": "会话不存在"
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
Invalid session ID, agent filter parameter, or pagination parameter. |
Check path and query parameters. |
|
|
The session does not exist, is not visible, or does not belong to the specified agent scope. |
Confirm session ID and agent filters. |
|
|
The server cannot query messages or generate message display data. |
Record the request time and error message and try again. |
|
|
Session service is temporarily unavailable. |
Try again later. |
Follow-up operations¶
Use Query session details to read the session’s current display information and active task associations.