# Update message div strong 🔨 In Development — This section is still being developed and may change. Edit message content and metadata after creation. NEW endpoint for content modification with proper authorization and validation. Edit message content and metadata after creation. This is a new endpoint that provides content modification capabilities with proper authorization, validation, and audit trails. #### Path Parameters **`thread_id`** string required The unique identifier of the thread containing the message. **`message_id`** string required The unique identifier of the message to update. #### Request Body **`content`** string optional The new text content for the message. Content is automatically trimmed of leading/trailing whitespace. Cannot be empty or whitespace only. **`metadata`** object optional Custom key-value pairs for message metadata. Performs partial update - merges with existing metadata. Update Content ```bash curl -X PATCH "https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content": "I have a billing question about my recent invoice" }' ``` ```python import requests response = requests.patch( "https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123", headers={"Authorization": f"Bearer {api_key}"}, json={ "content": "I have a billing question about my recent invoice" } ) message = response.json() print(f"Updated message: {message['content'][0]['text']}") ``` ```javascript const response = await fetch('https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123', { method: 'PATCH', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ content: 'I have a billing question about my recent invoice' }) }); const message = await response.json(); console.log(`Updated message: ${message.content[0].text}`); ``` Update Metadata ```bash curl -X PATCH "https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "metadata": { "edited": true, "edit_reason": "added more context", "edit_timestamp": "2025-01-04T10:30:00Z" } }' ``` ```python import requests response = requests.patch( "https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123", headers={"Authorization": f"Bearer {api_key}"}, json={ "metadata": { "edited": True, "edit_reason": "added more context", "edit_timestamp": "2025-01-04T10:30:00Z" } } ) message = response.json() print(f"Updated message metadata: {message['metadata']}") ``` ```javascript const response = await fetch('https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123', { method: 'PATCH', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ metadata: { edited: true, edit_reason: 'added more context', edit_timestamp: '2025-01-04T10:30:00Z' } }) }); const message = await response.json(); console.log('Updated message metadata:', message.metadata); ``` Update Both ```bash curl -X PATCH "https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123" \ -H "Authorization: Bearer $FREDDY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content": "I have a billing question about my recent invoice #INV-2025-001", "metadata": { "edited": true, "edit_reason": "added invoice number for clarity" } }' ``` ```python import requests response = requests.patch( "https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123", headers={"Authorization": f"Bearer {api_key}"}, json={ "content": "I have a billing question about my recent invoice #INV-2025-001", "metadata": { "edited": True, "edit_reason": "added invoice number for clarity" } } ) message = response.json() print(f"Updated message: {message['content'][0]['text']}") print(f"Metadata: {message['metadata']}") ``` ```javascript const response = await fetch('https://api.freddy.aitronos.com/v1/threads/thread_abc123/messages/msg_abc123', { method: 'PATCH', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ content: 'I have a billing question about my recent invoice #INV-2025-001', metadata: { edited: true, edit_reason: 'added invoice number for clarity' } }) }); const message = await response.json(); console.log(`Updated message: ${message.content[0].text}`); console.log('Metadata:', message.metadata); ``` ## Response 200 OK ```json { "id": "msg_abc123", "object": "thread.message", "createdAt": 1741476542, "updatedAt": 1741476900, "threadId": "thread_abc123", "role": "user", "content": [ { "type": "text", "text": "I have a billing question about my recent invoice #INV-2025-001" } ], "metadata": { "edited": true, "edit_reason": "added invoice number for clarity" } } ``` Errors ```json 400 Bad Request { "error": { "message": "Content cannot be empty", "type": "invalid_request_error", "code": "empty_content", "param": "content" } } ``` ```json 404 Not Found { "error": { "message": "Message not found or access denied", "type": "not_found_error", "code": "message_not_found" } } ``` ```json 422 Validation Error { "error": { "message": "Must provide at least one field to update", "type": "validation_error", "code": "no_fields_provided" } } ``` ## Related Resources - [Threads Overview](/docs/documentation/core-concepts/threads-overview) - [Get Thread Messages](/docs/api-reference/threads/messages) - [Delete Message](/docs/api-reference/threads/delete-message) - [Thread Context Modes](/docs/documentation/core-concepts/thread-context-modes)