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

GIVE DOCS FEEDBACK

Environments

Read time: 10 minutes
Last edited: Mar 01, 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

Understanding 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.

Opening environments

You can open environments on the Projects tab under Account settings. Click on a project name to view the environments within the project.

Here is a screenshot of the environments within a project:

A list of environments within a project.
A list of environments within a project.

Switching environments

The LaunchDarkly sidenav has a menu 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 "Switch environment" menu.
The "Switch environment" menu.

You can also search for and switch between environments using the quick search bar and your environment's name, key, or SDK key. You can find your environment's key and SDK key on the Environments tab of your project under Account settings.

To switch environments using the quick search bar:

  1. Click into the quick search bar or type CMD+K (Mac) or CTRL+K (PC).
  2. Select Switch environment or type G, then S. Alternatively, you can begin typing directly in the search bar.
  3. Enter an environment's name, key, or SDK key. A list of resources matching your search query appears.
  4. (Optional) To narrow the search results to just environments, click the Environments tab:
The "Environments" tab on the quick search bar with an environment name entered.
The "Environments" tab on the quick search bar with an environment name entered.
  1. Click the environment's name.

You are now in the environment you selected.

Creating environments

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 the Projects tab.
  3. Click the name of the project you want to add a new environment to. The Environments tab appears.
  4. 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.

Required confirmation is available to customers on Starter, Pro, and Enterprise plans. 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. 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 update.
  4. Click the overflow menu for the environment.
  5. Select Mark as critical.
  6. The "Mark environment as critical" environment appears.
  7. 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: Granting access to specific environments and flags.

Finding and resetting 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. Navigate to the the Account settings page.
  2. Click the Projects tab.
  3. Click the name of the project. The Environments tab appears.
  4. The "Keys" column displays the SDK key, mobile key, and client-side ID.

To reset an SDK key or mobile key:

  1. Navigate to the the Account settings page.
  2. Click the Projects tab.
  3. Click the name of the project. The Environments tab appears.
  4. Click the overflow menu next to your environment.
  5. Select "Edit environment." The "Edit environment" panel appears.
  6. In the "Keys" section click Reset SDK key or Reset mobile key.
  7. (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.
  8. 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 Comparing and copying 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.