Learn Something New: Working with Environments

Rollouts accounts start with two environments, Production and Development, with Production set as your primary. Environments allow you to organize Rollouts into sections that correspond to your development environments, like development and production. With environments, you can turn a feature flag on in one context, but leave it off in another. For example, you might turn a feature flag on for your team to demonstrate in a demo environment for feedback, but leave it turned off for users in your production application.

rollouts environments

Keeping separate environments reduces the risk of accidentally launching an unfinished or unverified feature to the live site. You can add as many environments to Rollouts as you need. Should it fit with your workflow, try adding a demo environment to your account to allow a space for active feedback.

When you set up a new environment, Optimizely generates:

  • An environment-specific datafile: The datafile generated for each additional environment contains the current state of all feature flags for that specific environment.
  • A unique SDK key: The key determines the URL of the environment's datafile and ensures that the URL won’t be easily guessed. For SDKs that provide native datafile managers (currently JavaScript, iOS, tvOS, and Android), you can use the SDK key to initialize the SDK with the corresponding environment's datafile. See initialize a mobile SDK.

Creating a new environment also creates a new environment key. This key is used for programmatic access to the environment. For example, you can modify your environments using Optimizely's REST API.

Create environments

Add environments, such as staging or demo.

  1. Navigate to Settings > Datafile.
  2. Click New Environment.
  3. Enter the environment name, key, and description.
  4. Specify whether you'd like to limit the ability to change the active state of a feature flag to Publishers only in this environment.
  5. Click Create Environment.

The Environment Key and Datafile URL for the new environment will display on the Settings page. This key needs to be added to your code.

Environment GIF


Keep your production application secure by limiting the permissions of collaborators who can turn on feature flags in your production environment.

By default, only collaborators with Publisher-level permissions can make changes to the production environment. You can toggle this permission setting separately in each environment. We'll look closer at this in our advanced course.

Rename an environment

In addition, environments can be renamed and even archived.

Note: Use this capability with caution. Changing the name of an existing environment will change the URL of your datafile. You will need to update any applications to use the new URL. The datafile content on the old URL will no longer be updated.

  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.


Archive an environment

You can archive environments if they aren’t being used anymore (except the primary environment, which can't be archived).

Note: Archiving environments will deactivate all the datafiles in that environment, replace them with an empty file, and remove the environment as an option for features. If feature flags are on in an environment when you archive it, the feature flags will stop working because archiving empties the datafile.

To archive an environment:

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

Archive environment