Skip to main content

Real-Time Stream API

Subscribe to a live stream of score updates, new events, and surge alerts as they happen. This endpoint uses Server-Sent Events (SSE) to push data to connected clients in real time.

GET /stream

Open a persistent SSE connection to receive real-time updates for the active Organizational Unit.

Request

No query parameters required. The connection remains open until the client disconnects.

Response

200 OK (Content-Type: text/event-stream)

The server sends JSON-encoded messages as SSE events. Each message includes a type field indicating the kind of update.

Message Types

TypeDescription
score_updateA lead's score changed
new_eventA new engagement event was ingested
surgeA surge was detected for an account

Message Fields

Score Update:

FieldTypeDescription
typestringscore_update
lead_idstringLead whose score changed
scoreintegerUpdated score value

New Event:

FieldTypeDescription
typestringnew_event
eventobjectFull event object (see Events)

Surge Alert:

FieldTypeDescription
typestringsurge
surgeobjectSurge event details

Example

curl -N "https://api.leadvibe.com/stream" \
-H "Authorization: Bearer <token>"

Example output:

data: {"type":"score_update","lead_id":"ld_abc123","score":85}

data: {"type":"new_event","event":{"event_id":"evt_001","lead_id":"ld_abc123","event_type":"page_view","timestamp":"2025-09-15T14:30:00Z"}}

data: {"type":"surge","surge":{"account_id":"acct_xyz","event_count":47}}

Common Errors

StatusMeaningSolution
400Bad RequestActive OU must be set before connecting
401UnauthorizedCheck authentication credentials

Notes

  • The stream is OU-scoped -- you only receive updates for the active Organizational Unit
  • The connection uses SSE (Server-Sent Events), which automatically reconnects if interrupted
  • Keep-alive messages are sent periodically to maintain the connection
  • For browser-based clients, use the native EventSource API or a library that supports SSE
  • Multiple clients can subscribe simultaneously; each receives the same updates
  • Events - List events with pagination
  • Score - Get current score for a lead