Subscribe to flag change events
Server-Sent Events (SSE) endpoint for real-time flag change notifications.
Overview
This endpoint establishes a long-lived SSE connection that streams flag change events in real-time. Use this to keep your application's flag values synchronized without polling.
Connection Behavior
- Long-lived connection: The connection remains open indefinitely until closed by the client
- Automatic filtering: Events are filtered to only include changes for the environment associated with your API key
- Heartbeat: A heartbeat event is sent every 15 seconds to keep the connection alive and detect stale connections
Event Types
flag-updated Event
Sent when a single flag is created, updated, or deleted.
event: flag-updated
data: {"flagKey":"my-feature","timestamp":"2024-01-21T10:30:45.123Z"}
id: 1705844445123
| Field | Type | Description |
|---|---|---|
flagKey | string | The key of the flag that changed. |
timestamp | string | ISO 8601 timestamp of when the change occurred. |
id | string | Event ID in epoch milliseconds. Use for client-side ordering and deduplication. |
config-updated Event
Sent when configuration changed that may affect multiple flags. Clients should re-evaluate all flags.
event: config-updated
data: {"reason":"segment-modified","timestamp":"2024-01-21T10:30:45.123Z"}
id: 1705844445123
| Field | Type | Description |
|---|---|---|
reason | string | Why the configuration update occurred. |
timestamp | string | ISO 8601 timestamp of when the change occurred. |
id | string | Event ID in epoch milliseconds. Use for client-side ordering and deduplication. |
Possible reason values:
segment-modified- A segment rule was created, updated, or deletedapi-key-rotated- API key was regenerated
heartbeat Event
Sent every 15 seconds to keep the connection alive.
event: heartbeat
data: {}
No action required from clients. This event helps detect stale connections and prevents proxy timeouts.
curl (Testing)
curl -N -H "X-API-Key: your-api-key" \
https://your-server/api/v1/flags/events
Header Parameters
Environment API key for authentication. Required for establishing the SSE connection.
Client IP address (set by reverse proxy)
Response Body
text/plain
text/plain
curl -X GET "https://loading/api/v1/flags/events""string""string"API Reference
Flipswitch REST APIs
Evaluate all flags
Evaluate all feature flags for the given context. ## ETag Caching This endpoint supports ETag-based caching to reduce bandwidth and improve performance for polling clients. ### How it works 1. **First request**: Call without `If-None-Match` header. Response includes an `ETag` header. 2. **Subsequent requests**: Include the `If-None-Match` header with the previous `ETag` value. 3. **If flags unchanged**: Server returns `304 Not Modified` with no body. 4. **If flags changed**: Server returns `200 OK` with new flag values and a new `ETag`. ### Example flow ``` # First request POST /ofrep/v1/evaluate/flags X-API-Key: your-api-key Response: 200 OK ETag: "abc123" { "flags": [...] } # Subsequent request with ETag POST /ofrep/v1/evaluate/flags X-API-Key: your-api-key If-None-Match: "abc123" Response: 304 Not Modified (no body) ``` ### When to use Use ETag caching when polling for flag updates. For real-time updates, consider using the SSE endpoint at `/api/v1/flags/events` instead.