Programmatically terminating web messaging session via guest api

looking for advice on how to cleanly close a web messaging session from the backend. we are building an outbound engagement flow where our bot initiates contact via open messaging. once the interaction is complete, we need to force-close the session on the guest side without relying on the client SDK to emit the hangup event.

i have tried sending a hangup event through the outbound webhook, but the session remains active in the analytics dashboard and the guest can still type messages. the documentation suggests that the guest sdk handles the lifecycle, but i need a server-side trigger for compliance reasons.

here is the event payload i am posting to /api/v2/conversations/messaging/events:

{
 "conversationId": "conv-12345",
 "participantId": "guest-67890",
 "type": "hangup",
 "timestamp": "2024-05-20T14:30:00.000Z"
}

the api returns a 204 No Content, which implies success, but the conversation state in genesys cloud stays as connected. i also tried calling the internal rest proxy from a studio snippet, but that seems to require the guest to be on the line to initiate the close.

is there a specific api endpoint in the guest api or the conversations api that allows a platform user to force-terminate a messaging session? i have checked the POST /api/v2/conversations/messaging/{conversationId}/participants/{participantId}/events endpoint, but it only accepts message or typing events.

i am running this on a server in berlin, so timezone skew is not the issue. the oauth token is valid. any ideas on how to programmatically kill this session?

Oh, this is a known issue with outbound flows. The guest API does not expose a direct termination endpoint for active sessions. You must trigger the closure from the routing side. Use the Python SDK to send a hangup event via routing_conversations_messaging_post with the correct participant ID. This forces the backend to mark the conversation as resolved, syncing analytics immediately.

from purecloudplatformclientv2 import RoutingConversationsApi, HangupEvent

api_instance = RoutingConversationsApi(platform_client)
body = HangupEvent(reason="customer_initiated")
api_instance.post_routing_conversations_messaging_conversation_id_hangup(conversation_id, body)