Replace a chat's messages
/v1/chat/updateRetired. This endpoint answers
410 Goneand no longer works. It is documented for reference only; use the v2 agent API's Chat instead.
Overwrite the entire message history of a chat with the array you
send. Use it to prune, correct or restructure a conversation; sending
[] empties the chat.
Unlike Send a message, no normalization is applied here: every
message must already be in a valid shape. In particular an
output_status part must be resolved or needs_clarification, and
every slot in an output_slots part needs a string id. Slots are also
checked against the stored slot rules on save (a search slot's
query must be 6–120 characters, slot and fit values must be
from their enums); a violation there is rejected with 422
and a details array naming each offending path.
Request body
application/jsonrequiredId of the chat to overwrite.
The complete new thread. May be empty. Not normalized — every message must already be valid.
Who wrote the message. system messages are passed to the model verbatim.
userassistantsystemPlain text, or an array of content parts.
Response
Id of the chat that was updated.
Number of messages now stored.
Errors
42Every error is JSON with a single error string unless noted. Match on the status code; the message is for humans.
Request body must be valid JSON.The request body could not be parsed as JSON.
Request body must be a JSON object.The request body is empty, or parsed to something other than a JSON object (for example an array or a string).
Chat not found or you do not have permission to access it.No chat with that id belongs to the organization.
This endpoint has been retired (v1/chat/update).Always, for API callers. This check runs before authentication and consumes no quota.
The 'chatId' field must be provided as a non-empty string.chatId is missing, empty, or not a string.
A valid chatId is required.chatId is only whitespace.
The 'messages' field must be provided as an array.messages is missing or not an array.
Message at index <n> must be an object.An entry of messages is not an object.
Message at index <n> must have a 'role' field.A message has no string role.
Message at index <n> has invalid role '<role>'. Must be one of: user, assistant, system.role is anything other than user, assistant or system.
Message at index <n> must have a 'content' field.content is missing or null.
Message at index <n> has empty content array. Must have at least one content part.content is an empty array.
Message at index <n> has invalid content. Must be either a string or an array of content parts.content is neither a string nor an array.
Message at index <n>: Content part at index <i> must be an object.A content part is not an object.
Message at index <n>: Content part at index <i> must have a 'type' field.A content part has no string type.
Message at index <n>: Content part at index <i> has invalid type '<type>'. Must be one of: input_text, output_text, input_image, output_slots, output_status.type is not one of the five content part types.
Message at index <n>: Content part at index <i> with type '<type>' must have a 'text' property.An input_text or output_text part has no string text.
Message at index <n>: Content part at index <i> with type '<type>' should not have '<field>' property.A part carries a field that belongs to another type (for example image_url on an input_text part, or text on an output_slots part).
Message at index <n>: Content part at index <i> with type 'input_image' must have an 'image_url' string property.An input_image part has no string image_url.
Message at index <n>: Content part at index <i> with type 'output_slots' must have a 'slots' array property.An output_slots part has no slots array.
Message at index <n>: Content part at index <i>: slot at index <j> must be an object.An entry of slots is not an object.
Message at index <n>: Content part at index <i>: slot at index <j> must have an 'id' string property.A slot has no string id.
Message at index <n>: Content part at index <i> with type 'output_status' must have a 'status' string property.An output_status part has no string status.
Message at index <n>: Content part at index <i> with type 'output_status' has invalid status '<status>'. Must be one of: resolved, needs_clarification.status is any other value, including transient markers such as streaming.
Validation failed.The messages passed the checks above but the stored slot rules rejected them on save (for example a search slot whose query is shorter than 6 characters). details lists each offending path with its message.
{
"error": "Validation failed.",
"details": [
{
"path": "messages.1.content.1.slots.0.query",
"message": "Path `query` (`tee`) is shorter than the minimum allowed length (6)."
}
]
}curl -X POST "https://stylor.ai/api/v1/chat/update" \
-H "Authorization: Bearer $STYLOR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "3f0c2a4e-8b1d-4c6a-9e2f-7a5b1c0d9e88",
"messages": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "I need a smart-casual outfit for a rooftop dinner."
}
]
},
{
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "For a rooftop dinner I'\''d pair a silk slip dress with a cropped leather jacket."
},
{
"type": "output_slots",
"slots": [
{
"id": "8066a68a-a39e-4d3e-993a-3887f6245032",
"type": "search",
"slot": "dress",
"query": "black silk slip dress",
"filters": {
"color_family": [
"black"
],
"family": [
"dress"
],
"exclude_terms": [],
"boost_terms": [
"silk"
]
},
"results": []
}
]
},
{
"type": "output_status",
"status": "resolved"
}
]
}
]
}'{
"chatId": "3f0c2a4e-8b1d-4c6a-9e2f-7a5b1c0d9e88",
"messagesCount": 2
}