Notifications
WebSocket
Connect to the v2 WebSocket feed and inspect active connections.
Flow Summary
Use the WebSocket routes like this:
- use
GET /api/v2/wsfor the real app connection - use
GET /api/v2/ws/connected-usersandGET /api/v2/ws/connectionsfor support or operational inspection - keep
GET /api/v2/ws/testdisabled from normal user-facing flows
Routes
GET /api/v2/wsGET /api/v2/ws/connected-usersGET /api/v2/ws/connectionsGET /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
tokenquery parameter for browser-driven flows
Recommended usage
- 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_idis optional and filters the connection list
Success response shape
The current response includes:
connections: the active connection records, optionally filtered byuser_idtotal_count: number of returned connection recordshub_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_statsis 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_iddirectly from the query string - Do not expose this as a normal production user feature
- Treat this as a debug or stress-test route only