Create environment
For the complete documentation index, see llms.txt. For the full documentation snapshot, see llms-full.txt.
Approval settings
You cannot configure approval settings when you create a new environment. Use Update environment to update approval settings.
The
approvalSettingsandresourceApprovalSettingskeys are only returned when the approvals feature is enabled.
Create a new environment in a specified project with a given name, key, swatch color, and default TTL.
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"color": "DADBEE",
"key": "environment-key-123abc",
"name": "My Environment"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments"
payload = {
"color": "DADBEE",
"key": "environment-key-123abc",
"name": "My Environment"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({color: 'DADBEE', key: 'environment-key-123abc', name: 'My Environment'})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'color' => 'DADBEE',
'key' => 'environment-key-123abc',
'name' => 'My Environment'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments"
payload := strings.NewReader("{\n \"color\": \"DADBEE\",\n \"key\": \"environment-key-123abc\",\n \"name\": \"My Environment\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"color\": \"DADBEE\",\n \"key\": \"environment-key-123abc\",\n \"name\": \"My Environment\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"color\": \"DADBEE\",\n \"key\": \"environment-key-123abc\",\n \"name\": \"My Environment\"\n}"
response = http.request(request)
puts response.read_body{
"_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"
],
"critical": true,
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
},
"approvalSettings": {
"required": true,
"bypassApprovalsForPendingChanges": false,
"minNumApprovals": 1,
"canReviewOwnRequest": false,
"canApplyDeclinedChanges": true,
"serviceKind": "launchdarkly",
"serviceConfig": {},
"requiredApprovalTags": [
"require-approval"
],
"autoApplyApprovedChanges": true,
"serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"
},
"resourceApprovalSettings": {}
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "optimistic_locking_error",
"message": "Conflict. Optimistic lock error. Try again later."
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Authorizations
Path Parameters
The project key
Body
A human-friendly name for the new environment
"My Environment"
A project-unique key for the new environment
"environment-key-123abc"
A color to indicate this environment in the UI
"F5A623"
The default time (in minutes) that the PHP SDK can cache feature flag rules locally
5
Ensures that one end user of the client-side SDK cannot inspect the variations for another end user
true
Enables tracking detailed information for new flags by default
false
Requires confirmation for all flag and segment changes via the UI in this environment
false
Requires comments for all flag and segment changes via the UI in this environment
false
Tags to apply to the new environment
["ops"]
Indicates that the new environment created will be cloned from the provided source environment
Show child attributes
Show child attributes
Whether the environment is critical
true
Response
Environment response
The location and content type of related resources
Show child attributes
Show child attributes
{
"self": {
"href": "/api/v2/projects/my-project/environments/my-environment",
"type": "application/json"
}
}
The ID for the environment. Use this as the client-side ID for authorization in some client-side SDKs, and to associate LaunchDarkly environments with CDN integrations in edge SDKs.
"57be1db38b75bf0772d11384"
A project-unique key for the new environment
"environment-key-123abc"
A human-friendly name for the new environment
"My Environment"
The SDK key for the environment. Use this for authorization in server-side SDKs.
"sdk-xxx"
The mobile key for the environment. Use this for authorization in mobile SDKs.
"mob-xxx"
The color used to indicate this environment in the UI
"F5A623"
The default time (in minutes) that the PHP SDK can cache feature flag rules locally
5
Ensures that one end user of the client-side SDK cannot inspect the variations for another end user
true
Enables tracking detailed information for new flags by default
false
Whether members who modify flags and segments through the LaunchDarkly user interface are required to add a comment
true
Whether members who modify flags and segments through the LaunchDarkly user interface are required to confirm those changes
true
A list of tags for this environment
["ops"]
Whether the environment is critical
true
Show child attributes
Show child attributes
Details about the approval settings for flags in this environment
Show child attributes
Show child attributes
Details about the approval settings for other resources in this environment, organized by resource kind (for example, "aiconfig" and "segment")
Show child attributes
Show child attributes
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"color": "DADBEE",
"key": "environment-key-123abc",
"name": "My Environment"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments"
payload = {
"color": "DADBEE",
"key": "environment-key-123abc",
"name": "My Environment"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({color: 'DADBEE', key: 'environment-key-123abc', name: 'My Environment'})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'color' => 'DADBEE',
'key' => 'environment-key-123abc',
'name' => 'My Environment'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments"
payload := strings.NewReader("{\n \"color\": \"DADBEE\",\n \"key\": \"environment-key-123abc\",\n \"name\": \"My Environment\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"color\": \"DADBEE\",\n \"key\": \"environment-key-123abc\",\n \"name\": \"My Environment\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/environments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"color\": \"DADBEE\",\n \"key\": \"environment-key-123abc\",\n \"name\": \"My Environment\"\n}"
response = http.request(request)
puts response.read_body{
"_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"
],
"critical": true,
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
},
"approvalSettings": {
"required": true,
"bypassApprovalsForPendingChanges": false,
"minNumApprovals": 1,
"canReviewOwnRequest": false,
"canApplyDeclinedChanges": true,
"serviceKind": "launchdarkly",
"serviceConfig": {},
"requiredApprovalTags": [
"require-approval"
],
"autoApplyApprovedChanges": true,
"serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"
},
"resourceApprovalSettings": {}
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "optimistic_locking_error",
"message": "Conflict. Optimistic lock error. Try again later."
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}