Connect to event store via WebSocket
GET /api/event-stores/{eventStoreName}/events/ws
Establish a WebSocket connection to receive real-time events from an event store.
This endpoint implements the WebSocket protocol (RFC 6455) to provide a streaming connection of events. The HTTP connection is upgraded to a WebSocket connection, allowing for real-time bidirectional communication.
Connection Process:
- Connect to this endpoint using a WebSocket client (browser WebSocket API or library)
- The connection is upgraded from HTTP to WebSocket
- Events matching the filter will stream to the client in real-time
- The connection remains open until closed by either party
Event Filtering:
The filter query parameter accepts a JSON string that defines which events the client wants to receive. The filter can include:
type: Match specific event types (e.g., “user.created”)streamId: Match events from specific streamsdata: Match specific fields in the event datametadata: Match specific fields in the event metadata
Example filters:
// Match user creation events
{
"type": "user.created"
}
// Match events from a specific stream with metadata
{
"streamId": "users-123",
"metadata": {
"source": "api"
}
}
// Match events with specific data fields
{
"type": "order.updated",
"data": {
"status": "completed"
}
}
// Complex filter combining multiple criteria
{
"type": "payment.processed",
"streamId": "orders-456",
"data": {
"amount": 100
},
"metadata": {
"region": "us-east"
}
}
If no filter is provided, the client will receive all events. If there’s an error parsing the filter, the client will also receive all events (with an error logged).
Authentication:
- Use the optional
authTokenparameter if authentication is required - Tokens should be obtained from your authentication system
Note: This endpoint is designed for WebSocket clients, not regular HTTP requests.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Event store name (automatically scoped to your organization)
Event store name (automatically scoped to your organization)
Query Parameters
Section titled “Query Parameters ”Unique identifier for the client
Unique identifier for the client
Authentication token
Authentication token
JSON string containing filter criteria for events. Can include type, streamId, data, and metadata matching.
JSON string containing filter criteria for events. Can include type, streamId, data, and metadata matching.
Where to start receiving events from (defaults to “latest”)
Where to start receiving events from (defaults to “latest”)
Responses
Section titled “ Responses ”Switching Protocols - WebSocket connection established
Invalid request parameters
object
Error type
Human-readable error message
Additional error details
object
Examples
{ "error": "MISSING_CLIENT_ID", "message": "A client ID is required"}{ "error": "INVALID_FILTER", "message": "The provided filter JSON is invalid or malformed", "details": { "filter": "{\"type\": \"user.created\", malformed: true}", "parseError": "Unexpected token m in JSON at position 31" }}Authentication failed
object
Error type
Human-readable error message
Additional error details
object
Examples
{ "error": "INVALID_AUTH_TOKEN", "message": "The provided authentication token is invalid or expired"}Event store not found
object
Error type
Human-readable error message
Additional error details