meta { name: WebSocket - Connect and Receive Updates type: websocket seq: 1 } vars { token: "" } websocket { url: {{base_url}}/ws/sync?token={{token}} body: { type: "ping", timestamp: "2026-01-30T20:00:00Z" } auth: inherit } headers { Authorization: Bearer {{token}} } script:post-response { function onResponse(res) { tests('Status is 101 (Switching Protocols)', res.getStatus() === 101); const headers = res.getHeaders(); const connection = headers.get("Connection"); const upgrade = headers.get("Upgrade"); tests('Connection header has upgrade', connection && connection.toLowerCase().includes("upgrade")); tests('Upgrade header is websocket', upgrade && upgrade.toLowerCase().includes("websocket")); } onResponse(res); } settings { encodeUrl: true timeout: 0 } docs { ## WebSocket - Connect and Receive Updates Establishes a WebSocket connection for real-time sync updates. **Type:** WebSocket **Endpoint:** /ws/sync?token={token} **Authentication:** Bearer token (via query parameter) **Query Parameters:** - `token` (string): JWT access token **Request Body:** - `type` (string): Message type (ping, subscribe, unsubscribe) - `timestamp` (string): ISO 8601 timestamp **Expected Response:** - Status: 101 Switching Protocols - Headers: - `Connection`: upgrade - `Upgrade`: websocket **Status Codes:** - 101: Switching Protocols - WebSocket established - 401: Unauthorized - 500: Internal server error **Note:** WebSocket connection allows real-time push notifications for sync updates, progress changes, and device activity. }