Trying to understand why my mobile app receives a 400 Bad Request when attempting to send a canned response during an active Web Messaging session using the Genesys Cloud Conversations API.
Context:
I am developing a custom iOS client using the Genesys Cloud Web Messaging SDK (v2.1.4). The app successfully initiates chats and handles real-time text messages. However, when an agent selects a canned response from their desktop UI, my mobile app needs to mirror this action or handle the incoming system message correctly. I am trying to programmatically inject a canned response into the conversation thread via the REST API to test synchronization, but the server rejects the payload.
I am using the POST /api/v2/conversations/messaging/{conversationId}/messages endpoint. My authorization header contains a valid OAuth token with the messaging:write scope. The conversation ID is retrieved directly from the SDK’s session object. Here is the cURL equivalent and the JSON payload I am sending:
{
"to": {
"id": "agent-user-id-123",
"type": "user"
},
"from": {
"id": "mobile-app-client-id",
"type": "user"
},
"body": {
"contentType": "text/plain",
"content": "Thank you for contacting support. Your ticket number is #12345."
},
"metadata": {
"source": "canned-response",
"cannedId": "canned-uuid-456"
}
}
Question:
The response body returns:
{
"code": "badRequest",
"message": "Invalid message format: 'to' field must match the conversation's other participant or be a valid routing queue.",
"status": 400
}
I have verified that the to.id is the correct agent user ID associated with the conversation. Is there a specific requirement for the to field when sending messages via the Conversations API in a Web Messaging context? Or should I be using a different endpoint, such as the Interaction Control API, to properly trigger a canned response injection? I am on the America/Sao_Paulo timezone and using the US East region.