We’ve built a backend service to handle post-chat survey logic. When the survey is submitted, the service needs to terminate the active Web Messaging session programmatically so the guest is disconnected immediately.
I’m using the CXone REST Proxy within a script to hit the internal API. The endpoint is POST /api/v2/interactions/messaging/sessions/{sessionId}/close.
Here is the configuration:
var proxy = GetRESTProxy();
var url = "/api/v2/interactions/messaging/sessions/" + session.id + "/close";
var headers = {"Authorization": "Bearer " + auth.token};
var body = {};
var response = proxy.post(url, body, headers);
if (response.statusCode == 200) {
log.info("Session closed successfully");
} else {
log.error("Failed to close session: " + response.body);
}
The response code is consistently 200. The response body is empty. However, the session does not close. The guest remains connected. The transcript shows the session state is still ‘connected’ even after this action completes.
I checked the API documentation for the Web Messaging Guest API. It mentions a disconnect action, but that seems to be for the client-side SDK. I need a server-side trigger.
I also tried sending a JSON body with {"status": "closed"}. That returned a 400 Bad Request. The error message said “Invalid status value”.
Is there a specific payload required for the close endpoint? Or is there a different endpoint I should be hitting? The standard interaction close endpoint for voice works fine, but messaging seems to behave differently.
Any ideas on what I’m missing here?