Genesys Cloud API: Applying Wrap-up Codes via Conversations API post-interaction

building a Terraform module to automate post-interaction workflows, and we’ve hit a snag with programmatically assigning wrap-up codes. The requirement is to set the wrap-up code immediately after an interaction ends, specifically for voice interactions handled by agents.

I’ve been examining the Conversations API documentation, and the POST /api/v2/conversations/voice/{conversationId}/wrapup endpoint seems to be the correct place to apply these codes. However, the interaction must be in a specific state for this call to succeed. The documentation mentions that the conversation should be in the WRAPPED or CLOSED state, but our automated tests are returning a 409 Conflict error when we attempt to call this endpoint right after the agent clicks ‘Complete’ in the UI.

Here is the JSON payload we are sending:

{
 "wrapUpCode": "Customer_Support_Closed",
 "wrapUpCodeId": "123e4567-e89b-12d3-a456-426614174000"
}

We are authenticating using a service account with the conversation:voice:write scope. The error response body indicates that the conversation is not in a valid state for wrap-up. We suspect there might be a race condition where the API hasn’t fully transitioned the conversation to the WRAPPED state yet.

Is there a recommended polling mechanism or a webhook event we should listen to before making this API call? Alternatively, is there a different endpoint or method to ensure the wrap-up code is applied correctly without manual intervention? We’ve tried waiting for a few seconds, but it’s not reliable in a production environment. Any insights on handling this state transition would be appreciated.

The POST /api/v2/conversations/voice/{conversationId}/wrapup endpoint is indeed the correct path, but the payload structure trips people up. You need to send a JSON body with the wrapupCode object, not just the ID string.

Here’s the exact curl command that works for voice wrap-ups:

curl -X POST "https://api.mypurecloud.com/api/v2/conversations/voice/{conversationId}/wrapup" \
 -H "Authorization: Bearer {access_token}" \
 -H "Content-Type: application/json" \
 -d '{
 "wrapupCode": {
 "id": "your-wrapup-code-id"
 }
 }'

Make sure the wrapupCode object matches the schema. If you pass just the ID at the root level, it fails. Also, verify the agent has the wrapup permission enabled in their role. Without that, the API returns a 403 even if the token is valid.