POST /conversations/interactions/{id}/wrap-up returns 404 after InteractionControl API call

Problem

We’re instrumenting our Genesys Cloud Data Actions with OpenTelemetry. The goal is to capture the exact moment an interaction transitions to wrap-up so we can close the root span.

The flow triggers a custom Data Action via a web action node. The code calls the Interaction Control API to end the interaction, then immediately attempts to set the wrap-up code.

Code Snippet

# End interaction
end_resp = client.interactions_api.post_interactions_control(interaction_id, body={'status': 'completed'})

# Set wrap-up code
wrap_body = {'wrapUpCodeId': 'my-wc-id-123'}
wrap_resp = client.interactions_api.post_interactions_wrap_up(interaction_id, body=wrap_body)

Error

The first call succeeds. The second call throws a 404 Not Found error.

genesyscloud.api_client.ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Wed, 15 May 2024 08:30:00 GMT'})
HTTP response body: {"errors":[{"code":"notFound","message":"Interaction not found or not in wrap-up state"}]}

The interaction definitely exists. It just ended. I’ve tried adding a 2-second sleep between calls. Same result.

Is there a race condition in the state machine? Or do I need to poll for a specific status before calling the wrap-up endpoint?

You’re hitting the 404 because the interaction is still in post-call state when the wrap-up call fires. The Interaction Control API doesn’t sync instantly. Add a retry loop or wait for the interaction:updated event with state: "wrap-up" before sending the code.