Skip to content

Update Message

PATCH
/api/chat/messages/{message_id}

Update message content

Updates the content of an existing message. Only user messages can be edited. AI responses cannot be modified directly (use regenerate instead).

Args: request: FastAPI request object message_id: ID of message to update request_data: Message update data (new content) backend: Backend service instance (injected)

Returns: MessageUpdateResponse: Updated message data

Raises: HTTPException: 404 if message not found HTTPException: 403 if attempting to edit AI message HTTPException: 500 if update fails

Example Request: PATCH /chat/messages/msg_abc123 { “content”: “Updated message content here” }

Example Response: { “status”: “success”, “message_id”: “msg_abc123”, “updated_message”: { “id”: “msg_abc123”, “content”: “Updated message content here”, “role”: “user”, “edited”: true }, “edited_at”: “2025-01-15T10:30:00Z” }

message_id
required
Message Id
string
MessageUpdateRequest

Message content update request model.

Request model for updating the content of an existing message. Only user messages can be edited. AI responses cannot be modified directly (use regenerate instead).

Fields: content: New message content (must be non-empty)

Used By: - PATCH /api/chat/messages/{message_id} endpoint - Message edit UI - Message correction workflow

object
content
required
Content

New message content

string
>= 1 characters

Successful Response

MessageUpdateResponse

Message update response model.

Confirms successful update of message content with updated message data.

Fields: status: Update status (“success”, “error”) message_id: ID of updated message updated_message: Updated message object edited_at: Edit timestamp

Used By: - PATCH /api/chat/messages/{message_id} response - Message edit confirmation - Message history tracking

object
status
required
Status

Update status (‘success’ or ‘error’)

string
messageId
required
Messageid

ID of updated message

string
updatedMessage
required
ChatMessage

Updated message object

object
messageId
required
Messageid

Unique message identifier

string
threadId
required
Threadid

Parent thread identifier

string
role
required
Role

Message role (‘user’ or ‘assistant’)

string
content
required
Content

Message text content

string
timestamp
Timestamp

Message timestamp

string format: date-time
agentUsed
Any of:
string
modelUsed
Any of:
string
isError
Any of:
boolean
senderName
Any of:
string
contentType
Any of:
string
workflowType
Any of:
string
sources
Any of:
Array<string>
uuid
Any of:
string
conversationId
Any of:
string
version
Any of:
string
schemaVersion
Any of:
string
userId
Any of:
string
sessionId
Any of:
string
projectId
Any of:
string
createdBy
Any of:
string
modifiedBy
Any of:
string
createdAt
Any of:
string
modifiedAt
Any of:
string
editedAt
Any of:
string
status
Any of:
string
isEdited
Any of:
boolean
isDeleted
Any of:
boolean
isPinned
Any of:
boolean
isFavorite
Any of:
boolean
responseTimeMs
Any of:
number
generationTimeMs
Any of:
number
tokensPerSecond
Any of:
number
tokensUsed
Any of:
integer
promptTokens
Any of:
integer
completionTokens
Any of:
integer
contextSources
Any of:
Array<object>
ContextSourceInfo

RAG context source information for chat responses.

Represents a single document or source used to provide context for AI responses through Retrieval-Augmented Generation (RAG). Includes relevance scoring and source metadata for attribution and transparency.

Fields: source: Document or source identifier score: Semantic similarity score (0.0-1.0, higher is more relevant) title: Human-readable source title content_preview: Preview snippet of relevant content document_type: Type of document (e.g., ‘lore’, ‘character’, ‘world’) collection: ChromaDB collection name

Used By: - ChatResponse.context_sources - EnhancedChatResponse.context_sources - ChatMessage.context_sources - ChatMessageInfo.context_sources

object
source
required
Source

Document or source identifier

string
score
required
Score

Semantic similarity score (0.0-1.0)

