Notifications

WebSocket

Connect to the v2 WebSocket feed and inspect active connections.

Flow Summary

Use the WebSocket routes like this:

  • use GET /api/v2/ws for the real app connection
  • use GET /api/v2/ws/connected-users and GET /api/v2/ws/connections for support or operational inspection
  • keep GET /api/v2/ws/test disabled from normal user-facing flows

Routes

  • GET /api/v2/ws
  • GET /api/v2/ws/connected-users
  • GET /api/v2/ws/connections
  • GET /api/v2/ws/test

1. Open Authenticated WebSocket

GET /api/v2/ws

Upgrades the connection to the main WebSocket feed.

Auth options

  • Normal bearer auth is supported
  • The handler also accepts an optional token query parameter for browser-driven flows
  • mobile apps or backend-controlled clients should prefer the normal Authorization: Bearer <access_token> flow
  • browser-based connection helpers can use ?token=<access_token> because browser WebSocket clients cannot always attach custom auth headers cleanly

Connection behavior

  • the backend first resolves the current authenticated mobile_user_id
  • if the same user already has an older active WebSocket connection, the backend disconnects the old connection and keeps only the newest one
  • if WebSocket support is disabled in server config, the route returns 503

Browser example

wss://api.example.com/api/v2/ws?token=<access_token>

2. Get Connected Users

GET /api/v2/ws/connected-users

Returns the list of currently connected users.

Success response shape

{
  "status_code": 200,
  "message": "Success",
  "data": {
    "connected_users": [
      "10001",
      "10002"
    ],
    "count": 2
  }
}

Notes

  • this route is useful for support dashboards and operational checks
  • the returned user IDs are string values in the current handler response

3. Get Connection Details

GET /api/v2/ws/connections

Returns detailed information about active WebSocket connections.

Query parameter

  • user_id is optional and filters the connection list

Success response shape

The current response includes:

  • connections: the active connection records, optionally filtered by user_id
  • total_count: number of returned connection records
  • hub_stats: aggregate hub distribution data when available from the current hub manager

Notes

  • use this route when support teams need more detail than the simple connected-user list
  • hub_stats is operational data and may change shape if the hub implementation changes

4. Test WebSocket Endpoint

GET /api/v2/ws/test

Stress-test helper endpoint.

Important warning

  • The handler comments explicitly say this route does not require auth
  • It accepts user_id directly from the query string
  • Do not expose this as a normal production user feature
  • Treat this as a debug or stress-test route only
Copyright © 2026