Hey everyone.
I’m hitting a snag with the wrap-up code assignment flow in our Node.js integration. We have a custom backend service that processes interaction metadata and decides on the final disposition code based on complex business logic that lives outside the Genesys Cloud environment. The goal is to programmatically set the wrap-up code on a conversation right after it ends, or at least trigger the wrap-up state so the agent can select from a pre-filtered list.
The docs mention the /api/v2/conversations endpoint, but I’m confused about the exact method and payload required to actually set the wrap-up code via API, especially since the conversation state machine is strict. I tried sending a PATCH request to /api/v2/conversations/{conversationId} with a simple payload, but it just returns a 400 Bad Request saying the action is invalid for the current state.
Here’s the snippet I’m using in my Node service:
const response = await fetch(`https://{orgHost}.mygen.com/api/v2/conversations/${convId}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
wrapUpCode: {
id: 'my-custom-wrapup-code-id'
}
})
});
The error response is pretty generic:
{
"code": "invalidArgument",
"message": "Invalid action for conversation state"
}
I know I can’t just force a wrap-up code if the conversation is still in the ACTIVE state. But once the state is ENDED, shouldn’t I be able to set it? Or do I need to use the Interaction Control API differently? I’ve also looked at the postWrapUp action in the interaction control, but that seems to be for triggering the UI flow, not setting the value directly.
Is there a specific endpoint or body structure I’m missing? I’ve tried adding wrapUpCode to the actions array in a POST /api/v2/conversations request, but that’s for initiating interactions, not modifying ended ones.
Any pointers on the correct API call sequence?