Setting wrap-up codes via Genesys Cloud API after interaction ends

I’m building a C# service that needs to apply specific wrap-up codes to interactions after they conclude. We’ve got a custom workflow that processes the call data and determines the correct code based on certain business rules. I tried using the PUT /api/v2/conversations/{conversationId} endpoint with the wrapUpCode field in the request body, but it returns a 400 Bad Request error. The error message says “Invalid wrap-up code” even though the code ID exists in our Genesys Cloud instance. Here’s the JSON payload I’m sending:

{
 "wrapUpCode": {
 "id": "12345678-1234-1234-1234-123456789012"
 }
}

I’ve also tried using the PATCH method with the same payload, but that doesn’t work either. The conversation is already in a terminated state when I make the request. I’m not sure if there’s a different endpoint or a specific sequence I need to follow to apply the wrap-up code programmatically. Any ideas on what I might be missing?

You can’t use the generic conversations endpoint. You need to hit the specific wrap-up endpoint for the interaction type, like PUT /api/v2/interactions/{id}/wrapsup.

PUT /api/v2/interactions/{id}/wrapsup
Content-Type: application/json

{
 "wrapupCode": {
 "id": "your-code-id"
 }
}