No results for ""
EXPAND ALL
  • Home
  • API docs

GIVE DOCS FEEDBACK

Environments

Read time: 13 minutes
Last edited: Jun 05, 2024

Overview

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 development environments.

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

You can also use the REST API: Environments

Default environments

Your first project has two environments, Test and Production, by default. Each environment has its own SDK key, client-side ID, and mobile key, which are used to connect the LaunchDarkly SDKs 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 targeting rules in a development or staging environment for QA testing before rolling out to production.

By default, LaunchDarkly marks your Production environment as "critical" to indicate that it affects your customers or the health of your systems.

View a project's environments

To view a project's environments:

  1. Click the project dropdown. The project menu appears:
The project menu.
The project menu.
  1. Select Environments. The Environments list appears.

Open environments

You can open environments from the flags list, or while on a flag's targeting page:

  • On the flags list, opening an environment adds that environment's flag status to the list
  • On the targeting page, opening an environment adds a new section with that environment's flag targeting rules

To open an environment from the flags list or the flag's targeting page:

  1. Click the + next to the list of environment sections.
  2. Search for the environment you want, and select it from the list.
The environment selection menu.
The environment selection menu.

The new environment, and its related flag targeting information, appears. The number of environments you can view at once is limited by the width of your browser.

Favorite environments

You can add environments to your "Favorites" list, which is pinned to the top of the environments list. This list makes them easy to find when you want to open a commonly-used environment.

To add an environment to your favorites list:

  1. From the flags list, hover on the environment you want to add to your favorites, and click the three-dot overflow menu that appears.
  2. Click Add to favorites.

The environment is added to your favorites list.

You can also add an environment to your favorites list from a flag's details page using the environment's overflow menu.

To remove an environment from your favorites list, click Remove from favorites in the overflow menu.

Create environments

You can manage your environments from a project's Environments 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. Click the project dropdown. The project menu appears:
The project menu.
The project menu.
  1. Select Environments. The Environments list appears.
  2. Click Create environment. The "Create an environment" panel appears.
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 Critical environment checkbox to indicate this environment affects your customers or the health of your systems.
  5. (Optional) Select the Require comments for flag and segment changes checkbox to force members who modify flags and 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 your organization understand why flags or segments look and behave certain ways.

Required comments are only enforced from the flags list

When Require comments is enabled, members must leave a comment to explain their changes when they make changes from the flags list in the LaunchDarkly user interface (UI). Comments are not required for changes made with the LaunchDarkly API.

