Hey folks,
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.
Here’s the payload I’m sending:
{
"wrapupCodes": [
{
"id": "my-wrapup-code-id-from-lookup",
"data": [
{
"name": "Duration",
"value": "120"
}
]
}
]
}
I’m getting a 400 Bad Request back. The error message is just generic: Validation failed.
I’ve confirmed the ID exists and is active. I’ve even tried sending just the ID in the array without the data field, same result.
The documentation says this endpoint accepts an array of wrapup codes, but it feels like it wants something else or maybe the timing is off?
Any ideas on what I’m missing?
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 putInteraction call.
Here is what I’d check first. Make sure you are using the correct endpoint for updating wrap-up data. You should be using PUT /api/v2/interactions/{id} with a specific body format, not just a list of codes. The wrapupCodes array needs to be part of the interaction object, and the data fields must match the schema defined for that specific wrap-up code.
Try this payload structure instead. Note the data object inside each code. 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.
{
"wrapupCodes": [
{
"id": "my-wrapup-code-id-from-lookup",
"data": [
{
"name": "Duration",
"value": "120"
}
]
}
]
}
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 interaction.stateChange event. Ensure the state is WRAPUP before you hit the API. If you’re doing this from a webhook, add a small delay or use the POST /api/v2/interactions/{id}/wrapup endpoint directly if available in your version, though the PUT method is more standard now.
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.