• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
No results for ""



Read time: 4 minutes
Last edited: Oct 06, 2021


This topic explains what environments are in LaunchDarkly and how to use them to manage different business areas or areas of your product lifecycle.

Environments are organizational units contained within projects. Environments allow you to manage your feature flags throughout your entire development lifecycle, from local development through production. Typical environments within a project could be Production, QA, Staging, or individual environments.

Your LaunchDarkly account supports an unlimited number of projects, environments, flags, and server-side Monthly Active Users (MAU). If you are on a legacy Starter plan, your account may be limited to two projects and two environments. Contact our Support team at support@launchdarkly.com to remove those restrictions.

You can create multiple environments within each project, and all projects must have at least one environment. To learn more about projects, read Projects.

Getting started with environments

Your first project has two environments, Test and Production, by default. Each environment has its own SDK key, which is used to connect the LaunchDarkly SDK to a specific environment.

Each feature flag that you create has its own set of targeting rules for each environment. This means that you can change your flag rollout rules in a development or staging environment for QA testing before rolling out to production.

The LaunchDarkly sidebar has a dropdown widget that shows you the current project and environment and allows you to quickly switch between projects and environments.

Here is a screenshot of the Switch environment menu:

The Environment switching widget.
The Environment switching widget.

You can manage your environments from the Account settings page. Here, you can add new environments to a project (for example, to give each developer on your team their own environment for local testing).

To add a new environment:

  1. Navigate to the Account Settings page.
  2. Click Create environment. The "Create an environment" screen appears:

The Account Settings page with the new environment button called out.
The Account Settings page with the new environment button called out.

Make sure you're in the right project

Confirm you're creating the environment in the project where you want it to live. You cannot move an environment from one project to another.

  1. Give your environment a human-readable Name.
  2. (Optional) Give your environment a unique Key. This field populates automatically based on your name, but you can change it now if you wish.
  3. (Optional) Add Tags.
  4. (Optional) Select the Enable secure mode checkbox to ensure a user of the client-side SDK cannot impersonate another user.
  5. (Optional) Select the Require comments for flag and segment changes checkbox to force members who modify flags and user segments to leave a comment to explain their changes.
Comments help establish a change history

Requiring members to leave comments when they change flags or segments helps future users understand why flags or segments look and behave certain ways.

Required comments are only enforced in the Dashboard

When Require comments is enabled, the LaunchDarkly Dashboard will force members to explain their changes. Comments are not required for changes made with the LaunchDarkly API.

Required comments is available to customers on an Enterprise plan.

  1. (Optional) Select the Require confirmation for flag and segment changes checkbox to force members who modify flags and user segments to verify they wish to make these changes.
Confirm changes helps prevent mistakes

Requiring members to confirm that they wish to make changes may help them from changing the wrong flag or segment inadvertently.

  1. (Optional) Select the Send detailed events to Data Export destinations checkbox to enable Data Export for every flag created in this environment after this checkbox is selected. To learn more, read Data Export.
  2. (Optional) Specify a TTL between 0 and 60 minutes. TTL, or Time to Live, is a setting in DNS records that dictates how long the record should be cached by nameservers and browsers.
PHP users need a TTL setting

The TTL setting checkbox only applies to environments using the PHP SDK. To learn more, read TTL settings.

  1. Choose a Color to differentiate this environment from other environments.
  2. Click Save Environment. The new environment appears on the Account Settings page:

The Create an environment screen.
The Create an environment screen.

Migrating content between environments

You can migrate some, but not all, content between environments. Compare and copy flag settings between environments from the LaunchDarkly UI. To learn more, read Compare and copy flag settings.

Alternatively, use the REST API to migrate flags from one environment to another. First, GET the feature flag you wish to import, then PATCH to update the flag configuration in production.

To learn more about these endpoints, read Get feature flag and Update feature flag.

Resetting an environment's key

If you need to reset an SDK or mobile key for an environment, navigate to the Account Settings page and click Edit next to the environment you wish to change.

When you edit an environment, you see the option to reset your SDK or mobile key for that environment. Click Reset SDK key or Reset mobile key to bring up a confirmation screen. From there, you have the option to keep the old key active for a period of time, up to a maximum of 720 hours (30 days).

Here is an image of the SDK key reset screen:

The SDK key reset screen.
The SDK key reset screen.

TTL settings

Each environment also has a time-to-live (TTL) setting. This sets the number of minutes that the PHP SDK can cache feature flag rules locally.

The TTL is only used in our PHP SDK, since PHP's shared-nothing architecture makes our streaming model impossible.

For customers using PHP, we recommend setting your TTL to at least five minutes in production environments. This lets our SDKs cache feature flag rules for five minutes, so most calls to variation will not make a remote request. The tradeoff is that changes you make to your feature flag rules on your dashboard will not take effect for five minutes.

If your site has relatively low traffic (fewer than one request per minute), you may wish to increase the TTL to five minutes or more to take better advantage of the local cache.

If the TTL is set to zero minutes, the SDK will not use a local cache, and every call to variation will make a remote request to our CDN. You can set your TTL to zero in testing environments to see changes reflected immediately, but we do not recommend a zero minute TTL in production.

In high volume PHP environments, we strongly recommend using our Relay Proxy. To learn more, read The Relay Proxy.