Setting wrap-up codes via Conversations API returns 409 Conflict

We’re building a custom agent desktop widget using the Embeddable Client App SDK. The goal is to programmatically set a wrap-up code after a conversation ends, rather than relying on the standard UI. I’ve been using the PUT /api/v2/conversations/{conversationId} endpoint to update the interaction details.

Here is the payload I’m sending:

{
 "wrapUpCode": {
 "id": "c1a2b3d4-5678-90ab-cdef-1234567890ab"
 }
}

The request fails with a 409 Conflict status. The error message says “Conversation is not in a state that allows this operation.” I’ve verified the conversation ID and the wrap-up code ID are valid. The conversation status is closed on the client side, but it seems the server still considers it active or pending for a few seconds.

I’ve tried adding a 5-second delay before making the API call, but it still fails. Is there a specific event in the SDK I should listen for to know when the conversation is fully closed on the server side? Or is there a different endpoint I should be using to set the wrap-up code? The documentation isn’t clear on the exact timing for this operation.

Any help would be appreciated. I’m stuck on this for a day now.

You’re hitting a 409 because the conversation state doesn’t match. The API expects the interaction to be in WRAPUP or COMPLETED before you can persist that code. Check the current state first. If it’s still active, you’ll need to transition it manually via the SDK or wait for the standard flow to finish.