Updating wrap-up code via POST /conversations/conversationId/interactions/interactionId/wrap-up returns 400

We’re trying to automate the assignment of wrap-up codes based on specific call outcomes in our workflow. The goal is to push a code to the conversation after the agent clicks end, but before the interaction fully closes out in the queue. I’ve been using the conversations_api.update_conversation_interaction_wrap_up method from the Python SDK, targeting the endpoint /api/v2/conversations/{conversationId}/interactions/{interactionId}/wrap-up. The request body looks standard enough, just specifying the wrap-up code ID we created in the admin console. Here is the JSON payload I am sending:

{
 "wrapUpCodeId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

I can see the interaction ID from the conversation details, and I’ve verified that the wrapUpCodeId matches an active code in our routing configuration. The token I’m using has the interaction:write scope, so permissions shouldn’t be the issue. The call goes through without throwing an authentication error, which is good. But instead of updating the record, I keep hitting a 400 Bad Request. The error message in the response body is vague: {"code": "badRequest", "message": "Invalid wrap up code for this interaction type"}.

I’m stuck because the code exists and is valid for voice interactions. I’ve checked the wrap-up code settings in Genesys Cloud, and it’s definitely enabled and associated with the correct queue. I’ve also tried passing the wrapUpCodeId as a string versus an integer, but the SDK handles the serialization anyway. Is there a timing issue here? Maybe the interaction has to be in a specific state before this endpoint accepts the payload? I’ve read the docs on the Conversations API, but they don’t mention any preconditions for updating the wrap-up code after the fact. It feels like I’m missing a small detail in the request structure or the lifecycle state. Any ideas on what might trigger that specific ‘invalid wrap up code’ error when the code itself is clearly valid?