WebSocket Streaming

Live equipment status, alarms, events and messages.

Connect

The socket is at /ws on the gateway (not under /api/v1). Authenticate during the upgrade with an X-API-Key header, an Authorization: Bearer header, or, from a browser, a token query parameter. Browser origins must be on the gateway’s websocket.allowed_origins list.

javascript
const ws = new WebSocket(`ws://gateway:8080/ws?token=${accessToken}`);

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    payload: { topics: ["equipment", "alarms", "events"] }
  }));
};

ws.onmessage = (e) => {
  const { type, timestamp, payload } = JSON.parse(e.data);
};

Topics

Messages arrive only for topics you subscribe to: equipment, alarms, events, messages. unsubscribe takes the same payload.

Subscribe with equipment_id in the payload to receive one tool’s traffic; messages that name no tool, such as the heartbeat, still arrive.

Message types

TypePayload fields
equipment_status, equipment_connected, equipment_disconnectedequipment_id, name, status, communication_state, control_state
alarm_raised, alarm_cleared, alarm_acknowledgedalarm_id, equipment_id, alarm_code, alarm_text, severity, is_set, timestamp
collection_eventevent_id, equipment_id, ceid, event_name, reports, timestamp
secs_message, secs_responsemessage_id, equipment_id, stream, function, w_bit, direction, timestamp
heartbeatserver_time, every 30 seconds

GraphQL subscriptions

GraphQL subscriptions at /api/v1/graphql/ws deliver equipment status, alarms, events and messages live, scoped to your tenant.

Something missing or wrong on this page? Tell us.