Environments allow you to maintain separate rollout rules in different contexts, from local development to QA, staging, and production. With the LaunchDarkly Environments API, you can programmatically list, create, and manage environments. To learn more, read 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.
LaunchDarkly supports two 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.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
.
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.
Environments collection response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Method not allowed
Rate limited
{- "_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,
- "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
}
]
}
Approval settings
The
approvalSettings
key is only returned when the flag approvals feature is enabled.You cannot update approval settings when creating new environments. Update approval settings with the Update environment API.
Create a new environment in a specified project with a given name, key, swatch color, and default TTL.
Environment response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Status conflict
Rate limited
{- "color": "DADBEE",
- "key": "environment-key-123abc",
- "name": "My Environment"
}
{- "_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,
- "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
}
Approval settings
The
approvalSettings
key is only returned when the Flag Approvals feature is enabled.
Get an environment given a project and key.
Environment response
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "_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,
- "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
}
Update an environment. Updating an environment uses a JSON patch representation of the desired changes. To learn more, read Updates.
To update fields in the environment object that are arrays, set the path
to the name of the field and then append /<array index>
. Using /0
appends to the beginning of the array.
This request only returns the approvalSettings
key if the flag approvals feature is enabled.
Only the canReviewOwnRequest
, canApplyDeclinedChanges
, minNumApprovals
, required
and requiredApprovalTagsfields
are editable.
If you try to patch the environment by setting both required
and requiredApprovalTags
, the request fails and an error appears. You can specify either required approvals for all flags in an environment or those with specific tags, but not both.
Environment response
Invalid request
Invalid access token
Invalid resource identifier
Status conflict
Rate limited
[- {
- "op": "replace",
- "path": "/requireComments",
- "value": true
}
]
{- "_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,
- "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
}
Delete a environment by key.
Action succeeded
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
{- "code": "unauthorized",
- "message": "Invalid access token"
}
Reset an environment's SDK key with an optional expiry time for the old key.
Environment response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Status conflict
Rate limited
{- "_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,
- "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
}
Reset an environment's mobile key. The optional expiry for the old key is deprecated for this endpoint, so the old key will always expire immediately.
Environment response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Status conflict
Rate limited
{- "_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,
- "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
}