Setting wrap-up codes via Conversations API after interaction ends

I’m working on a script to automatically assign wrap-up codes after an interaction ends. The goal is to update the conversation object with the correct wrap-up code based on some post-call logic. I’ve tried using the POST /api/v2/conversations/{conversationId}/wrapup endpoint, but it returns a 400 Bad Request with the message ‘Wrap-up code is not valid for this interaction type.’

Here’s the JSON payload I’m sending:

{
 "wrapupCode": "SurveySent",
 "durationMs": 30000
}

I’ve verified that the wrap-up code exists in the tenant and is enabled. I’m also using the correct conversation ID and ensuring the interaction has actually ended before making the API call. I’ve checked the documentation, and it seems like the endpoint should work for call interactions.

I’ve also tried using the conversations_api.create_conversation_wrapup method from the Python SDK, but it results in the same error. The interaction type is CALL, and the wrap-up code is set up for CALL interactions.

Has anyone encountered this issue? Is there something I’m missing in the payload or the API call? Any help would be appreciated.

You’re likely hitting the interaction type mismatch. Voice calls need wrapupCode from the wrapup code set, not just a raw string. Check the conversation’s interactionType first.

{
 "wrapupCode": "Survey Complete",
 "wrapupCodeId": "your-code-set-id"
}

Verify the ID matches the set linked to your queue.

Are you pulling the wrapup code set ID from the queue config or hardcoding it? That 400 usually screams mismatched metadata. ’s on the right track, but you’ll also need to ensure the wrapupCode string exactly matches the name in the code set, case-sensitive. The API doesn’t do fuzzy matching here.

Here’s how I handle it in my desktop app logic. First, fetch the active code set from the queue details, then map your logic to the correct ID.

# Python example using PureCloudPlatformClientV2
from purecloudplatformclientv2 import ConversationsApi

api_instance = ConversationsApi()

# Ensure you have the correct wrapup_code_id from the queue's wrap_up_code_set
wrapup_body = {
 "wrapup_code": "Survey Complete", # Must match the code set entry exactly
 "wrapup_code_id": "8f3a2b1c-4d5e-6f7g-8h9i-0j1k2l3m4n5o" # From /api/v2/queues/{queueId}
}

try:
 api_instance.post_conversations_conversation_wrapup(conversation_id="abc-123", body=wrapup_body)
except Exception as e:
 print(f"Failed: {e.body}")

If the code set isn’t linked to the queue, the endpoint rejects it outright. Check the queue wrapper first.

Heads up on that approach. If you’re automating this via API, ensure your service account has the conversation:wrapup:write scope. Also, double-check the queue’s wrapup code set ID. It’s easy to grab the wrong one if you have multiple sets configured. The API is strict about the ID matching the queue’s active set.