Required comments is available to customers on an Enterprise plan. To learn more, read Required comments.

  1. (Optional) Select the Require confirmation for flag and segment changes checkbox to force members who modify flags and 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. To learn more, read Required confirmation.

  1. (Optional) Select the Enable secure mode checkbox to ensure an end user of a client-side SDK cannot impersonate another end user.
  2. (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.
  3. (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.
Specify a TTL if you use the PHP SDK

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

  1. (Optional) Choose a Color to differentiate this environment from other environments.
  2. Click Create environment:
The "Create an environment" panel.
The "Create an environment" panel.


The new environment appears on the Account settings page.

Most customers can create up to 300 environments per project by default. If you are on a legacy Starter plan, your account may be limited to two environments. To request an increase to your environment limit, contact Support.

You can also use the REST API: Create environment

Critical environments

Critical environments, such as production, affect your customers or the health of your systems.

When you create a new environment, we strongly recommend enabling the following safeguards for your critical environments:

  • Require comments for flag and segment changes
  • Require confirmation for flag and segment changes

LaunchDarkly also enables some safeguards for critical environments, such as prompting you to check these environments when you archive a flag or view flags across multiple environments. Additionally, you can create custom roles that allow or deny access to critical environments.

To mark an environment as critical after you have created it:

  1. Click the project dropdown. The project menu appears:
The project menu.
The project menu.
  1. Select Environments. The Environments list appears.
  2. Click the overflow menu for the environment.
  3. Select Mark as critical.
  4. The "Mark environment as critical" dialog appears.
  5. Review the recommended safeguards:
  • (Optional) Select the Require comments for flag and segment changes checkbox to force members who modify flags and segments to leave a comment to explain their changes.
  • (Optional) Select the Require confirmation for flag and segment changes checkbox to force members who modify flags and segments to verify they wish to make these changes.
  1. Click Mark as critical.

To remove the critical designation from an environment, click the overflow menu for the environment and select "Mark as non-critical."

To view examples of custom role policies that use critical environments, read Example: Grant access to specific environments and flags.

Find and reset an environment's keys

You can view the SDK key, mobile key, and client-side ID for an environment from your Account settings page.

You need one of these keys when you set up your SDK. Which key you need depends on which SDK you use:

  • Use SDK keys for server-side SDKs. SDK keys should be kept secret. If an SDK key is exposed, you can reset it.
  • Use mobile keys for some client-side SDKs. Mobile keys do not need to be kept secret. However, if you wish to reset a mobile key, you can.
  • Use client-side IDs for JavaScript-based client-side SDKs and for edge SDKs. The client-side ID does not need to be kept secret and cannot be reset.

To learn more about different SDK key types, read Understanding the different types of SDKs and Keys.

To find an SDK key, mobile key, or client-side ID:

  1. Click the project dropdown. The project menu appears:
The project menu.
The project menu.
  1. Select Environments. The Environments list appears.
  2. The "Keys" column displays the SDK key, mobile key, and client-side ID.

To reset an SDK key or mobile key:

  1. Click the project dropdown. The project menu appears:
The project menu.
The project menu.
  1. Select Environments. The Environments list appears.
  2. Click the overflow menu next to your environment.
  3. Select Edit environment. The "Edit environment" panel appears.
  4. In the "Keys" section click Reset SDK key or Reset mobile key.
  5. (Optional) If you are resetting an SDK key, choose how many hours to keep the current SDK key active for, up to 720 hours (30 days). During this period, both the current SDK key and the new SDK key will work. This option is not available for mobile keys.
  6. Enter the name or key of your environment:
The SDK key reset dialog.
The SDK key reset dialog.
  1. Click Reset.

Deleting environments

You can delete an environment when you are no longer using it. Delete with caution, as deleting an environment is permanent.

To delete an environment:

  1. Navigate to the Account settings page.
  2. Click the Projects tab.
  3. Click the name of the project that contains the environment you want to delete.
  4. Click the overflow menu for the environment.
  5. Select Delete environment. A "Delete environment?" dialog appears.
  6. Enter the name or key of your environment in the confirmation field.
  7. Click Delete.

Your environment is now deleted.

You can also use the REST API: Delete environment

Cloning environments

For organizations with many flags, cloning an environment is the fastest way to create an environment and copy current flag settings from an existing environment. Cloning an environment also copies segment and flag rules for that environment.

When you clone an environment, the following restrictions apply:

  • You cannot clone an environment if it has more than 1,000 segments.
  • When you clone an environment, context targeting does not carry over to the new environment, because contexts may not exist in both environments.
  • Contexts in segments do not carry over to the new environment. Instead, LaunchDarkly creates an empty segment as a placeholder for flag rules to reference. To learn how to add contexts to these segments, read Segments.

Cloning an environment is currently only available through the REST API.

You can use the REST API: Create environment. Use the source field in the request body to pass in the environment to clone from.

Migrating content between environments

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

Alternatively, customers on a Pro or Enterprise plan can 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.

TTL settings

TTL settings are only used in the PHP SDK

This setting controls how long the PHP SDK can cache feature flag rules locally. You only need to configure this if you are using the PHP SDK.

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 the PHP SDK, because PHP's shared-nothing architecture makes LaunchDarkly's streaming model impossible. To learn more, read the PHP SDK reference.

For customers using PHP, we recommend setting your TTL to at least five minutes in production environments. This lets the PHP SDK 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 flags list 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 so it reflects changes 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.

To set the TTL:

  1. Navigate to the Account settings page.
  2. Click the Projects tab.
  3. Click the name of the project. The project page appears.
  4. Click the overflow menu next to your environment.
  5. Select Edit environment. The "Edit environment" panel appears.
  6. Enter a value in the TTL input and click Save environment.