Terraform: Can't set wrap-up codes on closed interactions via API

I’m building out a Terraform module to automate our post-interaction workflows, and I’ve hit a wall with the Conversations API. Specifically, I need to programmatically assign a wrap-up code after a voice interaction ends. My understanding is that I should use the POST /api/v2/conversations/voice/{id}/wrapup endpoint.

Here’s the payload I’m sending:

{
 "code": "WU-001",
 "description": "Call completed successfully"
}

The interaction ID is valid, and the call is already in the closed state. I’m getting a 409 Conflict back with the message “Interaction is not in a state that allows wrap-up”. I’ve double-checked the state transitions in the docs, and closed seems like the right spot for this.

Is there a specific timeout window I’m missing? Or does the API require the interaction to be in queued or connected before it locks down? I’ve tried waiting 30 seconds after the hangup, but no luck. The Terraform provider doesn’t seem to have a resource for this yet, so I’m using a local-exec with curl for now.

Any ideas on what state the API actually expects here?