Programmatically closing Web Messaging session via backend API

Trying to force-close an active Web Messaging session from our Python backend to reset the guest context. The standard POST /api/v2/conversations/messaging/participants/{participantId} endpoint works for general messaging, but it doesn’t seem to terminate the WebSocket connection for web chat guests. Is there a specific API call or payload flag that triggers an immediate disconnect? Currently getting a 200 OK but the session remains active on the frontend. Need this for our tracing pipeline.

You’re looking at the wrong endpoint. Use DELETE /api/v2/conversations/messaging/{conversationId} to actually tear down the session, not just update a participant.

import purecloudplatformclientv2 as pcc

api_instance = pcc.ConversationsApi(pcc.ApiClient())
try:
 api_instance.delete_conversations_messaging_conversation(conversation_id)
 print("Session terminated.")
except pcc.rest.ApiException as e:
 print(f"Failed: {e.status} {e.reason}")

The DELETE endpoint only marks the conversation as closed in the database. It doesn’t kill the WebSocket connection on the client side. You need to send a specific close event via the participant endpoint or handle it in your frontend logic.