Optimizely will be sunsetting Full Stack Experimentation on July 29, 2024. See the recommended Feature Experimentation migration timeline and documentation.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySumbit a ticketLog In
GitHubNuGetDev CommunitySumbit a ticket

Use Optimizely Agent

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

Optimizely Agent provides APIs that enable experimentation and feature management. Agent provides equivalent functionality to all our SDKs. At its core is the Optimizely Go SDK. In some cases, however, we have updated our APIs to simplify key use cases.

Manage features

Optimizely Agent simplifies the core feature management of our SDK APIs. It consolidates the following endpoints:

... into one, convenient endpoint:

POST /v1/activate?featureKey={featureKey}

This activate endpoint returns:

  • the decision for this feature for this user
  • any corresponding feature variable values.

For example:

{
	"featureKey": "feature-key-1",
	"enabled": true,
	"variables": {
		"my-var-1": "cust-val-1",
		"my-var-2": "cust-va1-2"
	}
}

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

📘

Note

If the user is assigned to a feature test, this API will dispatch an impression.

Authentication

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.

Running A/B tests

To activate an A/B test, use:

POST /v1/activate?experimentKey={experimentKey}

This dispatches an impression and return the user’s assigned variation:

POST /v1/activate?experimentKey={experimentKey}

This dispatches an impression and return the user’s assigned variation:

{
  "experimentKey": "experiment-key-1",
  "variationKey": "variation-key-1"
}

Get All Decisions

To get all Feature decisions for a visitor in a single request use:

POST /v1/activate?type=feature

To receive only the enabled features for a visitor use:

POST /v1/activate?type=feature&enabled=true

To get all Experiment decisions for a visitor in a single request use:

POST /v1/activate?type=experiment

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 API Reference.