number
<= 1
title
Any of:
string
contentPreview
Any of:
string
documentType
Any of:
string
collection
Any of:
string
chunkIndex
Any of:
integer
metadata
Any of:
object
key
additional properties
string
ragEnabled
Any of:
boolean
ragSourcesCount
Any of:
integer
contextQuality
Any of:
number
searchResultsCount
Any of:
integer
qualityScore
Any of:
number
<= 100
relevanceScore
Any of:
number
<= 1
confidenceScore
Any of:
number
<= 1
parentMessageId
Any of:
string
previousMessageId
Any of:
string
nextMessageId
Any of:
string
replyToMessageId
Any of:
string
tags
Any of:
Array<string>
customMetadata
Any of:
CustomMetadataInfo

Custom metadata container for extensibility.

Provides a structured container for custom key-value metadata that doesn’t fit into predefined fields. Supports common metadata patterns.

Fields: tags: List of tags for categorization labels: Key-value labels annotations: Additional annotations source: Data source identifier version: Data version

Used By: - Various models’ custom_metadata fields

object
tags
Any of:
Array<string>
labels
Any of:
object
key
additional properties
string
annotations
Any of:
object
key
additional properties
string
source
Any of:
string
version
Any of:
string
extra
Any of:
object
key
additional properties
string
persona
Any of:
string
stance
Any of:
string
thinkingSteps
Any of:
Array<object>
ThinkingStepInfo

Pipeline thinking step captured from a workflow callback.

Mirrors enhanced_chat_handler.ThinkingStep but lives in the schema package so response models can reference it without a circular import. Shape is authoritative — the only writer is WorkflowCallbackHandler which builds dicts with exactly these fields.

Used By: - ChatMessage.thinking_steps (restored from SQLite on thread load)

object
stepNumber
required
Stepnumber

Step index

integer
>= 1
stepName
required
Stepname

Human-readable step name

string
stepDescription
required
Stepdescription

Human-readable description

string
inputData
required
Inputdata

Inputs at step start

object
key
additional properties
any
outputData
required
Outputdata

Outputs at step end

object
key
additional properties
any
durationMs
required
Durationms

Step duration in ms

integer
timestamp
required
Timestamp

ISO timestamp

string
reasoningTrace
Any of:
Array<object>
ReasoningStepInfo

Individual reasoning step in AI thinking trace.

Represents a single step in the AI’s reasoning process for transparency and debugging. Includes step type, content, timing, and confidence.

Fields: step_number: Sequential step number step_type: Type of reasoning (e.g., ‘analysis’, ‘synthesis’, ‘evaluation’) content: Reasoning content or thought confidence: Confidence level for this step (0.0-1.0) duration_ms: Time taken for this step

Used By: - EnhancedChatResponse.reasoning_trace - ChatMessage.reasoning_trace - EnhancedChatStreamChunk.reasoning_trace

object
stepNumber
required
Stepnumber

Sequential step number

integer
>= 1
stepType
Any of:
string
content
required
Content

Reasoning content or thought

string
confidence
Any of:
number
<= 1
durationMs
Any of:
number
toolUsed
Any of:
string
result
Any of:
string
modelReasoning
Any of:
string
toolCalls
Any of:
Array<object>
object
key
additional properties
any
toolCallId
Any of:
string
originalContent
Any of:
string
images
Any of:
Array<object>
ImageAttachment

Base64-encoded image attached to a chat message.

object
mediaType
required
Mediatype

MIME type (image/png, image/jpeg, image/gif, image/webp)

string
data
required
Data

Base64-encoded image data

string
requestId
Any of:
string
traceId
Any of:
string
correlationId
Any of:
string
error
Any of:
string
warnings
Any of:
Array<string>
extra
Any of:
CustomMetadataInfo

Custom metadata container for extensibility.

Provides a structured container for custom key-value metadata that doesn’t fit into predefined fields. Supports common metadata patterns.

Fields: tags: List of tags for categorization labels: Key-value labels annotations: Additional annotations source: Data source identifier version: Data version

Used By: - Various models’ custom_metadata fields

object
tags
Any of:
Array<string>
labels
Any of:
object
key
additional properties
string
annotations
Any of:
object
key
additional properties
string
source
Any of:
string
version
Any of:
string
extra
Any of:
object
key
additional properties
string
editedAt
required
Editedat

Edit timestamp

string format: date-time

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object