Skip to content

List events

GET /v1/sessions/{session_id}/events

Returns a session’s event history, oldest first by default.

The key must have the tasks:read capability. For what each capability allows, see Keys.

Path parameters

NameTypeRequiredDefaultDescription
session_idstringYesThe ID of the session whose events to return.

Query parameters

NameTypeRequiredDefaultDescription
limitintegerNo100The maximum number of events to return on one page. Must be between 1 and 1000.
orderstringNoascThe sort order. One of asc (oldest first) or desc (newest first).
pagestringNoThe ID of the event to start from. To fetch the next page, pass the next_page value from the previous response. With asc, the page starts with the first event after this one. With desc, it starts with the first event before it. The event itself is not included.
typesarray<string>NoThe event types to return. To pass more than one, repeat the parameter: types[]=agent.message&types[]=session.status_idle.
created_at[gte]stringNoThe earliest processed_at time to include, as an RFC 3339 timestamp. created_at[gt] (after), created_at[lt] (before) and created_at[lte] (at or before) filter the same field.

Response

Returns 200 with a page of events in data, in the order order sets, and a next_page value to pass as page. next_page is null when no more events match.

{
"data": [
{
"type": "user.message",
"id": "sevt_1_0",
"processed_at": "2026-10-21T01:42:16.357Z",
"content": [
{
"type": "text",
"text": "Run this bash command and tell me the output: echo first"
}
]
},
{
"type": "session.status_running",
"id": "sevt_1_1",
"processed_at": "2026-10-21T01:42:16.357Z"
},
{
"type": "agent.tool_use",
"id": "sevt_29_0",
"processed_at": "2026-10-21T01:42:21.908Z",
"name": "bash",
"input": {
"command": "echo first"
}
}
],
"next_page": null
}

Errors

This endpoint can return these errors as well as the common errors.

Statuserror.typeCause and fix
400invalid_request_errorlimit is outside 1 to 1000. Send a value from 1 to 1000.
400invalid_request_errororder is not asc or desc. Send one of them, or omit it.
400invalid_request_errorpage is not an event ID this API issued. Send the next_page value from the previous response, unchanged.
400invalid_request_errorA created_at bound is not an RFC 3339 timestamp. Send a timestamp such as 2026-10-21T01:42:16Z.
404not_found_errorNo session with this ID exists, or this key can’t read it. Check the session ID.
503api_errorThe session’s history is still being indexed. Retry the request shortly.

Example

cURL
curl -sS "$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/events?limit=100" -H "x-api-key: $CONTEXT_API_KEY"
Python
for event in client.beta.sessions.events.list("dd13d728-93e3-440a-874c-4efeb58c97e0", limit=100): # auto-paginates
print(event.id, event.type)
TypeScript
for await (const event of client.beta.sessions.events.list("dd13d728-93e3-440a-874c-4efeb58c97e0", { limit: 100 })) console.log(event.id, event.type)