Setting wrap-up codes via API after interaction ends?

Hey folks,

Trying to push a wrap-up code to Genesys Cloud automatically once an interaction wraps. I’m hitting POST /api/v2/conversations/{conversationId}/wrapup with a basic payload:

{
 "wrapUpCode": { "id": "123" }
}

Getting a 400 Bad Request saying the interaction isn’t in the right state. Is there a specific endpoint or timing trick to get this to stick? The UI does it fine, but the API seems fussy.