Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev guideRecipesAPI ReferenceChangelog
Dev guideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Agent notifications

Optimizely Agent provides an endpoint that sends notifications to subscribers using Server-Sent Events. This is Agent's equivalent of Notification Listeners found in the Optimizely Feature Experimentation SDKs.

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.

Configuration

By default, the notifications endpoint is disabled. To enable it, update theconfig.yaml file.

# config.yaml
api:
    enableNotifications: true

Or, enable it by configuring an environment variable.

# set an env. variable
export OPTIMIZELY_API_ENABLENOTIFICATIONS=1

Usage

Send a 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 remains 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.

Filter query parameter

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

When the Agent is operating in High Availability (HA) mode, you need to enable notification sync to get notifications from the nodes in an HA configuration. A PubSub system (Redis) is now used to ensure consistent retrieval of notification events across all nodes in an HA configuration.

The following is an example of how you can enable the notification sync with Redis:

## synchronization should be enabled when features for multiple nodes like notification streaming are deployed
synchronization:
    pubsub:
        redis:
            host: "localhost:6379"
            password: ""
            database: 0
    ## if notification synchronization is enabled, then the active notification event-stream API
    ## will get the notifications from available replicas
    notification:
        enable: true
        default: "redis"

Example

For a runnable Python example, see examples/notifications.py in GitHub.