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 create, delete, and update environments. To learn more, read Environments.
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 PATCH Environment API.
Create a new environment in a specified project with a given name, key, swatch color, and default TTL.
Successful environment response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Status conflict
Rate limited
{- "color": "DADBEE",
- "key": "my-environment",
- "name": "My Environment"
}
{- "_links": {
- "self": {
- "href": "/api/v2/projects/my-project/environments/my-environment",
- "type": "application/json"
}
}, - "_id": "57be1db38b75bf0772d11384",
- "key": "my-environment",
- "name": "My Environment",
- "apiKey": "XYZ",
- "mobileKey": "XYZ",
- "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,
- "serviceKind": "launchdarkly",
- "serviceConfig": { },
- "requiredApprovalTags": [
- "require-approval"
]
}
}
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 JSON
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
curl -i -X GET \ 'https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}' \ -H 'Authorization: YOUR_API_KEY_HERE'
{- "_links": {
- "self": {
- "href": "/api/v2/projects/my-project/environments/my-environment",
- "type": "application/json"
}
}, - "_id": "57be1db38b75bf0772d11384",
- "key": "my-environment",
- "name": "My Environment",
- "apiKey": "XYZ",
- "mobileKey": "XYZ",
- "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,
- "serviceKind": "launchdarkly",
- "serviceConfig": { },
- "requiredApprovalTags": [
- "require-approval"
]
}
}
Update an environment. Requires a JSON Patch representation of the desired changes to the environment.
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 JSON
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": "my-environment",
- "name": "My Environment",
- "apiKey": "XYZ",
- "mobileKey": "XYZ",
- "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,
- "serviceKind": "launchdarkly",
- "serviceConfig": { },
- "requiredApprovalTags": [
- "require-approval"
]
}
}
Delete a environment by key.
Action succeeded
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
curl -i -X DELETE \ 'https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}' \ -H 'Authorization: YOUR_API_KEY_HERE'
{- "code": "unauthorized",
- "message": "invalid key"
}
Reset an environment's SDK key with an optional expiry time for the old key.
Successful environment response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
curl -i -X POST \ 'https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/apiKey' \ -H 'Authorization: YOUR_API_KEY_HERE'
{- "_links": {
- "self": {
- "href": "/api/v2/projects/my-project/environments/my-environment",
- "type": "application/json"
}
}, - "_id": "57be1db38b75bf0772d11384",
- "key": "my-environment",
- "name": "My Environment",
- "apiKey": "XYZ",
- "mobileKey": "XYZ",
- "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,
- "serviceKind": "launchdarkly",
- "serviceConfig": { },
- "requiredApprovalTags": [
- "require-approval"
]
}
}
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.
Successful environment response
Invalid request
Invalid access token
Forbidden
Invalid resource identifier
Rate limited
curl -i -X POST \ 'https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments/{environmentKey}/mobileKey' \ -H 'Authorization: YOUR_API_KEY_HERE'
{- "_links": {
- "self": {
- "href": "/api/v2/projects/my-project/environments/my-environment",
- "type": "application/json"
}
}, - "_id": "57be1db38b75bf0772d11384",
- "key": "my-environment",
- "name": "My Environment",
- "apiKey": "XYZ",
- "mobileKey": "XYZ",
- "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,
- "serviceKind": "launchdarkly",
- "serviceConfig": { },
- "requiredApprovalTags": [
- "require-approval"
]
}
}