Trying to send a quick reply card via the Open Messaging API but getting a 400 Bad Request.
The endpoint is https://api.mypurecloud.com/api/v2/conversations/messaging/messages.
Here is the JSON body I’m sending:
{
"mediaType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"content": {
"type": "card",
"title": "Options"
}
}
The response says Invalid mediaType. Not sure what the correct value is for a card message. I’ve tried text/plain but that just sends raw text. Any ideas?
You’re hitting a type mismatch on mediaType. The Open Messaging API expects application/json for structured content like cards, not that Word doc MIME type. Also, the content object needs specific properties depending on the card type you’re trying to render.
Here’s what a valid quick reply card payload looks like in Node using the SDK or direct fetch:
const payload = {
mediaType: "application/json",
content: {
type: "card",
title: "Options",
description: "Choose an option",
quickReplies: [
{ title: "Option 1", type: "text", value: "opt1" },
{ title: "Option 2", type: "text", value: "opt2" }
]
}
};
// Example using fetch
await fetch('https://api.mypurecloud.com/api/v2/conversations/messaging/messages', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify(payload)
});
The mediaType tells the engine how to parse the content. If you send a non-JSON mediaType with a JSON body, it rejects it immediately. Make sure your content object has the required fields for the card type you’re using.