GetThreadData
Retrieves the conversation data of a specified thread and returns the messages generated in each turn in chronological order with pagination.
Operation description
The session data is organized in the data array by conversation turn. Each element corresponds to a turn and contains the messages generated in that turn, along with the request ID and Tracing Analysis ID of the request that initiated the turn. The message structure is consistent with the messages returned in the stream of CreateChat. You can use callId and parentCallId to revert the execute hierarchy of the agent, use contents to obtain text content, use events to track node status changes, and use tools and agents to understand the execute procedure. For long sessions, use nextToken to read the data page by page.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
log:GetThreadData |
get |
*DataAgent
|
None | None |
Request syntax
GET /dataagents/{name}/threads/{threadId}/data HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| name |
string |
No |
The name of the DataAgent. This parameter is passed in the request path and specifies the DataAgent to which the session belongs. |
order-analysis-agent |
| threadId |
string |
No |
The ID of the session to query. This parameter is passed in the request path and is returned by CreateThread. |
thread-tiirv9-irwdoal8t4rm |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| nextToken |
string |
No |
The pagination cursor. Pass the nextToken returned in the previous response to retrieve the next page. This parameter is not required for the first query. |
e81493d42a7d212810e0ac**** |
| maxResults |
integer |
No |
The maximum number of conversation turns to return per page. Maximum value: 100. |
20 |
For the first query, you only need to pass name and threadId in the path. To retrieve the next page, pass the nextToken from the previous response as a query parameter without modification. If maxResults is not specified, the default number of items per page is used.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response body. Returns the conversation data and pagination information of the thread. |
||
| data |
array<object> |
The thread data returned in the current response. The data is paginated and sorted in chronological order of the conversation turns. |
|
|
array<object> |
The data of a single conversation turn. |
||
| messages |
array<object> |
The list of messages generated in the current turn, including user inputs, agent replies, tool invocations, and status events. |
|
|
array<object> |
A single message. |
||
| agents |
array<object> |
The list of sub-agent calls initiated in the current message. This field may appear only when role is assistant. |
[ { "name": "search_data", "arguments": { "query": "The URL with the highest number of requests in the last hour" }, "status": "success" } ] |
|
object |
The information about a single sub-agent call. |
{ "name": "search_data", "arguments": { "query": "The URL with the highest number of requests in the last hour" }, "status": "success" } |
|
|
any |
The details of sub-agent invocations. Common fields include name (the name of the sub-agent), arguments (the input parameters for the current invocation), and status (the execution status: start, progress, success, or fail). |
search_data |
|
| artifacts |
array<object> |
The list of artifacts (files) produced by the current message. This field may appear only when role is assistant. |
[{ "name": "report.md", "path": "/artifacts/thread-tiirv9-irwdoal8t4rm/report.md" }] |
|
object |
A single artifact. |
{ "name": "report.md", "path": "/artifacts/thread-tiirv9-irwdoal8t4rm/report.md" } |
|
|
any |
The details of artifacts. Common fields include name (the artifact name) and path (the artifact path). You can call operations such as ListArtifacts and GetArtifact to retrieve the generated files. |
report.md |
|
| callId |
string |
The call ID of the current execution. Messages that use this value as parentCallId are its child messages. This field can be used to reconstruct the execution hierarchy of the agent. |
call_0fdabe9ba7c645a7a6cbf34f |
| contents |
array<object> |
The list of contents in the current message. |
[{ "type": "text", "value": "The URL with the highest number of requests in the last 1 hour is /api/v1/users, with a total of 12,580 requests.", "append": true, "lastChunk": true }] |
|
object |
A single content block. |
{ "type": "text", "value": "The URL with the highest number of requests in the last 1 hour is /api/v1/users, with a total of 12,580 requests.", "append": true, "lastChunk": true } |
|
|
any |
The details of the content. Common fields include type and value. When type is text, value is the reply text snippet. When type is spin_text, value is the prompt for the agent's thinking and execution process. When type is thread_title_updated, value is the updated conversation title. When type is error, value is the error message containing the code and message. During streaming output, the append (whether it is an incremental snippet) and lastChunk (whether it is the last chunk) markers are also included. |
text |
|
| detail |
string |
The supplementary description of the current message, such as the description of the action currently being executed. |
Analyzing query conditions |
| events |
array<object> |
The list of events carried in the current message, which indicates changes in the session status. Common type values: thinking (the agent is thinking), interactive (additional input or confirmation is required from you), task_finished (the current node is completed, and the payload contains success status and statistics information), stream_done (the current streaming output is completed), error (an execute error occurred), and thread_title_updated (the session title is updated). |
[{ "type": "thinking", "payload": { "message": "Analyzing the user's query intent..." } }] |
|
object |
A single event. |
{ "type": "thinking", "payload": { "message": "Analyzing the user's query intent..." } } |
|
|
any |
The details of events. Common fields include type (the event type) and payload (the event data, whose structure varies depending on the event type). |
task_finished |
|
| parentCallId |
string |
The ID of the parent call, which is used to reconstruct the execution hierarchy. An empty string indicates the root node of the current thread. |
thread-tiirv9-irwdoal8t4rm |
| role |
string |
The sender of the message. Valid values: assistant (a reply or action from the agent), tool (the result of a tool execution), user (user input), and system (a system message). |
assistant |
| seq |
integer |
The sequence number of the message. This number increments within the same thread and can be used to sort messages at the same level. We recommend that you also refer to timestamp and do not rely solely on this value. |
1 |
| timestamp |
string |
The time when the message was generated. The value is a UNIX timestamp in string format. |
1765289000 |
| tools |
array<object> |
The list of tool invocations initiated by the agent in the current message. This field may appear only when role is assistant. |
[{ "name": "get_current_time", "arguments": {}, "status": "success", "state": "success", "contents": [{ "type": "text", "value": "2026-11-13 17:38:01 (Asia/Shanghai)" }] }] |
|
object |
A single tool invocation. |
{ "name": "get_current_time", "arguments": {}, "status": "success", "state": "success", "contents": [{ "type": "text", "value": "2026-11-13 17:38:01 (Asia/Shanghai)" }] } |
|
|
any |
The details of tool calling. Common fields include name (the tool name), arguments (the input parameters to invoke the tool), status (the execute stage status: start, success, or fail), state (the execute result: success or fail), and contents (the tool output content). |
get_current_time |
|
| type |
string |
The message type. Regular reply messages may not have this field. This field appears when the entire message is used to express a status. For example, done indicates that the thread is ended, and error indicates an error message. |
done |
| version |
string |
The version number of the message structure. Current value: v0.1.0. |
v0.1.0 |
| requestId |
string |
The request ID that generated the current conversation turn. This ID can be used to associate the turn with the CreateChat call that initiated it. |
5B0A6B60BB6EE39764D458B5 |
| traceId |
string |
The Tracing Analysis ID of the current conversation turn. This ID is used to locate the invoke during troubleshooting. |
88b50db22437400fa9c16c5399722310 |
| maxResults |
integer |
The actual number of items per page that takes effect for the current request. |
20 |
| nextToken |
string |
The cursor for the next page. If this field is not returned, it indicates that the last page is reached. Pass this value as nextToken in the request to retrieve the next page. |
e81493d42a7d212810e0ac**** |
| requestId |
string |
The ID of the current request. This ID is used to locate the call during troubleshooting. |
5B0A6B60BB6EE39764D458B5 |
| threadId |
string |
The session ID of the current query. The value is the same as the threadId passed in the request path. |
thread-tiirv9-irwdoal8t4rm |
The following example shows the structure of the data for a single conversation turn:
{
"requestId": "1B2E6A9D-8C4F-4E2A-9E7D-3F5A6B7C8D9E",
"threadId": "thread-tiirv9-irwdoal8t4rm",
"maxResults": 20,
"nextToken": "e81493d42a7d212810e0ac****",
"data": [
{
"requestId": "2C3F7B0E-9D5A-4F3B-8E1C-4A6B7C8D9E0F",
"traceId": "88b50db22437400fa9c16c5399722310",
"messages": [
{
"role": "assistant",
"callId": "thread-tiirv9-irwdoal8t4rm",
"parentCallId": "",
"seq": 4,
"timestamp": "1765289004",
"version": "v0.1.0",
"contents": [
{ "type": "text", "value": "The URL with the highest number of requests in the last 1 hour is...", "append": true, "lastChunk": true }
]
}
]
}
]
}
Examples
Success response
JSON format
{
"data": [
{
"messages": [
{
"agents": [
{
"key": "search_data"
}
],
"artifacts": [
{
"key": "report.md"
}
],
"callId": "call_0fdabe9ba7c645a7a6cbf34f",
"contents": [
{
"key": "text"
}
],
"detail": "Analyzing query conditions",
"events": [
{
"key": "task_finished"
}
],
"parentCallId": "thread-tiirv9-irwdoal8t4rm",
"role": "assistant",
"seq": 1,
"timestamp": "1765289000",
"tools": [
{
"key": "get_current_time"
}
],
"type": "done",
"version": "v0.1.0"
}
],
"requestId": "5B0A6B60BB6EE39764D458B5",
"traceId": "88b50db22437400fa9c16c5399722310"
}
],
"maxResults": 20,
"nextToken": "e81493d42a7d212810e0ac****",
"requestId": "5B0A6B60BB6EE39764D458B5",
"threadId": "thread-tiirv9-irwdoal8t4rm"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.