Conversations API: Setting wrap-up code on completed interaction returns 400

Docs state: “You can update the wrap-up code for a conversation by sending a PATCH request to the /api/v2/conversations/{conversationId} endpoint.”

I’m trying to automate the assignment of a wrap-up code immediately after an interaction reaches the completed state via webhook. The goal is to ensure our analytics reflect the correct disposition without relying on agent input for system-generated calls.

Here’s the payload I’m sending in the PATCH body:

{
 "wrapUpCode": {
 "code": "WU-001",
 "name": "System Auto-Wrap"
 }
}

The endpoint returns a 400 Bad Request with the message: “The conversation is not in a state that allows updating the wrap-up code.”

I’ve verified the conversationId is correct. The interaction status in the webhook payload is completed. I’ve tried waiting 500ms and 2 seconds before sending the PATCH, assuming there’s a race condition with the state machine transition, but the error persists.

Is the completed state actually readable as closed or something else by the API? Or do I need to use the wrapUp action endpoint instead? The docs don’t explicitly list allowed states for this field update. I’ve checked the ConversationUpdate schema and wrapUpCode seems valid.

Using the Python SDK genesyscloud.conversations_api.update_conversation() yields the same error. Not sure if I’m missing a header or if the timing window is tighter than expected. Any pointers on the correct sequence or endpoint?