Events
Everything that happens in a session is an event: your messages, the agent's replies and tool calls, and status changes. You send events to steer the session and read them from the history or a live stream. The events follow Anthropic's Managed Agents API, with the differences listed at the end of this page.
The event object
| Field | Type | Description |
|---|---|---|
id | string | The event's ID, in the form sevt_<seq>_<index>. |
type | string | One of the types below. |
processed_at | string | null | When the event was processed, as an RFC 3339 timestamp. It is null only on send receipts. |
Each type adds its own fields, listed in Event types.
IDs sort in the order the events happened. Compare them by their numbers, not as strings: sevt_10_0 comes after
sevt_9_0. To resume after an event, pass its ID as page on List events
or as the Last-Event-ID header on the stream.
When you send an event, the response holds a send receipt: an event object with an ID of the form
sevt_receipt_<uuid> and a null processed_at. The receipt's ID is not the ID of the stored event. The stored
event, with its real ID, then appears on the stream and in the history.
Example
Code
Event types
Types are named <source>.<action>. The session uses the 13 types below. More types might be added, so skip any type you do not recognize.
Events you send
| Type | Fields | Description |
|---|---|---|
user.message | content: text blocks | Starts a turn. If a turn is already running, the message joins it, and one session.status_idle ends the combined turn. The first user.message also starts the session. |
user.tool_confirmation | tool_use_id, result (allow or deny), deny_message | Answers a tool call that waits for approval. allow approves that one call, and deny refuses it. The stored event carries deny_message only for a deny. |
user.custom_tool_result | custom_tool_use_id, content: text blocks, is_error | Answers an agent.custom_tool_use. The first answer counts, yours or that of the paired computer that serves the tool; a later answer is accepted and changes nothing. The session shows the answer that counted as a user.custom_tool_result, whoever sent it. |
user.interrupt | none | Stops the current turn. The session emits session.status_idle with end_turn. |
Events the session emits
| Type | Fields | Description |
|---|---|---|
agent.thinking | none | The agent reasoned before replying. The event has no content and arrives with the reply, so it isn't a live indicator. |
agent.message | content: text blocks | The agent replied. |
agent.tool_use | name, input | The agent called a tool. |
agent.custom_tool_use | name, input | The agent called one of its custom tools. A session.status_idle with requires_action naming it follows, until its user.custom_tool_result arrives: from you, or from your paired computer whose servers advertise a tool of exactly that name, whichever answers first. The call waits up to 12 minutes. |
agent.tool_result | tool_use_id, content, is_error | A tool returned its result. |
session.status_running | none | A turn started. |
session.status_idle | stop_reason, stop_details | A turn ended. stop_reason.type is end_turn, requires_action (with event_ids, the agent.tool_use IDs waiting for your approval) or retries_exhausted. stop_details is always null. |
session.error | error.type, error.message, error.retry_status | A step of the turn failed. error.type is one of the types in Session errors. With retry_status.type: "retrying", the session retries and stays running. With "exhausted", the turn failed, and a session.status_idle with retries_exhausted follows. |
session.usage | usage: input_tokens, output_tokens, cache_read_input_tokens, cache_creation, active_seconds | Reports the session's running totals, subagents included. The session sends it after each model call and before every session.status_idle. This event doesn't include cost. To read cost, retrieve the session and read its usage.list_cost. |
Warning: When
stop_reason.typeisrequires_action, answer every ID inevent_ids. The session doesn't send a newsession.status_idlefor the IDs you haven't answered. It runs again only after you answer the last one.
Subagents that the agent starts do not emit events of their own. The one exception is a subagent tool call waiting for approval, which shows up as agent.tool_use and a session.status_idle with requires_action.
Session errors
error.type | Cause |
|---|---|
model_rate_limited_error | The model provider's rate limit, or your own usage limit, was reached. |
model_overloaded_error | The model provider is unavailable or overloaded. |
model_request_failed_error | The model call failed for another reason, for example a timeout, a network failure, a refused request or a context window overflow. |
billing_error | Credits, a spend limit or a budget ran out, or the agent has no billing seat in its workspace. |
unknown_error | Any other failure, including a step the platform retries on its own without a known cause. |
retry_status.type is retrying or exhausted. Any error.type can come with retrying: the platform retries on its own and the turn continues. With exhausted, the turn failed. Send a new user.message to start the next turn.
Differences from Anthropic's API
This API follows Anthropic's Managed Agents API, with these differences:
- Event deltas and session threads are not supported.
- Sending
user.tool_result,user.define_outcomeorsystem.messagereturns400. - A custom tool can also be answered by a computer you paired with the Context app, and a call nobody answers ends after 12 minutes with an error result.
- Send receipts have their own ID form. See The event object.
- The stream accepts a
Last-Event-IDheader to resume after an event. Anthropic's API does not. retry_status.typeis neverterminal, and MCP, credential and repository error types are not sent.
For every difference in one place, see Coming from Anthropic's API.
List 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.
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.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | limit is outside 1 to 1000. Send a value from 1 to 1000. |
| 400 | invalid_request_error | order is not asc or desc. Send one of them, or omit it. |
| 400 | invalid_request_error | page is not an event ID this API issued. Send the next_page value from the previous response, unchanged. |
| 400 | invalid_request_error | A created_at bound is not an RFC 3339 timestamp. Send a timestamp such as 2026-10-21T01:42:16Z. |
| 404 | not_found_error | No session with this ID exists, or this key can't read it. Check the session ID. |
| 503 | api_error | The session's history is still being indexed. Retry the request shortly. |
path Parameters
session_idThe ID of the session whose events to return.
The ID of the session whose events to return.
query Parameters
limitThe maximum number of events to return on one page. Must be between 1 and 1000.
The maximum number of events to return on one page. Must be between 1 and 1000.
pageThe 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.
The 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.
created_at[gt]Only events whose processed_at is after this RFC 3339 timestamp.
Only events whose processed_at is after this RFC 3339 timestamp.
created_at[gte]Only events whose processed_at is at or after this RFC 3339 timestamp.
Only events whose processed_at is at or after this RFC 3339 timestamp.
created_at[lt]Only events whose processed_at is before this RFC 3339 timestamp.
Only events whose processed_at is before this RFC 3339 timestamp.
created_at[lte]Only events whose processed_at is at or before this RFC 3339 timestamp.
Only events whose processed_at is at or before this RFC 3339 timestamp.
orderThe sort order. One of asc (oldest first) or desc (newest first).
The sort order. One of asc (oldest first) or desc (newest first).
typesThe event types to return. To pass more than one, repeat the parameter: types=agent.message&types=session.status_idle.
The event types to return. To pass more than one, repeat the parameter: types=agent.message&types=session.status_idle.
types[]The same filter as types, in the bracketed form the SDKs send: types[]=agent.message&types[]=session.status_idle.
The same filter as types, in the bracketed form the SDKs send: types[]=agent.message&types[]=session.status_idle.
Headers
anthropic-workspace-idThe ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns 404. Without it, a new session runs in the agent's workspace or the owner's private workspace: see Where a session runs.
The ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns 404. Without it, a new session runs in the agent's workspace or the owner's private workspace: see Where a session runs.
List events › Responses
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.
next_pageSend events
Sends a message, a tool approval or an interrupt to a session.
Sends are not idempotent. If a send times out or its result is unknown, read the session's events before you send it again.
The server checks every event against the session before any of them acts, then applies them in order. If an event is refused while they are applied, because the session changed in the meantime, the earlier events stay accepted and the error message says how many were. Don't resend those.
Each event gets a receipt with a sevt_receipt_ ID and processed_at: null. The stored event, with its real
ID, then appears on the stream and in the history. The receipt ID is not the stored event's ID, so match the
stored event on the stream rather than by ID.
Before a session starts, it accepts exactly one user.message per request. Send more only after the stream
shows session.status_running. A user.message sent while a turn runs is added to that turn instead of
starting a new one.
A user.tool_confirmation also needs the tasks:approve capability and a
personal key.
The key must have the tasks:create capability. For what each capability allows, see Keys.
Response
Returns 200 with a data array that holds one receipt for each event you sent.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | An event is malformed, or its text is empty or over 100,000 characters in all. Fix the event the message names. |
| 400 | invalid_request_error | The session is archived. Archived sessions take no events. Create a new session. |
| 400 | invalid_request_error | The session has not started and the request holds more than one user.message, or the first turn is still starting. Send one message, then wait for session.status_running before you send the next. |
| 400 | invalid_request_error | A tool_use_id is unknown, repeated or already answered. Send only IDs from the latest stop_reason.event_ids that you have not answered. |
| 400 | invalid_request_error | An event has a type this endpoint does not accept: user.tool_result, user.define_outcome or system.message. Send only user.message, user.tool_confirmation, user.custom_tool_result or user.interrupt. |
| 400 | invalid_request_error | A user.custom_tool_result names a custom_tool_use_id this session never showed. Send the ID of its agent.custom_tool_use event. |
| 400 | invalid_request_error | An event carries session_thread_id. Sessions have one thread. Remove session_thread_id and retry. |
| 400 | invalid_request_error | A user.tool_confirmation follows a user.interrupt in the same request. Send the confirmation before the interrupt, or in a separate request. |
| 403 | permission_error | The key does not act for the session's owner, or the owner is no longer an active member. Use the owner's personal key or the service account key that created the session. |
| 403 | permission_error | A user.tool_confirmation was sent with a key that is not personal, or that lacks tasks:approve. Use a personal key with tasks:approve. |
| 404 | not_found_error | No session with this ID exists, or this key can't read it. Check the session ID. |
| 409 | invalid_request_error | The session's state changed while the request was processed. The tool call was already answered, or the session is stopping or moving. Read the events, then decide whether to send again. |
| 503 | api_error | The session's history is still being indexed. Retry the request shortly. |
path Parameters
session_idThe ID of the session to send events to.
The ID of the session to send events to.
Headers
anthropic-workspace-idThe ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns 404. Without it, a new session runs in the agent's workspace or the owner's private workspace: see Where a session runs.
The ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns 404. Without it, a new session runs in the agent's workspace or the owner's private workspace: see Where a session runs.
Send events › Request Body
The events to send, applied in order.
Send events › Responses
Returns 200 with a data array that holds one receipt for each event you sent.
Stream events
Streams a session's events as server-sent events while they happen.
Without Last-Event-ID, the stream sends only events that happen after it opens, so open it before you send a
message.
Each key can hold up to 24 open streams across all its sessions, unless your deployment sets a different limit. The limit applies on each server instance, so a key whose streams land on more than one instance can hold more in total. A stream counts until your client disconnects.
This endpoint takes no query parameters. Anthropic's event_deltas parameter isn't supported, and sending it
returns 400.
The key must have the tasks:read capability. For what each capability allows, see Keys.
Response
Returns 200 with the content type text/event-stream. Each event is one frame, described in Frames. The : open line is a comment, sent once when the stream opens, and SSE clients ignore it.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | Last-Event-ID is not an event ID of this session. Send an ID from this session's events, or omit the header. |
| 400 | invalid_request_error | The request includes the event_deltas query parameter. Remove it. |
| 404 | not_found_error | No session with this ID exists, or this key can't read it. Check the session ID. |
| 429 | rate_limit_error | This key already holds the most open streams allowed on the server instance that answered, 24 by default. Close a stream you no longer read, then retry. |
Frames
Each event is one frame with id, event and data, and the frame's id is the event ID. Events arrive
whole, without deltas, and agent.message carries the full reply. Every 20 seconds the server sends a ping
frame with no id.
Event order in a turn
Stop reading when a session.status_idle arrives whose stop_reason.type is anything other than
requires_action. A session.status_idle with requires_action means the agent is waiting for you. A
session.error with retry_status.type: "retrying" doesn't end the turn, so keep reading. A session.error
with retry_status.type: "exhausted" is followed by a session.status_idle with retries_exhausted.
A turn in which the agent asks to run a tool looks like this:
- The stream shows
user.message, thensession.status_running. - The stream shows
agent.tool_usefor the call, thensession.status_idlewithstop_reason.type: "requires_action"and the call's ID inevent_ids. - To answer, send a
user.tool_confirmationevent with Send events for each call. The stream shows it, thensession.status_runningonce every waiting call is answered. Until you answer every ID inevent_ids, the session keeps waiting and the stream sends no further status event. - The stream shows
agent.tool_result, thenagent.thinkingif the agent reasoned, thenagent.message. Asession.usageevent follows each model call. - The stream shows
session.usage, thensession.status_idlewithstop_reason.type: "end_turn". The turn is over.
How a stream ends
The server doesn't close the stream when a turn ends. Close it yourself when you stop reading, because an open stream counts against the key's limit.
A stream can end with an event: error frame, without an id, whose data is an error body. The server
sends nothing after it, so close the connection yourself.
error.type | Why | What to do |
|---|---|---|
api_error | The connection has carried 8 MiB. | Reconnect with Last-Event-ID. |
invalid_request_error | The session was archived. | Stop. The history stays readable. |
authentication_error | The key was revoked or expired, or its owner left the organization. | Stop. To keep reading, open a new stream with a valid key. |
permission_error, not_found_error | The key lost access to the session. | Stop. To keep reading, open a new stream with a key that can read the session. |
A stream can also close with no frame, for example when the server restarts. The SDKs do not reconnect for you.
Reconnecting
To resume a stream without missing events, follow these steps:
- Keep the
idof the last event you received. - Reopen the stream with a
Last-Event-IDheader set to that ID. The server replays every event after it, then continues live.
If you have not received any event yet, send sevt_0_0 to replay the whole history. To read the history first,
list it with List events and stream from the last listed ID. You
can also open the stream first, then list the history and skip any event IDs the stream has already delivered.
path Parameters
session_idThe ID of the session to stream.
The ID of the session to stream.
Headers
Last-Event-IDThe ID of the last event you received from this session. The stream replays every event after it, then continues live. sevt_0_0 replays from the start. A send receipt's ID (sevt_receipt_<uuid>, returned when you send an event) returns 400.
The ID of the last event you received from this session. The stream replays every event after it, then continues live. sevt_0_0 replays from the start. A send receipt's ID (sevt_receipt_<uuid>, returned when you send an event) returns 400.
anthropic-workspace-idThe ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns 404. Without it, a new session runs in the agent's workspace or the owner's private workspace: see Where a session runs.
The ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns 404. Without it, a new session runs in the agent's workspace or the owner's private workspace: see Where a session runs.
Stream events › Responses
Returns 200 with the content type text/event-stream. Each event is one frame, described in Frames. The : open line is a comment, sent once when the stream opens, and SSE clients ignore it.
Decision Table
| Variant | Matching Criteria |
|---|---|
| No specific criteria | |
| type = object · requires: type | |
| type = object · requires: type, error, request_id |
Decision Table
| Variant | Matching Criteria |
|---|---|
| type = object · requires: id, processed_at, type +1 more | |
| type = object · requires: id, processed_at, type | |
| type = object · requires: id, processed_at, type +2 more | |
| type = object · requires: id, processed_at, type +1 more | |
| type = object · requires: id, processed_at, type | |
| type = object · requires: id, processed_at, type +2 more | |
| type = object · requires: id, processed_at, type +2 more | |
| type = object · requires: id, processed_at, type +3 more | |
| type = object · requires: id, processed_at, type +3 more | |
| type = object · requires: id, processed_at, type | |
| type = object · requires: id, processed_at, type +2 more | |
| type = object · requires: id, processed_at, type +1 more | |
| type = object · requires: id, processed_at, type +1 more |
id^sevt_(0|[1-9][0-9]*… · requiredprocessed_attype