Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback

Manage environments

How to manage and run Optimizely Feature Experimentation in isolated environments, like development or staging.

Optimizely Feature Experimentation allows you to confirm behavior and run flags in isolated environments, like development or staging. This makes it easier to deploy targeted deliveries and experiments in production safely. For example, you could run a single experiment in some contexts and pause it in others, or you could turn an experiment to test it for your team and leave it off for visitors.

Every Optimizely Feature Experimentation project starts with two environments (and two datafiles): Production and Development.

New environments have the following attributes:

Environment-specific datafileAutomatically generatedShows the state of the experiments within that environment. If you created flags and experiments in other environments in your project, they show up as "not running" until you start them in this environment.
Unique SDK keyAutomatically generatedThis determines the URL of the environment's datafile, which ensures that the URL will not be easily guessed. You can use the SDK key to initialize the SDK with the corresponding environment's datafile.
Datafile access tokenAutomatically generatedIf you create a secure environment, then you can fetch the datafile for that secure environment from an authenticated endpoint using this access token.

For more information, see the initialization topic for your SDK language (server-side only).
Environment keyUser-provided. This key is used for programmatic access to the environment: for example, if you were to modify your environments using Optimizely's REST API.

You should also add a Staging environment to your project to use for QA testing before running experiments in your Production environment.

Environment permissions

You can control which collaborators have permission to start and stop experiments in an environment. This limits the number of people who can change your experiments' statuses or move them from one environment to another.

You should keep access open to everyone in local or development environments and limit access in production environments. By default, the production environment is limited to Publishers and above.

Secure environments

You can choose to secure your environments. When this setting is enabled, you must pass a datafile authentication token when you send requests to the datafile URL via the SDK. This can provide an additional layer of security and privacy to your flag rules (such as A/B tests) on top of the uniqueness and obscurity of the SDK key.



Server-side only

Optimizely Feature Experimentation recommends using this feature only in projects that exclusively use server-side SDKs and implementation. If you fetch the datafiles in a client-side environment, they may become accessible to end users. For information on which SDKs support secure environments, see SDK Compatibility Matrix.

Create environments

To create an environment:

  1. Navigate to Settings > Environments.
  1. Click Create New... and choose Environment or Secure Environment.
  2. Enter the environment name and key. The key must contain only numbers, letters and underscores. Specify the permission level you want to set for experiments in the environment.
  1. Click Create Environment.

The SDK Key and Datafile URL for the new environment are displayed on the Settings page.

Secure environments - generate an access token

If you created a secure environment, you need to generate an access token. This token will need to be passed into the SDK to access the datafile. Secure environments are recommended for server-side SDKs only. See Secure environments.



Once you have made an environment secure, you cannot go back to an unsecured environment.

  1. Select Add access token for the newly created environment.
  1. Add a Token Name for your access token and select Generate Token.
  1. Copy the token value from the Settings page. It will not be visible once you leave the page.



If you do not copy the token value, you will have to create a new token.

  1. Use the generated token as the access_token parameter when initializing the SDK. Select your SDK below for more information:



Experiments are paused by default in any new environments you create, even if they were already running in the default environment.

Convert to a secure environment

You can convert an existing unsecured environment to a secure one from the actions menu. You can tell if an environment is secure by referencing the lock icon on the Settings page.

An unlocked icon indicates a un-secured environment.



A locked icon indicates a secure environment.



  1. Select the Actions icon (...) for the environment you want to secure.
  2. Select Secure

You will see the following message:

  1. Select Secure
  2. Follow the instructions for Secure environments - generate access token above to complete your secure environment.



Update your SDK implementation

Once you convert to a secure environment you need to update your SDK implementation to initialize with the access token before you can continue to get updates from Optimizely.

Optional: Remove unsecured datafile

After you have secured your datafile and updated your application to initialize the SDK with the datafile access token created in the previous step, you can manually remove the cached copy of the datafile for your environment from Optimizely's public CDN.


You MUST complete steps 1 through 4 in Secure environments - generate access token before removing the unsecured datafile. Failure to do so will break your SDK implementation as the SDK will no longer be able to fetch the datafile.

  1. Select the Actions icon (...) for the environment you want to remove the public datafile.
  2. Select Remove Public Datafile

You will see the following message:

  1. Select Remove.

Rename an environment

To rename an environment:

  1. Navigate to Settings > Datafile.
  2. Click the Actions icon (...) for the environment you want to rename.
  3. Click Settings.
  4. Enter the new name for the environment and click Save Environment.



Be careful changing the datafile's environment key as it will impact the datafile URL your code loads.

The environment key displays on the Settings > Datafile page; see the image in View the datafile via the app.

Archive an environment

You can archive environments if they are not being used anymore (except the primary environment, which cannot be archived). Archiving deactivates all the datafiles in an environment, replacing them with an empty file, and removes the environment as an option for experiments.

If experiments are running in the environment when you archive it, they will stop because archiving empties the datafile.

To archive an environment:

  1. Go to Settings > Datafile.
  2. Click the Actions icon (...) for the environment you want to archive.
  3. Click Archive.

Results by environment

Each environment will have its own Reports page. You can toggle between your environments to view results for each. Refer to Reports for more information.