HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Use Optimizely Agent

This topic describes how Optimizely Agent provides REST APIs that enable experimentation and feature management.

Optimizely Agent provides APIs that enable running feature flag rules, such as A/B tests and targeted flag deliveries. Agent provides equivalent functionality to all our SDKs. At its core is the Optimizely Go SDK.

Running feature flag rules

The Decide endpoint buckets a user into a feature flag variation as part of a flag rule. It chooses between multiple enabled or one disabled variation for a flag. Flag rules include A/B tests and targeted feature flag deliveries. To run a flag rule, use:

POST /v1/decide?keys={flagKey}

In the request application/json body, include the userId and any decideOptions. The full request looks like this:

curl --location --request POST 'http://localhost:8080/v1/decide?keys=YOUR_FLAG_1&keys=YOUR_FLAG_2'
--header 'X-Optimizely-SDK-Key: YOUR_SDK_KEY'
--header 'Accept: text/event-stream'
--header 'Content-Type: application/json'
--data-raw '{
"decideOptions": [
"userId": "string",
"userAttributes": {
   "additionalProp1": {}

This returns an array of OptimizelyDecision objects that contains all the information you need to run your flag rule, such as:

  • the decision to bucket this user into an enabled or disabled feature flag variation.
  • any corresponding feature flag variable values.

For example:

    "userContext": {
        "UserId": "test-user",
        "Attributes": {
            "logged-in": true,
            "location": "usa"
    "flagKey": "my-feature-flag",
    "ruleKey": "my-a-b-test",
    "enabled": false,
    "variationKey": "control_variation"
    "variables": {
        "my-var-1": "cust-val-default-1",
        "my-var-2": "cust-va1-default-2"
    "reasons": []

The response is determined by the A/B tests and deliveries defined for the supplied feature key, following the same rules as any Full Stack SDK.



If the user is bucketed into an A/B test, this endpoint dispatches a decision event.


To authenticate, pass your SDK key as a header named X-Optimizely-SDK-Key in your API calls to Optimizely Agent. You can find your SDK key in app.optimizely.com under Settings > Environments > SDK Key. Remember you have a different SDK key for each environment.

Get All Decisions

  • To get all feature flag decisions for a visitor in a single request, omit the feature flag parameter:
    POST /v1/decide

  • To get decisions for multiple keys, specify multiple keys parameters, for example:

  • To receive only the enabled feature flags for a visitor use a decide option in the application/json request body:

--header 'Content-Type: application/json' \
--data-raw '{
   "userId": "test-user"
   "decideOptions": [

Tracking conversions

To track events, use the same tracking endpoint you use in the SDKs' track API:

POST /v1/track?eventKey={eventKey}

There is no response body for successful conversion event requests.

API reference

For more details on Optimizely Agent’s APIs, see the complete Agent API Reference.

Did this page help you?