Real-time event stream (WebSocket)
Live push of the same events and payloads your webhooks receive, over a plain WebSocket. Use it for dashboards, monitoring, or low-latency reactions without hosting a public HTTPS endpoint.
Connect (same API key as the REST API — no separate credentials):
const WebSocket = require('ws');
const ws = new WebSocket(
'wss://api.hyperprop.com/platform/v1/organization/events/stream',
{ headers: { 'X-API-Key': 'hp_live_...' } }
);
ws.on('message', (raw) => {
const frame = JSON.parse(raw);
if (frame.type === 'event') {
// frame.event is byte-for-byte the same JSON body a webhook POST carries:
// { id, type, createdAt, organizationId, data, previousAttributes, ... }
console.log(frame.event.type, frame.event.data.accountNumber);
}
});
Clients that cannot set headers may pass ?api_key=hp_live_... in the URL instead.
Frames you receive:
| Frame | Meaning |
|---|---|
{ "type": "connected", "organizationId", "serverTime" } | Sent once after a successful connect |
{ "type": "event", "event": { ... } } | A live event — event matches the webhook payload schema exactly |
{ "type": "event.replay", ... } | Slim catch-up event when you connect with ?since= (id, eventType, accountId, reason, createdAt) |
{ "type": "replay.complete", "count", "truncated" } | Catch-up finished; truncated: true means more than 1000 events matched — reconnect with a later since |
{ "type": "pong" } | Reply to your { "type": "ping" } |
Catch-up after a disconnect: reconnect with ?since=<ISO timestamp> (e.g. ?since=2026-07-21T10:00:00Z) to receive slim replays of events you missed, oldest first, then live events resume. Replay frames carry identifiers only — fetch full account state via GET /platform/v1/organization/trading-accounts/{id} if needed.
Delivery guarantees: the stream is a live, best-effort channel. Webhooks remain the guaranteed channel with retries, HMAC signing, and redelivery — keep them registered for anything money-critical and treat the stream as the low-latency mirror.
Keep-alive: the server pings every 30 seconds; standard WebSocket libraries answer automatically. Idle connections that miss pongs are dropped. You may also send {"type":"ping"} and receive {"type":"pong"}.
Limits: maximum 10 concurrent stream connections per organization.
Authentication: two modes are accepted:
- API key —
X-API-Key: hp_live_...header (preferred for server integrations) or?api_key=query parameter. - Member session —
Authorization: Bearer <jwt>header or?token=<jwt>query parameter (browsers cannot set WebSocket headers). Any active member of the organization may subscribe; this is what powers the real-time admin portal.
Authorizations
JWT Bearer token for user session auth. Format: "Bearer {token}". Used by User and Organization endpoints.
Response
Switching Protocols — the WebSocket handshake succeeded. The first frame is { "type": "connected", "organizationId", "serverTime" }, then event frames follow (see notes for the full frame table).
Related topics
WebSocket Stream (Documentation Only)Real-time WebSocket for trading eventsGet open positions with real-time P&LRate limits & quotasRegister a webhook endpoint