Stream a chat turn (SSE)
Send a user message to an existing chat and stream the assistant's reply as Server-Sent Events.
SDK method: patient.chats.stream() in TypeScript and Python. patient is the user-scoped client, client.forUser(userId) or client.for_user(user_id).
/chats/{chatId}/stream/Send a user message to an existing chat and stream the assistant's reply as Server-Sent Events.
The response is text/event-stream (not the standard JSON envelope). Each event is a
frame of the form event: <type> followed by a camelCase JSON data: payload. The
connection stays open for the whole assistant turn and closes when the turn ends.
Event types (see the 200 response examples for full payloads):
message.start/message.content/message.stop: the assistant message lifecycle and its streamed text chunks.conversation.offtopic: the message was classified as off-topic.conversation.end: the assistant ended the conversation (reasonexplains why).guardian: a safety condition was detected;guardianIdis stable.error: an error; the stream ends after it.errorCodeiserror.rate_limited(may includeretryAfterSeconds),error.internal(the reply failed; don't retry the turn automatically: read the transcript, then let the patient resend), orerror.consultation_not_ready(the consultation could not be finalized; booking is unavailable).skill_code.cta: an end-of-flow call to action (e.g. see a Doctronic doctor, or book an in-person visit); carriesskillCode,widget, and an optionaltextlabel.ai_consultation.complete: consultation completion with document IDs. Document retrieval can still return202while generation finishes.
Event compatibility: Published event names are stable wire identifiers. New event names may be added. A replacement will be introduced additively and the old name explicitly deprecated; published names will not be silently renamed. Consumers should ignore event names they do not recognize.
Request body
userEvent: the user message:typeuser_message,userInput, and optionalmessagePromptContext(up to 50,000 characters) with situational context for this turn.timezone: optional IANA timezone (defaultUTC); an invalid value returns400.
The chat must have been created through this Doctronic API and belong to both the
authenticated organization and user; otherwise it is masked as
404 error.partner.chat_not_found.
Auth: organization Bearer token + X-Doctronic-User-ID header (both required).
Authorization
HTTPBearer XDoctronicUserID In: header
Doctronic user ID returned as data.id by POST /users/. This value identifies the user in your organization scope; it is not an API token.
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
text/event-stream
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/chats/string/stream/" \ -H "Content-Type: application/json" \ -d '{ "userEvent": { "userInput": "string" } }'message.start{ "type": "message.start", "role": "assistant", "messageId": "ac_hist_01K6JGGM2G2DB4Y9KB9H9MJJ6Q", "messageTimestamp": 1741856873000}View raw SSE frame
event: message.startdata: {"type":"message.start","role":"assistant","messageId":"ac_hist_01K6JGGM2G2DB4Y9KB9H9MJJ6Q","messageTimestamp":1741856873000}