For details on the notification types, what causes them to be triggered and the data they provide, see Set up notification listener documentation for the Go SDK.
By default, the notifications endpoint is disabled. To enable it, update the
# config.yaml api: enableNotifications: true
Or, enable it by setting an environment variable:
# set an env. variable export OPTIMIZELY_API_ENABLENOTIFICATIONS=1
GET request to
/v1/notifications/event-stream to subscribe:
curl -N -H "Accept:text/event-stream" -H "X-Optimizely-Sdk-Key:<YOUR SDK KEY>"\ http://localhost:8080/v1/notifications/event-stream
This connection will remain open, and any notifications triggered by other requests received by Agent are pushed as events to this stream. Try sending requests to /v1/activate or /v1/track to see notifications being triggered.
To subscribe only to a particular category of notifications, add a
filter query parameter. For example, to subscribe only to Decision notifications:
# filter on decision notifications curl -N -H "Accept:text/event-stream" -H "X-Optimizely-Sdk-Key:<YOUR SDK KEY>"\ http://localhost:8080/v1/notifications/event-stream?filter=decision
For a runnable Python example, see examples/notifications.py in GitHub.
Updated 17 days ago