Skip to main content
Edit the content of a user message. All messages after the edited message are removed, and a fresh agent response is streamed back via SSE.
Only user messages can be edited. Attempting to edit an assistant message returns 400. The re-streamed response uses the same SSE event format as Send Message.
Editing is destructive. All messages following the edited message are permanently removed before the new response is streamed.
Authorization
string
required
Bearer token obtained from the authenticate endpoint.
Accept
string
Set to text/event-stream to receive SSE responses.
chat_id
string
required
Unique identifier of the chat containing the message.
message_id
string
required
Unique identifier of the user message to edit.
content
string
required
The new message content to replace the original.
integration_id
string
ID of the database integration to query for the re-streamed response.
model
string
AI model to use for the re-streamed response. If omitted, the default model is used. See List Models for available values.
include_tool_events
boolean
If true, internal tool events (tool_call, tool_result, tool_message) are included in the stream. Defaults to false.

Response

The response is a stream of Server-Sent Events — identical in format to Send Message.

Event types

EventDataDescription
chat_metadata{"id": "chat_...", "user_message_id": "msg_..."}Emitted first. Contains the chat ID and the new user message ID.
processing{"status": "thinking"}AI is processing the request.
visualizationFull chart or table payloadA chart or table was generated. See Visualizations.
message{"content": "...", "id": "msg_..."}The final response from the AI.
error{"error": "..."}An error occurred during processing.
curl -X PATCH "https://api.trellis.sh/v1/chats/chat_abc123/messages/msg_xyz789" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{
    "content": "Show me the top 10 projects by budget instead",
    "integration_id": "550e8400-e29b-41d4-a716-446655440000"
  }'
event: chat_metadata
data: {"id": "chat_abc123", "user_message_id": "msg_new001"}

event: processing
data: {"status": "thinking"}

event: processing
data: {"status": "analyzing"}

event: visualization
data: {"id": "ab12xy3456", "type": "chart", "chart_type": "bar", "title": "Top 10 Projects by Budget", "data": {"values": [{"label": "Green Spine Boulevard", "value": 31600000}, {"label": "Marina Gate Phase 2", "value": 22100000}], "x_axis_label": "Project", "y_axis_label": "Budget (AED)"}}

event: message
data: {"content": "Here are the top 10 projects by budget.", "id": "msg_new002"}