List Events

Updated at:

Queries session event history with pagination. The returned structure matches the SSE frame data. Supports filtering by event type, time window, and sorting.

Prerequisites

A session must already be created. For details, see Create Session. {session_id} is in the format sesn_xxx....

Endpoint

GET /sessions/{session_id}/events

The returned structure matches the SSE frame data. For details on event envelope fields, see the Event envelope section in Subscribe to Event SSE Stream.

Query parameters

ParameterRequiredTypeDefaultDescription
typesNostringFilter by event type; can be repeated. Example: ?types=message&types=tool_approval_request. When recovering approval cards after a disconnect/refresh, use types=tool_approval_request to re-fetch the current batch's approval requests, then match by (batch_id, call_id). Use types=error to re-fetch runtime errors (such as pending_tool_approval_unresolved, invalid_tool_approval); error details are in the top-level error object (error.code / error.message), not in content[].data
orderNostringascSort direction: asc (ascending) | desc (descending)
created_at[gt] / [gte] / [lt] / [lte]NostringFilter by time window, ISO 8601; the four comparison operators can be combined
limitNoint20Number of items per page, maximum 100
pageNostringOmit on the first request; pass next_page from the previous response for subsequent requests

Request example

curl "$AGENTSTUDIO_URL/sessions/sesn_xxx/events?order=asc&limit=100" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"
for event in client.sessions.events.list(
    "sesn_xxx",
    limit=100,
    order="asc",
):
    print(event.type, event.created_at)
CursorPage<SessionEvent> events = client.sessions().events().list("sesn_xxx",
    SessionEventListParam.builder()
        .limit(100)
        .order("asc")
        .build());
for (SessionEvent ev : events.getData()) {
    System.out.println("[" + ev.getType() + "] " + ev.getCreatedAt());
}

Response

Returns data (an array of event Message objects with the same structure as the SSE frame data field; for details, see Subscribe to Event SSE Stream), next_page (cursor for the next page; not returned or null when there is no more data), and request_id. Message object fields are as follows:

Response fields

FieldTypeDescription
dataarray<object>Array of event Message objects, sorted by order
data[].objectstringAlways message
data[].idstringEvent ID, prefix msg_ or out_
data[].created_atstringEvent timestamp, ISO 8601
data[].statusstringAlways completed
data[].rolestringuser | assistant | tool
data[].typestringEvent type, same values as SSE server push events (excludes error, which is a separate branch). For details, see Subscribe to Event SSE Stream
data[].contentarray<object>ContentBlock array, same structure as the send side
data[].is_errorboolOnly on tool output events (tool_call_output / mcp_call_output), at the Message top level (not inside content[].data): true means the tool execution failed or was interrupted/rejected; data is still a ToolCallOutput / McpCallOutput containing at least call_id and output
data[].metadataobjectEvent additional information (such as thread_id, call_id, etc.)
data[].errorobjectOnly on type=error events: runtime error details at the Message top level (not inside content[].data), with required code and message
next_pagestring | nullCursor for the next page; not returned or null when there is no more data
request_idstringUnique identifier for this request