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: fill.created is delivered at least once while you are connected, independently of your webhook configuration or webhook endpoint health. A fill can occasionally arrive a few seconds late, and duplicates are possible — dedupe on data.orderId. Fill replay via ?since= is complete regardless of webhook subscription state. Other event types on the stream are live best-effort with ?since= catch-up; webhooks remain the durable channel with retries, HMAC signing, and redelivery for anything money-critical.
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: your organization API key — X-API-Key: hp_live_... header (preferred) or the ?api_key= query parameter for clients that cannot set WebSocket headers.
Authorizations
Organization API key. Format: "hp_live_{key}". Organization admins manage the key in the dashboard.
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).