Connection URL
| Environment | URL |
|---|---|
| Production | wss://api.causeloop.ai/v1/stream |
| Local development | ws://localhost:4000/v1/stream |
Authentication
Browsers cannot set theAuthorization header on a WebSocket handshake. Instead, pass your Causeloop Bearer JWT as a query parameter:
workspace parameter — the server validates it matches the workspace claim in the token and rejects cross-tenant subscriptions:
Connection lifecycle
Receive the connected frame
Immediately after accepting, the server sends a
connected frame confirming your workspace and user:Receive event frames
The server pushes domain event frames as they occur. See Event types below.
Frame format
All frames share a common envelope:The event type identifier (see table below).
Event-specific data. Shape varies by event type.
UTC timestamp of when the event was emitted by the server.
Event types
| Type | Trigger |
|---|---|
connected | Sent once immediately after the connection is accepted. |
heartbeat | Sent every 5 seconds to keep the connection alive. |
issue.created | A new issue was ingested from a connector or created via API. |
issue.status.changed | An issue’s status changed (e.g. new → analyzing → resolved). |
pattern.detected | A new pattern was identified or an existing pattern updated. |
prediction.alert.fired | A prediction alert rule triggered. |
recommendation.status.changed | A recommendation was accepted, implemented, or dismissed. |
notification.created | A workspace notification was created for the connected user. |
job.updated | A background report or export job changed status or progress. |
issue.created payload
issue.status.changed payload
pattern.detected payload
job.updated payload
status is "succeeded", result_url is populated with the download path.
Close codes
| Code | Meaning |
|---|---|
4401 | Missing, invalid, or expired token. Re-authenticate and reconnect. |
4003 | Workspace mismatch — the workspace param does not match the token’s workspace claim. |
1001 | Server going away — graceful drain (e.g. deploy). Reconnect immediately. |
1011 | Unexpected server error. Reconnect with backoff. |
Example client
Event bus integration
Server-side routers can push frames directly into the stream using thepublish function (for workspace-wide events) or publish_user (for user-scoped events). This allows any API mutation — creating an issue, updating a recommendation — to fan out a real-time event to all connected clients in that workspace without polling.