PATCH /api/v2/interactions/instances/{id} 409 Conflict on wrap-up code update

Trying to set wrap-up codes programmatically right after an interaction ends. The UI shows the wrap-up screen, but we need to force specific codes via API for analytics consistency. I’m using the Python SDK to hit PATCH /api/v2/interactions/instances/{id}. The interaction status is ended when I make the call. Here’s the payload:

{
 "": {
 "wrapupcodes": [
 {
 "id": "my-wrapup-code-id",
 "score": 5
 }
 ]
 }
}

I get a 409 Conflict with message Interaction is not in a state that allows this operation. The docs imply you can update data post-interaction, but the API seems locked down. I’ve tried waiting 5 seconds after the interaction.ended webhook fires, no luck. Is there a specific status like closed I need to wait for, or is this endpoint completely read-only once the agent hangs up? The interaction.update method in the SDK doesn’t seem to have a dedicated flag for wrap-ups either.

The 409 usually means the interaction is still locked by the agent’s session. You need to wait for the interaction.ended webhook to fire before attempting the patch. Also, fix that JSON structure. It should look like this:

{
 "wrapupcodes": [
 {
 "id": "my-wrapup-code-id",
 "score": 5
 }
 ]
}

Check the error message for the specific lock reason.