Trying to set a wrap-up code after a voice interaction ends using PATCH /api/v2/conversations/voice/{id}. The request body includes {"wrapUpCode": {"id": "..."}} but I keep getting a 409 Conflict error. Is this endpoint actually disabled for terminated sessions or is there a specific state check I’m missing?
That 409 isn’t about the endpoint being disabled. It’s about the conversation state. You can’t PATCH a voice conversation once it hits TERMINATED. The API locks it down to prevent race conditions on historical data. You need to hook into the CONVERSATION_STATE event stream or use the Agent Desktop SDK callbacks to catch the ENDED state before the system marks it terminated.
If you’re building a custom desktop app, listen for the wrap-up window. Here’s how you’d structure the call using the JS SDK just before the session fully closes:
const patchBody = {
wrapUpCode: { id: "your-code-id-here" }
};
await platformClient.ConversationsApi.patchVoiceConversation(
conversationId,
patchBody
);
Timing is everything here. If you wait until the UI shows “Wrap Up” in grey, it’s usually too late. Check the state property in the conversation object. It must still be ACTIVE or ENDED but not TERMINATED. If it’s already terminated, you’re out of luck with this endpoint and need to look at analytics reporting instead.