Environments

List environments

GET
/api/v2/projects/{projectKey}/environments

Return a list of environments for the specified project.

By default, this returns the first 20 environments. Page through this list with the limit parameter and by following the first, prev, next, and last links in the _links field that returns. If those links do not appear, the pages they refer to don't exist. For example, the first and prev links will be missing from the response on the first page, because there is no previous page and you cannot return to the first page when you are already on the first page.

Filtering environments

LaunchDarkly supports the following fields for filters:

  • query is a string that matches against the environments' names and keys. It is not case sensitive.
  • tags is a +-separated list of environment tags. It filters the list of environments that have all of the tags in the list.
  • critical is a boolean filter. critical:true returns only environments marked as critical, and critical:false returns only non-critical environments.

For example, the filter filter=query:abc,tags:tag-1+tag-2 matches environments with the string abc in their name or key and also are tagged with tag-1 and tag-2. The filter is not case-sensitive.

The documented values for filter query parameters are prior to URL encoding. For example, the + in filter=tags:tag-1+tag-2 must be encoded to %2B.

Sorting environments

LaunchDarkly supports the following fields for sorting:

  • createdOn sorts by the creation date of the environment.
  • critical sorts by whether the environments are marked as critical.
  • name sorts by environment name.

For example, sort=name sorts the response by environment name in ascending order.

Authorization

ApiKey read, write
Authorization<token>

In: header

Scope: read, write

Path Parameters

projectKey*string

The project key

Formatstring

Query Parameters

limit?integer

The number of environments to return in the response. Defaults to 20.

Formatint64
offset?integer

Where to start in the list. This is for use with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query limit.

Formatint64
filter?string

A comma-separated list of filters. Each filter is of the form field:value.

Formatstring
sort?string

A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order.

Formatstring

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/api/v2/projects/string/environments"
{  "_links": {    "property1": {      "href": "string",      "type": "string"    },    "property2": {      "href": "string",      "type": "string"    }  },  "totalCount": 2,  "items": [    {      "_links": {        "self": {          "href": "/api/v2/projects/my-project/environments/my-environment",          "type": "application/json"        }      },      "_id": "57be1db38b75bf0772d11384",      "key": "environment-key-123abc",      "name": "My Environment",      "apiKey": "sdk-xxx",      "mobileKey": "mob-xxx",      "color": "F5A623",      "defaultTtl": 5,      "secureMode": true,      "_access": {        "denied": [          {            "action": "string",            "reason": {              "resources": [                "proj/*:env/*;qa_*:/flag/*"              ],              "notResources": [                "string"              ],              "actions": [                "*"              ],              "notActions": [                "string"              ],              "effect": "allow",              "role_name": "string"            }          }        ],        "allowed": [          {            "action": "string",            "reason": {              "resources": [                "proj/*:env/*;qa_*:/flag/*"              ],              "notResources": [                "string"              ],              "actions": [                "*"              ],              "notActions": [                "string"              ],              "effect": "allow",              "role_name": "string"            }          }        ]      },      "defaultTrackEvents": false,      "requireComments": true,      "confirmChanges": true,      "tags": [        "ops"      ],      "approvalSettings": {        "required": true,        "bypassApprovalsForPendingChanges": false,        "minNumApprovals": 1,        "canReviewOwnRequest": false,        "canApplyDeclinedChanges": true,        "autoApplyApprovedChanges": true,        "serviceKind": "launchdarkly",        "serviceConfig": {},        "requiredApprovalTags": [          "require-approval"        ],        "serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"      },      "resourceApprovalSettings": {        "property1": {          "required": true,          "bypassApprovalsForPendingChanges": false,          "minNumApprovals": 1,          "canReviewOwnRequest": false,          "canApplyDeclinedChanges": true,          "autoApplyApprovedChanges": true,          "serviceKind": "launchdarkly",          "serviceConfig": {},          "requiredApprovalTags": [            "require-approval"          ],          "serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"        },        "property2": {          "required": true,          "bypassApprovalsForPendingChanges": false,          "minNumApprovals": 1,          "canReviewOwnRequest": false,          "canApplyDeclinedChanges": true,          "autoApplyApprovedChanges": true,          "serviceKind": "launchdarkly",          "serviceConfig": {},          "requiredApprovalTags": [            "require-approval"          ],          "serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"        }      },      "critical": true    }  ]}

Evaluate flags for context instance POST

Evaluate flags for a context instance, for example, to determine the expected flag variation. **Do not use this API instead of an SDK.** The LaunchDarkly SDKs are specialized for the tasks of evaluating feature flags in your application at scale and generating analytics events based on those evaluations. This API is not designed for that use case. Any evaluations you perform with this API will not be reflected in features such as flag statuses and flag insights. Context instances evaluated by this API will not appear in the Contexts list. To learn more, read [Comparing LaunchDarkly's SDKs and REST API](https://launchdarkly.com/docs/guides/api/comparing-sdk-rest-api). ### Filtering LaunchDarkly supports the `filter` query param for filtering, with the following fields: - `query` filters for a string that matches against the flags' keys and names. It is not case sensitive. For example: `filter=query equals dark-mode`. - `tags` filters the list to flags that have all of the tags in the list. For example: `filter=tags contains ["beta","q1"]`. You can also apply multiple filters at once. For example, setting `filter=query equals dark-mode, tags contains ["beta","q1"]` matches flags which match the key or name `dark-mode` and are tagged `beta` and `q1`.

Create environment POST

> ### Approval settings > > You cannot configure approval settings when you create a new environment. Use [Update environment](https://launchdarkly.com/docs/api/environments/patch-environment) to update approval settings. > > The `approvalSettings` and `resourceApprovalSettings` keys are only returned when the [approvals](https://launchdarkly.com/docs/home/releases/approvals/) feature is enabled. Create a new environment in a specified project with a given name, key, swatch color, and default TTL.