Trying to force-close an active Web Messaging session from our Python backend to reset the guest context. The standard way to update a participant via /api/v2/conversations/{conversationId}/participants/{participantId} 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.
1 Like
You’re looking at the wrong endpoint. Use the API to terminate the conversation 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}")
2 Likes
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.