WebSocket notification subscription timing out before sending auth token

We are trying to establish a persistent WebSocket connection to /api/v2/analytics/conversations/realtime using the Python websockets library. The goal is to capture real-time conversation events for our Terraform-based audit logging pipeline.

The connection to the server succeeds, but the handshake fails immediately after. We send the auth message with the OAuth bearer token as per the documentation, yet the server closes the connection with a 1000 status code and no payload.

Here is the relevant snippet:

async with websockets.connect(url) as websocket:
 auth_msg = json.dumps({
 'type': 'auth',
 'token': access_token
 })
 await websocket.send(auth_msg)
 response = await websocket.recv()
 print(response)

The access_token is valid; we use it successfully for REST calls in the same script. We are in the Europe/Berlin timezone, so latency shouldn’t be an issue. Is there a specific header required during the initial HTTP upgrade request? Or does the order of operations matter more than we think? The docs are vague on the exact timing window.