Send Events
api/beta/sessions/events/send
Nearest release: v2.1.245, published an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
api/beta/sessions/events/send Changed · +155 / -170 lines
# Send Events ## Path parameters ## Headers ## Body parameters ## Returns ## Example ### Response (200) ## Send Events ### Path Parameters ### Header Parameters ### Body Parameters ### Returns ### Example #### Response
---- -title: Send Events -url: https://platform.claude.com/docs/en/api/beta/sessions/events/send ---- +# Send Events -## Send Events +**POST** `/v1/sessions/{session_id}/events` -**post** `/v1/sessions/{session_id}/events` - Send Events -### Path Parameters +## Path parameters - `session_id: string` -### Header Parameters +## Headers - `"anthropic-beta": optional array of AnthropicBeta`
- `"mid-conversation-tool-changes-2026-07-01"` -### Body Parameters +## Body parameters - `events: array of BetaManagedAgentsEventParams` Events to send to the `session`. - - `BetaManagedAgentsUserMessageEventParams object { content, type }` + - `BetaManagedAgentsUserMessageEventParams object` Parameters for sending a user message to the session.
Array of content blocks for the user message. - - `BetaManagedAgentsTextBlock object { text, type }` + - `BetaManagedAgentsTextBlock object` Regular text content.
The text content. + minLength: 1 + - `type: "text"` - - `"text"` + - `BetaManagedAgentsImageBlock object` - - `BetaManagedAgentsImageBlock object { source, type }` - Image content specified directly as base64 data or as a reference via a URL. - `source: BetaManagedAgentsBase64ImageSource or BetaManagedAgentsURLImageSource or BetaManagedAgentsFileImageSource`
Union type for image source variants. - - `BetaManagedAgentsBase64ImageSource object { data, media_type, type }` + - `BetaManagedAgentsBase64ImageSource object` Base64-encoded image data.
Base64-encoded image data. + minLength: 1 + - `media_type: string` MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp"). + minLength: 1 + - `type: "base64"` - - `"base64"` + - `BetaManagedAgentsURLImageSource object` - - `BetaManagedAgentsURLImageSource object { type, url }` - Image referenced by URL. - `type: "url"` - - `"url"` - - `url: string` URL of the image to fetch. - - `BetaManagedAgentsFileImageSource object { file_id, type }` + minLength: 1 + - `BetaManagedAgentsFileImageSource object` + Image referenced by file ID. - `file_id: string`
ID of a previously uploaded file. + minLength: 1 + - `type: "file"` - - `"file"` - - `type: "image"` - - `"image"` + - `BetaManagedAgentsDocumentBlock object` - - `BetaManagedAgentsDocumentBlock object { source, type, context, title }` - Document content, either specified directly as base64 data, as text, or as a reference via a URL. - `source: BetaManagedAgentsBase64DocumentSource or BetaManagedAgentsPlainTextDocumentSource or BetaManagedAgentsURLDocumentSource or BetaManagedAgentsFileDocumentSource`
Union type for document source variants. - - `BetaManagedAgentsBase64DocumentSource object { data, media_type, type }` + - `BetaManagedAgentsBase64DocumentSource object` Base64-encoded document data.
Base64-encoded document data. + minLength: 1 + - `media_type: string` MIME type of the document (e.g., "application/pdf"). + minLength: 1 + - `type: "base64"` - - `"base64"` + - `BetaManagedAgentsPlainTextDocumentSource object` - - `BetaManagedAgentsPlainTextDocumentSource object { data, media_type, type }` - Plain text document content. - `data: string`
The plain text content. + minLength: 1 + - `media_type: "text/plain"` MIME type of the text content. Must be "text/plain". - - `"text/plain"` - - `type: "text"` - - `"text"` + - `BetaManagedAgentsURLDocumentSource object` - - `BetaManagedAgentsURLDocumentSource object { type, url }` - Document referenced by URL. - `type: "url"` - - `"url"` - - `url: string` URL of the document to fetch. - - `BetaManagedAgentsFileDocumentSource object { file_id, type }` + minLength: 1 + - `BetaManagedAgentsFileDocumentSource object` + Document referenced by file ID. - `file_id: string`
ID of a previously uploaded file. + minLength: 1 + - `type: "file"` - - `"file"` - - `type: "document"` - - `"document"` - - `context: optional string or null` Additional context about the document for the model.
The title of the document. - - `BetaManagedAgentsRedactedBlock object { type }` + - `BetaManagedAgentsRedactedBlock object` Placeholder for content withheld by Anthropic model policy. - `type: "redacted"` - - `"redacted"` - - `type: "user.message"` - - `"user.message"` + - `BetaManagedAgentsUserInterruptEventParams object` - - `BetaManagedAgentsUserInterruptEventParams object { type, session_thread_id }` - Parameters for sending an interrupt to pause the agent. - `type: "user.interrupt"` - - `"user.interrupt"` - - `session_thread_id: optional string or null` If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. - - `BetaManagedAgentsUserToolConfirmationEventParams object { result, tool_use_id, type, deny_message }` + - `BetaManagedAgentsUserToolConfirmationEventParams object` Parameters for confirming or denying a tool execution request.
The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field. + minLength: 1, maxLength: 128 + - `type: "user.tool_confirmation"` - - `"user.tool_confirmation"` - - `deny_message: optional string or null` Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'. - - `BetaManagedAgentsUserCustomToolResultEventParams object { custom_tool_use_id, type, content, is_error }` + maxLength: 10000 + - `BetaManagedAgentsUserCustomToolResultEventParams object` + Parameters for providing the result of a custom tool execution. - `custom_tool_use_id: string`
The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field. + minLength: 1, maxLength: 128 + - `type: "user.custom_tool_result"` - - `"user.custom_tool_result"` - - `content: optional array of BetaManagedAgentsTextBlock or BetaManagedAgentsImageBlock or BetaManagedAgentsDocumentBlock or BetaManagedAgentsSearchResultBlock` The result content returned by the tool. - - `BetaManagedAgentsTextBlock object { text, type }` + - `BetaManagedAgentsTextBlock object` Regular text content. - - `BetaManagedAgentsImageBlock object { source, type }` + - `BetaManagedAgentsImageBlock object` Image content specified directly as base64 data or as a reference via a URL. - - `BetaManagedAgentsDocumentBlock object { source, type, context, title }` + - `BetaManagedAgentsDocumentBlock object` Document content, either specified directly as base64 data, as text, or as a reference via a URL. - - `BetaManagedAgentsSearchResultBlock object { citations, content, source, 2 more }` + - `BetaManagedAgentsSearchResultBlock object` A block containing a web search result.
The text content. + minLength: 1 + - `type: "text"` - - `"text"` - - `source: string` The URL source of the search result. + minLength: 1 + - `title: string` The title of the search result. + minLength: 1 + - `type: "search_result"` - - `"search_result"` - - `is_error: optional boolean or null` Whether the tool execution resulted in an error. - - `BetaManagedAgentsUserDefineOutcomeEventParams object { description, rubric, type, max_iterations }` + - `BetaManagedAgentsUserDefineOutcomeEventParams object` Parameters for defining an outcome the agent should work toward. The agent begins work on receipt.
Rubric for grading the quality of an outcome. - - `BetaManagedAgentsFileRubricParams object { file_id, type }` + - `BetaManagedAgentsFileRubricParams object` Rubric referenced by a file uploaded via the Files API.
- `type: "file"` - - `"file"` + - `BetaManagedAgentsTextRubricParams object` - - `BetaManagedAgentsTextRubricParams object { content, type }` - Rubric content provided inline as text. - `content: string`
Rubric content. Plain text or markdown — the grader treats it as freeform text. Maximum 262144 characters. + maxLength: 262144 + - `type: "text"` - - `"text"` - - `type: "user.define_outcome"` - - `"user.define_outcome"` - - `max_iterations: optional number or null` Eval→revision cycles before giving up. Default 3, max 20. - - `BetaManagedAgentsUserToolResultEventParams object { tool_use_id, type, content, is_error }` + format: int32 + - `BetaManagedAgentsUserToolResultEventParams object` + Parameters for providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server. - `tool_use_id: string`
The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field. + minLength: 1, maxLength: 128 + - `type: "user.tool_result"` - - `"user.tool_result"` - - `content: optional array of BetaManagedAgentsTextBlock or BetaManagedAgentsImageBlock or BetaManagedAgentsDocumentBlock or BetaManagedAgentsSearchResultBlock` The result content returned by the tool. - - `BetaManagedAgentsTextBlock object { text, type }` + - `BetaManagedAgentsTextBlock object` Regular text content. - - `BetaManagedAgentsImageBlock object { source, type }` + - `BetaManagedAgentsImageBlock object` Image content specified directly as base64 data or as a reference via a URL. - - `BetaManagedAgentsDocumentBlock object { source, type, context, title }` + - `BetaManagedAgentsDocumentBlock object` Document content, either specified directly as base64 data, as text, or as a reference via a URL. - - `BetaManagedAgentsSearchResultBlock object { citations, content, source, 2 more }` + - `BetaManagedAgentsSearchResultBlock object` A block containing a web search result.
Whether the tool execution resulted in an error. - - `BetaManagedAgentsSystemMessageEventParams object { content, type }` + - `BetaManagedAgentsSystemMessageEventParams object` Privileged context for the accompanying turn and all subsequent turns, appended to the session's system context as a `role: "system"` turn rather than replacing the top-level system prompt. At most one per request: it must be the final event and immediately follow the `user.message`, `user.tool_result`, or `user.custom_tool_result` it accompanies. Only supported on models that accept mid-conversation system messages.
The text content. + minLength: 1 + - `type: "text"` - - `"text"` - - `type: "system.message"` - - `"system.message"` +## Returns -### Returns +- `BetaManagedAgentsSendSessionEvents object` -- `BetaManagedAgentsSendSessionEvents object { data }` - Events that were successfully sent to the session. - `data: optional array of BetaManagedAgentsUserMessageEvent or BetaManagedAgentsUserInterruptEvent or BetaManagedAgentsUserToolConfirmationEvent or 4 more`
Sent events - - `BetaManagedAgentsUserMessageEvent object { id, content, type, processed_at }` + - `BetaManagedAgentsUserMessageEvent object` A user message event in the session conversation.
Array of content blocks comprising the user message. - - `BetaManagedAgentsTextBlock object { text, type }` + - `BetaManagedAgentsTextBlock object` Regular text content.
The text content. + minLength: 1 + - `type: "text"` - - `"text"` + - `BetaManagedAgentsImageBlock object` - - `BetaManagedAgentsImageBlock object { source, type }` - Image content specified directly as base64 data or as a reference via a URL. - `source: BetaManagedAgentsBase64ImageSource or BetaManagedAgentsURLImageSource or BetaManagedAgentsFileImageSource`
Union type for image source variants. - - `BetaManagedAgentsBase64ImageSource object { data, media_type, type }` + - `BetaManagedAgentsBase64ImageSource object` Base64-encoded image data.
Base64-encoded image data. + minLength: 1 + - `media_type: string` MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp"). + minLength: 1 + - `type: "base64"` - - `"base64"` + - `BetaManagedAgentsURLImageSource object` - - `BetaManagedAgentsURLImageSource object { type, url }` - Image referenced by URL. - `type: "url"` - - `"url"` - - `url: string` URL of the image to fetch. - - `BetaManagedAgentsFileImageSource object { file_id, type }` + minLength: 1 + - `BetaManagedAgentsFileImageSource object` + Image referenced by file ID. - `file_id: string`
ID of a previously uploaded file. + minLength: 1 + - `type: "file"` - - `"file"` - - `type: "image"` - - `"image"` + - `BetaManagedAgentsDocumentBlock object` - - `BetaManagedAgentsDocumentBlock object { source, type, context, title }` - Document content, either specified directly as base64 data, as text, or as a reference via a URL. - `source: BetaManagedAgentsBase64DocumentSource or BetaManagedAgentsPlainTextDocumentSource or BetaManagedAgentsURLDocumentSource or BetaManagedAgentsFileDocumentSource`
Union type for document source variants. - - `BetaManagedAgentsBase64DocumentSource object { data, media_type, type }` + - `BetaManagedAgentsBase64DocumentSource object` Base64-encoded document data.
Base64-encoded document data. + minLength: 1 + - `media_type: string` MIME type of the document (e.g., "application/pdf"). + minLength: 1 + - `type: "base64"` - - `"base64"` + - `BetaManagedAgentsPlainTextDocumentSource object` - - `BetaManagedAgentsPlainTextDocumentSource object { data, media_type, type }` - Plain text document content. - `data: string`
The plain text content. + minLength: 1 + - `media_type: "text/plain"` MIME type of the text content. Must be "text/plain". - - `"text/plain"` - - `type: "text"` - - `"text"` + - `BetaManagedAgentsURLDocumentSource object` - - `BetaManagedAgentsURLDocumentSource object { type, url }` - Document referenced by URL. - `type: "url"` - - `"url"` - - `url: string` URL of the document to fetch. - - `BetaManagedAgentsFileDocumentSource object { file_id, type }` + minLength: 1 + - `BetaManagedAgentsFileDocumentSource object` + Document referenced by file ID. - `file_id: string`
ID of a previously uploaded file. + minLength: 1 + - `type: "file"` - - `"file"` - - `type: "document"` - - `"document"` - - `context: optional string or null` Additional context about the document for the model.
The title of the document. - - `BetaManagedAgentsRedactedBlock object { type }` + - `BetaManagedAgentsRedactedBlock object` Placeholder for content withheld by Anthropic model policy. - `type: "redacted"` - - `"redacted"` - - `type: "user.message"` - - `"user.message"` - - `processed_at: optional string or null` A timestamp in RFC 3339 format - - `BetaManagedAgentsUserInterruptEvent object { id, type, processed_at, session_thread_id }` + format: date-time + - `BetaManagedAgentsUserInterruptEvent object` + An interrupt event that pauses agent execution and returns control to the user. - `id: string`
- `type: "user.interrupt"` - - `"user.interrupt"` - - `processed_at: optional string or null` A timestamp in RFC 3339 format + format: date-time + - `session_thread_id: optional string or null` If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. - - `BetaManagedAgentsUserToolConfirmationEvent object { id, result, tool_use_id, 4 more }` + - `BetaManagedAgentsUserToolConfirmationEvent object` A tool confirmation event that approves or denies a pending tool execution.
- `type: "user.tool_confirmation"` - - `"user.tool_confirmation"` - - `deny_message: optional string or null` Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'. + maxLength: 10000 + - `processed_at: optional string or null` A timestamp in RFC 3339 format + format: date-time + - `session_thread_id: optional string or null` When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval. - - `BetaManagedAgentsUserCustomToolResultEvent object { id, custom_tool_use_id, type, 4 more }` + - `BetaManagedAgentsUserCustomToolResultEvent object` Event sent by the client providing the result of a custom tool execution.
- `type: "user.custom_tool_result"` - - `"user.custom_tool_result"` - - `content: optional array of BetaManagedAgentsTextBlock or BetaManagedAgentsImageBlock or BetaManagedAgentsDocumentBlock or BetaManagedAgentsSearchResultBlock` The result content returned by the tool. - - `BetaManagedAgentsTextBlock object { text, type }` + - `BetaManagedAgentsTextBlock object` Regular text content. - - `BetaManagedAgentsImageBlock object { source, type }` + - `BetaManagedAgentsImageBlock object` Image content specified directly as base64 data or as a reference via a URL. - - `BetaManagedAgentsDocumentBlock object { source, type, context, title }` + - `BetaManagedAgentsDocumentBlock object` Document content, either specified directly as base64 data, as text, or as a reference via a URL. - - `BetaManagedAgentsSearchResultBlock object { citations, content, source, 2 more }` + - `BetaManagedAgentsSearchResultBlock object` A block containing a web search result.
The text content. + minLength: 1 + - `type: "text"` - - `"text"` - - `source: string` The URL source of the search result. + minLength: 1 + - `title: string` The title of the search result. + minLength: 1 + - `type: "search_result"` - - `"search_result"` - - `is_error: optional boolean or null` Whether the tool execution resulted in an error.
A timestamp in RFC 3339 format + format: date-time + - `session_thread_id: optional string or null` Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`. - - `BetaManagedAgentsUserDefineOutcomeEvent object { id, description, max_iterations, 4 more }` + - `BetaManagedAgentsUserDefineOutcomeEvent object` Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.
Evaluate-then-revise cycles before giving up. Default 3, max 20. + format: int32 + - `outcome_id: string` Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
A timestamp in RFC 3339 format + format: date-time + - `rubric: BetaManagedAgentsFileRubric or BetaManagedAgentsTextRubric` Rubric for grading the quality of an outcome. - - `BetaManagedAgentsFileRubric object { file_id, type }` + - `BetaManagedAgentsFileRubric object` Rubric referenced by a file uploaded via the Files API.
- `type: "file"` - - `"file"` + - `BetaManagedAgentsTextRubric object` - - `BetaManagedAgentsTextRubric object { content, type }` - Rubric content provided inline as text. - `content: string`
- `type: "text"` - - `"text"` - - `type: "user.define_outcome"` - - `"user.define_outcome"` + - `BetaManagedAgentsUserToolResultEvent object` - - `BetaManagedAgentsUserToolResultEvent object { id, tool_use_id, type, 4 more }` - Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server. - `id: string`
- `type: "user.tool_result"` - - `"user.tool_result"` - - `content: optional array of BetaManagedAgentsTextBlock or BetaManagedAgentsImageBlock or BetaManagedAgentsDocumentBlock or BetaManagedAgentsSearchResultBlock` The result content returned by the tool. - - `BetaManagedAgentsTextBlock object { text, type }` + - `BetaManagedAgentsTextBlock object` Regular text content. - - `BetaManagedAgentsImageBlock object { source, type }` + - `BetaManagedAgentsImageBlock object` Image content specified directly as base64 data or as a reference via a URL. - - `BetaManagedAgentsDocumentBlock object { source, type, context, title }` + - `BetaManagedAgentsDocumentBlock object` Document content, either specified directly as base64 data, as text, or as a reference via a URL. - - `BetaManagedAgentsSearchResultBlock object { citations, content, source, 2 more }` + - `BetaManagedAgentsSearchResultBlock object` A block containing a web search result.
A timestamp in RFC 3339 format + format: date-time + - `session_thread_id: optional string or null` Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`. - - `BetaManagedAgentsSystemMessageEvent object { id, content, type, processed_at }` + - `BetaManagedAgentsSystemMessageEvent object` A mid-conversation system message event. Carries system-role content that is appended to the session as a `role: "system"` turn.
The text content. + minLength: 1 + - `type: "text"` - - `"text"` - - `type: "system.message"` - - `"system.message"` - - `processed_at: optional string or null` A timestamp in RFC 3339 format -### Example + format: date-time -```http +## Example + +```bash curl https://api.anthropic.com/v1/sessions/$SESSION_ID/events \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \
}' ``` -#### Response +### Response (200) ```json {