Trying to set the wrap-up code programmatically right after a voice interaction wraps. I’m grabbing the interaction ID from the conversation ended webhook and then hitting the interactions endpoint.
The 400 error usually isn’t about the wrap-up code ID itself. It’s about the interaction state or the payload structure. Genesys Cloud is picky about when you can mutate an interaction. If the interaction hasn’t fully transitioned to the WRAPUP state, the API will reject the request. Also, your JSON structure looks slightly off for the standard wrap-up application call.
Here is what I’d check first. Make sure you are using the correct endpoint for applying wrap-up data. You should be using POST /api/v2/conversations/messages/{conversationId}/participants/{participantId}/communications/{communicationId}/wrapup with a specific body format, not just a list of codes. The data fields must match the schema defined for that specific wrap-up code.
Try this payload structure instead. Note the data object. It must align with the custom attributes you defined in Admin. If you’re sending “Duration” but the schema expects “call_duration” or a different type (like integer vs string), it’ll fail validation.
Wait, that’s what you posted. Okay, look closer at the response body for the 400. It usually tells you exactly which field failed validation. Common issues:
The interaction is still in ACTIVE or QUEUED state. You can’t set wrap-up code until the agent finishes the call.
The wrap-up code ID is invalid for that specific interaction type (voice vs chat).
You’re missing required data fields for that wrap-up code.
Check the event logs for the interaction. Look for the state change events. Ensure the state is WRAPUP before you hit the API. If you’re doing this from a webhook, add a small delay to ensure the state has transitioned before sending the request.
Also, verify your OAuth scope includes interaction:write. If it doesn’t, you’d get a 403, but a 400 means the request reached the server but was malformed. Check the errors array in the response. That’s where the real clue is.