The stream carries a sequence of JSON events covering turn-run state changes, incremental text/token chunks, and tool calls made by the agent as it works.
const response = await fetch( `https://suite.sundaypyjamas.com/api/v1/managed-agents/sessions/${sessionId}/messages`, { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ message: 'What did you find in the report?' }), });const reader = response.body.getReader();const decoder = new TextDecoder();while (true) { const { done, value } = await reader.read(); if (done) break; console.log(decoder.decode(value));}
Returns 400 with "message is required" if message is missing. Returns 429 if the workspace has hit its managed-agent rate limit.
Get Session Timeline
GET /api/v1/managed-agents/sessions/{sessionId}/events
Returns the full ordered history of a session — messages and turn runs interleaved, sorted ascending by created_at.
(MessageEvent | TurnRunEvent)[]
Show MessageEvent
string
"message"
string
string
user · assistant · tool
string
object
string
Show TurnRunEvent
string
"turn_run"
string
string
string
string | null
string | null
Submit Tool Results
POST /api/v1/managed-agents/sessions/{sessionId}/tool-results
When an agent needs to call a tool your integration owns, it pauses and emits a pending tool call in the event stream. Execute the tool on your side, then report the result back here so the agent can continue.
string
required
The ID of the pending tool call, taken from the event stream.
any
The tool’s return value. Provide this on success.
string
Error message if the tool failed. Provide either result or error, not both.
Returns 403 with "toolCallId does not belong to session" if the tool call belongs to a different session, and 404 with "Unknown toolCallId" if it doesn’t exist.
Cancel Run
POST /api/v1/managed-agents/sessions/{sessionId}/cancel
Returns 400 with "Run is {current_status}" if the run isn’t currently running (e.g. already completed).
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"SundayPyjamas AI Suite","colors":{"primary":"#52525B","light":"#A1A1AA","dark":"#27272A"},"logo":{"light":"https://mintcdn.com/sundaypyjamas/mPtTCdYgcCjb2V3-/logo/dark.svg?fit=max\u0026auto=format\u0026n=mPtTCdYgcCjb2V3-\u0026q=85\u0026s=e5e3e1e59634cc40750fcd055681aa89","dark":"https://mintcdn.com/sundaypyjamas/mPtTCdYgcCjb2V3-/logo/light.svg?fit=max\u0026auto=format\u0026n=mPtTCdYgcCjb2V3-\u0026q=85\u0026s=b9d1555ea0161f6a3430f051ece1ad65","href":"https://suite.sundaypyjamas.com"},"favicon":"https://mintcdn.com/sundaypyjamas/cBD4NursMvkHwenF/favicon.ico?fit=max\u0026auto=format\u0026n=cBD4NursMvkHwenF\u0026q=85\u0026s=5434345933ef2101b5a73c0c78e619f4","background":{"decoration":"gradient"},"navbar":{"links":[],"primary":{"type":"button","label":"Get API Key","href":"https://suite.sundaypyjamas.com"}},"footer":{"socials":{"github":"https://github.com/sundaypyjamas"}},"fonts":{"heading":{"family":"Inter"},"body":{"family":"Inter"}},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"API Platform","icon":"gauge-high","href":"https://suite.sundaypyjamas.com"},{"anchor":"GitHub","icon":"github","href":"https://github.com/sundaypyjamas"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"sundaypyjamas","hasAudioNarration":false,"actualSubdomain":"sundaypyjamas","customDomains":["docs.sundaypyjamas.com"],"gitSource":{"type":"github","owner":"sundaypyjamas","repo":"ai-suite-platform-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae92b3fc650774b1d01b165:success","clientVersion":"0.0.4304","searchFilterCounts":[{"language":"default","tag":"API Reference","count":31},{"language":"default","tag":"User Guide","count":26},{"language":"default","tag":"Documentation","count":11},{"language":"default","tag":"Work with Agents","count":6},{"language":"default","tag":"Manage \u0026 Get Help","count":6},{"language":"default","tag":"Agents","count":5},{"language":"default","tag":"More Ways to Work","count":5},{"language":"default","tag":"Useful Skills","count":5},{"language":"default","tag":"Apps","count":4},{"language":"default","tag":"Storage","count":4}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#navbar{z-index:30}.dark #navbar,.dark #navbar-transition{background-color:#0a0a0a!important;opacity:1!important}html:not(.dark) #navbar,html:not(.dark) #navbar-transition{background-color:#ffffff!important;opacity:1!important}#sidebar-content .pointer-events-none.sticky{display:none!important}#navigation-items{padding-top:0.5rem}"}]}
{"page":{"pagePath":"api-reference/agents/messaging","slug":"/api-reference/agents/messaging","pageMetadata":{"title":"Messaging \u0026 Events","description":"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs","href":"/api-reference/agents/messaging"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Expandable,Heading,ParamField,ResponseField,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`send-message-assist-mode`,children:`Send Message (Assist Mode)`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/messages`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Sends a user message into the session and streams the agent’s reply back as `,_jsx(_components.strong,{children:`Server-Sent Events`}),`.`]}),`\n`,_jsx(ParamField,{body:`message`,type:`string`,required:true,id:`param-message`,children:_jsx(_components.p,{children:`The user message.`})}),`\n`,_jsx(ParamField,{body:`model`,type:`string`,id:`param-model`,children:_jsx(_components.p,{children:`Override the model configured on the agent for this turn only.`})}),`\n`,_jsx(Heading,{level:`3`,id:`response`,children:`Response`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Content-Type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` text/event-stream`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Cache-Control`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` no-cache`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Connection`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` keep-alive`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The stream carries a sequence of JSON events covering turn-run state changes, incremental text/token chunks, and tool calls made by the agent as it works.`}),`\n`,`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`400`}),` with `,_jsx(_components.code,{children:`\"message is required\"`}),` if `,_jsx(_components.code,{children:`message`}),` is missing. Returns `,_jsx(_components.code,{children:`429`}),` if the workspace has hit its managed-agent rate limit.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`get-session-timeline`,children:`Get Session Timeline`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`GET`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/events`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Returns the full ordered history of a session — messages and turn runs interleaved, sorted ascending by `,_jsx(_components.code,{children:`created_at`}),`.`]}),`\n`,_jsxs(ResponseField,{name:`events`,type:`(MessageEvent | TurnRunEvent)[]`,id:`param-events`,children:[_jsxs(Expandable,{title:`MessageEvent`,children:[_jsx(ResponseField,{name:`type`,type:`string`,id:`param-type`,children:_jsx(_components.code,{children:`\"message\"`})}),_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id`}),_jsxs(ResponseField,{name:`role`,type:`string`,id:`param-role`,children:[_jsx(_components.code,{children:`user`}),` · `,_jsx(_components.code,{children:`assistant`}),` · `,_jsx(_components.code,{children:`tool`})]}),_jsx(ResponseField,{name:`content`,type:`string`,id:`param-content`}),_jsx(ResponseField,{name:`metadata`,type:`object`,id:`param-metadata`}),_jsx(ResponseField,{name:`created_at`,type:`string`,id:`param-created-at`})]}),_jsxs(Expandable,{title:`TurnRunEvent`,children:[_jsx(ResponseField,{name:`type`,type:`string`,id:`param-type-1`,children:_jsx(_components.code,{children:`\"turn_run\"`})}),_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id-1`}),_jsx(ResponseField,{name:`status`,type:`string`,id:`param-status`}),_jsx(ResponseField,{name:`created_at`,type:`string`,id:`param-created-at-1`}),_jsx(ResponseField,{name:`completed_at`,type:`string | null`,id:`param-completed-at`}),_jsx(ResponseField,{name:`error_message`,type:`string | null`,id:`param-error-message`})]})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`submit-tool-results`,children:`Submit Tool Results`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/tool-results`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`When an agent needs to call a tool your integration owns, it pauses and emits a pending tool call in the event stream. Execute the tool on your side, then report the result back here so the agent can continue.`}),`\n`,_jsx(ParamField,{body:`toolCallId`,type:`string`,required:true,id:`param-tool-call-id`,children:_jsx(_components.p,{children:`The ID of the pending tool call, taken from the event stream.`})}),`\n`,_jsx(ParamField,{body:`result`,type:`any`,id:`param-result`,children:_jsx(_components.p,{children:`The tool’s return value. Provide this on success.`})}),`\n`,_jsx(ParamField,{body:`error`,type:`string`,id:`param-error`,children:_jsxs(_components.p,{children:[`Error message if the tool failed. Provide either `,_jsx(_components.code,{children:`result`}),` or `,_jsx(_components.code,{children:`error`}),`, not both.`]})}),`\n`,`\n`,`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`403`}),` with `,_jsx(_components.code,{children:`\"toolCallId does not belong to session\"`}),` if the tool call belongs to a different session, and `,_jsx(_components.code,{children:`404`}),` with `,_jsx(_components.code,{children:`\"Unknown toolCallId\"`}),` if it doesn’t exist.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`cancel-run`,children:`Cancel Run`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/cancel`})]}),`\n`]})})}),`\n`,_jsx(ParamField,{body:`runId`,type:`string`,required:true,id:`param-run-id`,children:_jsxs(_components.p,{children:[`The turn run (or `,_jsx(_components.a,{href:`/api-reference/agents/runs`,children:`autonomous run`}),`) to cancel.`]})}),`\n`,`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`400`}),` with `,_jsx(_components.code,{children:`\"Run is {current_status}\"`}),` if the run isn’t currently running (e.g. already completed).`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Messaging \u0026 Events","description":"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs","href":"/api-reference/agents/messaging"}}},"mdxSourceWithNoJs":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Expandable,Heading,ParamField,RequestExample,ResponseExample,ResponseField,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!RequestExample)_missingMdxReference(`RequestExample`,true);if(!ResponseExample)_missingMdxReference(`ResponseExample`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`send-message-assist-mode`,children:`Send Message (Assist Mode)`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/messages`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Sends a user message into the session and streams the agent’s reply back as `,_jsx(_components.strong,{children:`Server-Sent Events`}),`.`]}),`\n`,_jsx(ParamField,{body:`message`,type:`string`,required:true,id:`param-message`,children:_jsx(_components.p,{children:`The user message.`})}),`\n`,_jsx(ParamField,{body:`model`,type:`string`,id:`param-model`,children:_jsx(_components.p,{children:`Override the model configured on the agent for this turn only.`})}),`\n`,_jsx(Heading,{level:`3`,id:`response`,children:`Response`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Content-Type`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` text/event-stream`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Cache-Control`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` no-cache`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`Connection`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` keep-alive`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The stream carries a sequence of JSON events covering turn-run state changes, incremental text/token chunks, and tool calls made by the agent as it works.`}),`\n`,_jsx(RequestExample,{children:_jsx(CodeBlock,{filename:`Streaming client`,numberOfLines:`20`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`20`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://suite.sundaypyjamas.com/api/v1/managed-agents/sessions/\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sessionId`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"/messages`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Authorization'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `Bearer \"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`apiKey`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'What did you find in the report?'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` reader`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`body`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getReader`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` decoder`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` TextDecoder`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`while`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`done`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`value`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` reader`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`read`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`done`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`break`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`decoder`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`decode`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`value`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`400`}),` with `,_jsx(_components.code,{children:`\"message is required\"`}),` if `,_jsx(_components.code,{children:`message`}),` is missing. Returns `,_jsx(_components.code,{children:`429`}),` if the workspace has hit its managed-agent rate limit.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`get-session-timeline`,children:`Get Session Timeline`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`GET`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/events`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Returns the full ordered history of a session — messages and turn runs interleaved, sorted ascending by `,_jsx(_components.code,{children:`created_at`}),`.`]}),`\n`,_jsxs(ResponseField,{name:`events`,type:`(MessageEvent | TurnRunEvent)[]`,id:`param-events`,children:[_jsxs(Expandable,{title:`MessageEvent`,children:[_jsx(ResponseField,{name:`type`,type:`string`,id:`param-type`,children:_jsx(_components.code,{children:`\"message\"`})}),_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id`}),_jsxs(ResponseField,{name:`role`,type:`string`,id:`param-role`,children:[_jsx(_components.code,{children:`user`}),` · `,_jsx(_components.code,{children:`assistant`}),` · `,_jsx(_components.code,{children:`tool`})]}),_jsx(ResponseField,{name:`content`,type:`string`,id:`param-content`}),_jsx(ResponseField,{name:`metadata`,type:`object`,id:`param-metadata`}),_jsx(ResponseField,{name:`created_at`,type:`string`,id:`param-created-at`})]}),_jsxs(Expandable,{title:`TurnRunEvent`,children:[_jsx(ResponseField,{name:`type`,type:`string`,id:`param-type-1`,children:_jsx(_components.code,{children:`\"turn_run\"`})}),_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id-1`}),_jsx(ResponseField,{name:`status`,type:`string`,id:`param-status`}),_jsx(ResponseField,{name:`created_at`,type:`string`,id:`param-created-at-1`}),_jsx(ResponseField,{name:`completed_at`,type:`string | null`,id:`param-completed-at`}),_jsx(ResponseField,{name:`error_message`,type:`string | null`,id:`param-error-message`})]})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`submit-tool-results`,children:`Submit Tool Results`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/tool-results`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`When an agent needs to call a tool your integration owns, it pauses and emits a pending tool call in the event stream. Execute the tool on your side, then report the result back here so the agent can continue.`}),`\n`,_jsx(ParamField,{body:`toolCallId`,type:`string`,required:true,id:`param-tool-call-id`,children:_jsx(_components.p,{children:`The ID of the pending tool call, taken from the event stream.`})}),`\n`,_jsx(ParamField,{body:`result`,type:`any`,id:`param-result`,children:_jsx(_components.p,{children:`The tool’s return value. Provide this on success.`})}),`\n`,_jsx(ParamField,{body:`error`,type:`string`,id:`param-error`,children:_jsxs(_components.p,{children:[`Error message if the tool failed. Provide either `,_jsx(_components.code,{children:`result`}),` or `,_jsx(_components.code,{children:`error`}),`, not both.`]})}),`\n`,_jsx(RequestExample,{children:_jsx(CodeBlock,{filename:`cURL`,numberOfLines:`4`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://suite.sundaypyjamas.com/api/v1/managed-agents/sessions/sess_44bc.../tool-results`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer spj_ai_your_api_key_here\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{ \"toolCallId\": \"tc_991a...\", \"result\": { \"status\": \"ok\", \"rows\": 12 } }'`})]}),`\n`]})})})}),`\n`,_jsx(ResponseExample,{children:_jsx(CodeBlock,{filename:`Response`,numberOfLines:`6`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"accepted\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"sessionId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"sess_44bc...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"toolCallId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"tc_991a...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"status\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"completed\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`403`}),` with `,_jsx(_components.code,{children:`\"toolCallId does not belong to session\"`}),` if the tool call belongs to a different session, and `,_jsx(_components.code,{children:`404`}),` with `,_jsx(_components.code,{children:`\"Unknown toolCallId\"`}),` if it doesn’t exist.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`cancel-run`,children:`Cancel Run`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`http`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`http`,children:_jsxs(_components.code,{language:`http`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`POST`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` /api/v1/managed-agents/sessions/\u0026#123;sessionId\u0026#125;/cancel`})]}),`\n`]})})}),`\n`,_jsx(ParamField,{body:`runId`,type:`string`,required:true,id:`param-run-id`,children:_jsxs(_components.p,{children:[`The turn run (or `,_jsx(_components.a,{href:`/api-reference/agents/runs`,children:`autonomous run`}),`) to cancel.`]})}),`\n`,_jsx(ResponseExample,{children:_jsx(CodeBlock,{filename:`Response`,numberOfLines:`4`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"runId\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"run_8a21...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"status\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cancelled\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`400`}),` with `,_jsx(_components.code,{children:`\"Run is {current_status}\"`}),` if the run isn’t currently running (e.g. already completed).`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Messaging \u0026 Events","description":"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs","href":"/api-reference/agents/messaging"}}}},"mdxExtracts":{"tableOfContents":[{"title":"Send Message (Assist Mode)","slug":"send-message-assist-mode","depth":2,"children":[{"title":"Response","slug":"response","depth":3,"children":[]}]},{"title":"Get Session Timeline","slug":"get-session-timeline","depth":2,"children":[]},{"title":"Submit Tool Results","slug":"submit-tool-results","depth":2,"children":[]},{"title":"Cancel Run","slug":"cancel-run","depth":2,"children":[]}],"codeExamples":{"request":{"type":"RequestExample","children":[{"filename":"Streaming client","html":"\u003cpre class=\"shiki shiki-themes github-light-default dark-plus\" style=\"background-color:#ffffff;--shiki-dark-bg:#0B0C0E;color:#1f2328;--shiki-dark:#D4D4D4\" language=\"javascript\">\u003ccode language=\"javascript\" numberOfLines=\"20\">\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">const\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#4FC1FF\"> response\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\"> =\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> fetch\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> `https://suite.sundaypyjamas.com/api/v1/managed-agents/sessions/\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#569CD6\">${\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">sessionId\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">/messages`\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\"> method:\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> 'POST'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\"> headers:\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> 'Authorization'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">:\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> `Bearer \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#569CD6\">${\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">apiKey\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">`\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> 'Content-Type'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">:\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> 'application/json'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> },\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\"> body:\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#4FC1FF\"> JSON\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\">stringify\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">({ \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">message:\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> 'What did you find in the report?'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> }),\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> }\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">);\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">const\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#4FC1FF\"> reader\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\"> =\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\"> response\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">body\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\">getReader\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">();\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">const\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#4FC1FF\"> decoder\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\"> =\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> new\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> TextDecoder\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">();\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">while\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> (\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">true\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">) {\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> const\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> { \u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#4FC1FF\">done\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#4FC1FF\">value\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> } \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\"> reader\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\">read\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">();\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> if\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> (\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">done\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">) \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">break\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">;\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\"> console\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\">log\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">decoder\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\">decode\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">value\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">));\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">}\u003c/span>\u003c/span>\n\u003c/code>\u003c/pre>"}],"attributes":[]},"response":{"type":"ResponseExample","children":[{"filename":"Response","html":"\u003cpre class=\"shiki shiki-themes github-light-default dark-plus\" style=\"background-color:#ffffff;--shiki-dark-bg:#0B0C0E;color:#1f2328;--shiki-dark:#D4D4D4\" language=\"json\">\u003ccode language=\"json\" numberOfLines=\"6\">\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">{\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#116329;--shiki-dark:#9CDCFE\"> \"accepted\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">true\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#116329;--shiki-dark:#9CDCFE\"> \"sessionId\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"sess_44bc...\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#116329;--shiki-dark:#9CDCFE\"> \"toolCallId\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"tc_991a...\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#116329;--shiki-dark:#9CDCFE\"> \"status\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"completed\"\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">}\u003c/span>\u003c/span>\n\u003c/code>\u003c/pre>"}],"attributes":[]}}},"jsLinks":[],"subdomain":"sundaypyjamas","siteName":"SundayPyjamas AI Suite","title":"Messaging \u0026 Events - SundayPyjamas AI Suite","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-07-09T19:52:28.547Z","originalFileLocation":"api-reference/agents/messaging.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs\">\u003cmeta data-mint-head name=\"application-name\" content=\"SundayPyjamas AI Suite\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Messaging \u0026amp; Events - SundayPyjamas AI Suite\">\u003cmeta data-mint-head property=\"og:description\" content=\"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"SundayPyjamas AI Suite\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.sundaypyjamas.com/api-reference/agents/messaging\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://sundaypyjamas.mintlify.site/_mintlify/api/og/v2?division=Agents\u0026amp;title=Messaging+%26+Events\u0026amp;description=Stream+assist-mode+replies%2C+read+the+session+timeline%2C+respond+to+tool+calls%2C+and+cancel+runs\u0026amp;theme=fa3b1ef4a5a7bb21408bdce7\u0026amp;signature=a618e98457464644c1404a814fc0b24fa3cce051666b6fc9120d93687bdb9e10\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Messaging \u0026amp; Events - SundayPyjamas AI Suite\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://sundaypyjamas.mintlify.site/_mintlify/api/og/v2?division=Agents\u0026amp;title=Messaging+%26+Events\u0026amp;description=Stream+assist-mode+replies%2C+read+the+session+timeline%2C+respond+to+tool+calls%2C+and+cancel+runs\u0026amp;theme=fa3b1ef4a5a7bb21408bdce7\u0026amp;signature=a618e98457464644c1404a814fc0b24fa3cce051666b6fc9120d93687bdb9e10\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/sundaypyjamas/wQgQ3BV84t2A39dR/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"SundayPyjamas AI Suite\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#52525B\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.sundaypyjamas.com/api-reference/agents/messaging\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/agents/messaging.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.sundaypyjamas.com/#organization\",\"name\":\"SundayPyjamas AI Suite\",\"url\":\"https://docs.sundaypyjamas.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/sundaypyjamas/mPtTCdYgcCjb2V3-/logo/dark.svg?fit=max\u0026auto=format\u0026n=mPtTCdYgcCjb2V3-\u0026q=85\u0026s=e5e3e1e59634cc40750fcd055681aa89\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.sundaypyjamas.com#website\",\"name\":\"SundayPyjamas AI Suite\",\"url\":\"https://docs.sundaypyjamas.com\",\"publisher\":{\"@id\":\"https://docs.sundaypyjamas.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging#webpage\",\"url\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging\",\"name\":\"Messaging \u0026 Events\",\"description\":\"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs\",\"dateModified\":\"2026-07-09T19:52:28.547Z\",\"isPartOf\":{\"@id\":\"https://docs.sundaypyjamas.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Agents\",\"item\":\"https://docs.sundaypyjamas.com/api-reference/agents/introduction\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Messaging \u0026 Events\",\"item\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging#article\",\"headline\":\"Messaging \u0026 Events\",\"name\":\"Messaging \u0026 Events\",\"description\":\"Stream assist-mode replies, read the session timeline, respond to tool calls, and cancel runs\",\"url\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging\",\"mainEntityOfPage\":{\"@id\":\"https://docs.sundaypyjamas.com/api-reference/agents/messaging#webpage\"},\"dateModified\":\"2026-07-09T19:52:28.547Z\",\"publisher\":{\"@id\":\"https://docs.sundaypyjamas.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.sundaypyjamas.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"SundayPyjamas AI Suite\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"SundayPyjamas AI Suite\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-reference/agents/messaging.md","siteName":"SundayPyjamas AI Suite","nav":{"global":{"anchors":[{"anchor":"API Platform","icon":"gauge-high","href":"https://suite.sundaypyjamas.com"},{"anchor":"GitHub","icon":"github","href":"https://github.com/sundaypyjamas"}]},"tabs":[{"tab":"User Guide","pages":[{"title":"User Guide","href":"/user-guide/welcome"}]},{"tab":"Documentation","pages":[{"title":"Documentation","href":"/introduction"}]},{"tab":"API Reference","groups":[{"group":"Chat","pages":[{"title":"Chat API Reference","href":"/api-reference/chat/introduction"},{"title":"POST /chat","api":"POST https://suite.sundaypyjamas.com/api/v1/chat","href":"/api-reference/chat/post-chat"}]},{"group":"Agents","pages":[{"title":"Agents API","href":"/api-reference/agents/introduction"},{"title":"Manage Agents","href":"/api-reference/agents/agents"},{"title":"Runs","href":"/api-reference/agents/runs"},{"title":"Sessions","description":"Manage the conversational or work context an agent operates in","href":"/api-reference/agents/sessions"},{"title":"Messaging \u0026 Events","href":"/api-reference/agents/messaging"}]},{"group":"RAG","pages":[{"title":"RAG API","description":"Upload documents and query them with retrieval-augmented generation","href":"/api-reference/rag/introduction"},{"title":"POST /rag/upload","api":"POST https://suite.sundaypyjamas.com/api/v1/rag/upload","href":"/api-reference/rag/upload"},{"title":"POST /rag/query","api":"POST https://suite.sundaypyjamas.com/api/v1/rag/query","href":"/api-reference/rag/query"}]},{"group":"Artifacts","pages":[{"title":"Artifacts API","href":"/api-reference/artifacts/introduction"},{"title":"POST /artifacts/generate","api":"POST https://suite.sundaypyjamas.com/api/v1/artifacts/generate","href":"/api-reference/artifacts/generate"}]},{"group":"Image","pages":[{"title":"Image API","href":"/api-reference/image/introduction"},{"title":"POST /image","api":"POST https://suite.sundaypyjamas.com/api/v1/image","href":"/api-reference/image/generate"}]},{"group":"Vector Store","pages":[{"title":"Vector Store API","href":"/api-reference/vector-store/introduction"},{"title":"Indexes","href":"/api-reference/vector-store/indexes"},{"title":"Vectors","href":"/api-reference/vector-store/vectors"}]},{"group":"Apps","pages":[{"title":"Apps API","href":"/api-reference/apps/introduction"},{"title":"Chat","href":"/api-reference/apps/chat"},{"title":"Memory","href":"/api-reference/apps/memory"},{"title":"Usage","href":"/api-reference/apps/usage"}]},{"group":"Storage","pages":[{"title":"Storage API","href":"/api-reference/storage/introduction"},{"title":"Files","href":"/api-reference/storage/files"},{"title":"Folders \u0026 Tree","href":"/api-reference/storage/folders"},{"title":"Import","href":"/api-reference/storage/import"}]},{"group":"Integrations","pages":[{"title":"Integrations API","href":"/api-reference/integrations/introduction"},{"title":"Integration Packs","href":"/api-reference/integrations/integration-packs"},{"title":"MCP Connectors","href":"/api-reference/integrations/mcp-connectors"}]},{"group":"Insights","pages":[{"title":"Insights API","href":"/api-reference/insights/introduction"},{"title":"Conversations","href":"/api-reference/insights/conversations"}]},{"group":"Platform Tools","pages":[{"title":"Platform Tools API","href":"/api-reference/platform-tools/introduction"}]}]}]},"basePath":"","title":"Messaging \u0026 Events - SundayPyjamas AI Suite","deploymentId":"dpl_57NA6NKtrcUBhuxv6Tm2hAi21TK4","buildId":"dpl_57NA6NKtrcUBhuxv6Tm2hAi21TK4","dynamics":["2b790eda92"],"chunks":["ApiExamples-CSBS2nDe.js","usePlaygroundInputsStore-BkN7uKke.js","shallow-6IMgYiEa.js","utils-DOTAoFcT.js","utils-Bn5byECU.js","isEqual-DicuCknl.js","_Uint8Array-CQuRedKT.js","isObject-FP1Yky1u.js","CodeSnippets-C268fsRY.js","CodeSnippet-BBA8eWiP.js","snippetPresets-DtvvunBK.js","style-to-object-BY3JEAdk.js","cloneDeep-k2aHAqp5.js","v4-DIgz8zy6.js","getApiPlaygroundDisplay-DMK5GRGS.js"]}