The Messages REST API provides management of messages within conversations. All message operations are scoped to specific conversations using external IDs.
Base URL: https://your-api-name.mercury.ratiomachina.com Authentication: x-mercury-api-key: YOUR_API_KEY (Note: Not validated for message endpoints)
external_id - Conversation external IDNo query parameters supported. Returns conversation with all messages and context.
{
"conversation": {
"id": "456e7890-e89b-12d3-a456-426614174000",
"externalId": "conv789",
"personaId": "789e4567-e89b-12d3-a456-426614174000",
"contactId": "123e4567-e89b-12d3-a456-426614174000",
"data": "{"channel":"SMS"}",
"createdAt": "2024-01-15T10:35:00Z",
"updatedAt": "2024-01-15T10:45:00Z",
"messages": [
{
"id": "abc12345-e89b-12d3-a456-426614174000",
"conversationId": "456e7890-e89b-12d3-a456-426614174000",
"sender": "contact",
"message": "Hello, I need help",
"messageType": "undefined",
"data": "{}",
"createdAt": "2024-01-15T10:35:00Z"
}
],
"persona": {
"id": "789e4567-e89b-12d3-a456-426614174000",
"externalId": "agent456",
"name": "Sales Agent",
"data": "{"tone":"friendly"}",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
},
"contact": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"externalId": "customer123",
"name": "John Doe",
"email": "john@example.com",
"phone": "555-0123",
"data": "{"source":"website"}",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}
}
}{
"message": "Hello, I need help with my order",
"sender": "contact"
}{
"message": {
"id": "abc12345-e89b-12d3-a456-426614174000",
"conversationId": "456e7890-e89b-12d3-a456-426614174000",
"message": "Hello, I need help with my order",
"sender": "contact",
"createdAt": "2024-01-15T10:35:00Z",
"data": "{}"
}
}external_id - Conversation external IDid - Message UUID{
"message": {
"id": "abc12345-e89b-12d3-a456-426614174000",
"conversationId": "456e7890-e89b-12d3-a456-426614174000",
"message": "Hello, I need help with my order",
"sender": "contact",
"createdAt": "2024-01-15T10:35:00Z",
"data": "{}"
}
}Update message content and sender. Only provided fields will be updated.
{
"message": "Updated message content",
"sender": "contact"
}{
"message": {
"id": "abc12345-e89b-12d3-a456-426614174000",
"conversationId": "456e7890-e89b-12d3-a456-426614174000",
"message": "Updated message content",
"sender": "contact",
"createdAt": "2024-01-15T10:35:00Z",
"data": "{}"
}
}⚠️ Warning: This will permanently delete the message from the conversation.
external_id - Conversation external IDid - Message UUID{
"message": "Message deleted successfully",
"deletedMessage": {
"id": "abc12345-e89b-12d3-a456-426614174000",
"conversationId": "456e7890-e89b-12d3-a456-426614174000",
"message": "Hello, I need help with my order",
"sender": "contact",
"createdAt": "2024-01-15T10:35:00Z"
}
}