Why does this setting... cause WebSocket disconnects during Notification API subscription?

We are building a Terraform module that configures real-time monitoring for Genesys Cloud. The backend service subscribes to /api/v2/analytics/events via WebSocket using a valid OAuth2 token. However, the connection terminates immediately with a close code 1006. Why does this setting… in the subscription request body trigger an unexpected disconnect before any events are streamed? Is there a specific payload structure required for the initial handshake that differs from standard REST calls?

this looks like a payload validation issue rather than a network problem. the close code 1006 usually means the server sent an error response that the client couldn’t parse as a proper close frame, or the connection was abruptly killed due to a malformed subscription request. in my experience building dashboards with genesyscloud-platform-client-sdk, the most common culprit is an invalid eventTypes array or missing filters structure in the initial post to /api/v2/analytics/events.

check your subscription body. the server expects a specific json structure. if you pass eventTypes as a string instead of an array, or if you include an unsupported event type like conversation:created without the proper scope, the server rejects it immediately.

here is a minimal valid payload using curl to test the handshake before your terraform module applies it:

curl -X POST "https://api.mypurecloud.com/api/v2/analytics/events" \
 -H "Authorization: Bearer $TOKEN" \
 -H "Content-Type: application/json" \
 -d '{
 "eventTypes": ["conversation:updated", "interaction:updated"],
 "filters": {
 "divisions": ["self"]
 }
 }'

also, ensure your oauth token includes analytics:events:read. if the token lacks this scope, the server closes the connection silently or with a generic error. if you are using the js sdk, look at analyticsApi.createEventSubscription(). it handles the websocket upgrade automatically, but you must pass the filters object correctly.

another thing to check is the pageSize or interval if you are mixing aggregate queries with event streams. they are different endpoints. /api/v2/analytics/events is for real-time streams. do not send aggregate query parameters there.

if the disconnect persists, enable debug logging on your websocket client. you should see a 400 Bad Request or 403 Forbidden before the 1006 close. fix the payload structure first. the server is strict about json schema validation on the initial post.

have you tried validating your subscription payload against the strict schema? the docs state that “the eventTypes array must contain valid identifiers” but many implementations ignore the required filters object. if you send an empty or malformed filter, the server drops the connection with code 1006 because it cannot establish the query context. this is not a network issue. it is a protocol violation.

{
 "eventTypes": [
 "routing.queueMemberEvent",
 "routing.wrappingEvent"
 ],
 "filters": {
 "routing.queueMemberEvent": [
 {
 "field": "queueId",
 "operator": "in",
 "values": ["your-queue-id-here"]
 }
 ]
 }
}

ensure your oauth token has the analytics:events:read scope. also, check that your client handles the initial heartbeat correctly. if you are using the java sdk, verify that the websocket client is not closing on the first text frame. i see this often when developers copy-paste examples without adjusting the filter logic.

The problem is likely that an incomplete filters object in your WebSocket subscription payload, causing the server to reject the handshake. Ensure your Go client sends a valid filter structure like this to prevent the 1006 close code:

subscription := platformclientv2.Eventssubscription{
 EventTypes: []string{"routing.queueMemberAdded"},
 Filters: &platformclientv2.Eventssubscriptionfilters{
 QueueId: &queueID,
 },
}

To fix this easily, this is to ensure the filters object is strictly defined.

  • Use routing.queueMemberAdded in eventTypes.
  • Include queueId in filters.
  • Validate payload against schema before sending.
    This prevents 1006 errors from malformed subscriptions.