Update layer
For the complete documentation index, see llms.txt. For the full documentation snapshot, see llms-full.txt.
Update a layer by adding, changing, or removing traffic reservations for experiments, or by changing layer name or description. Updating a layer uses the semantic patch format.
To make a semantic patch request, you must append domain-model=launchdarkly.semanticpatch to your Content-Type header. To learn more, read Updates using semantic patch.
Instructions
Semantic patch requests support the following kind instructions for updating layers.
Click to expand instructions for updating layers
updateName
Updates the layer name.
Parameters
name: The new layer name.
Here’s an example:
{
"instructions": [{
"kind": "updateName",
"name": "New name"
}]
}
updateDescription
Updates the layer description.
Parameters
description: The new description.
Here’s an example:
{
"instructions": [{
"kind": "updateDescription",
"description": "New description"
}]
}
updateExperimentReservation
Adds or updates a traffic reservation for an experiment in a layer.
Parameters
experimentKey: The key of the experiment whose reservation you are adding to or updating in the layer.reservationPercent: The amount of traffic in the layer to reserve. Must be an integer. Zero is allowed until iteration start.
Here’s an example:
{
"environmentKey": "production",
"instructions": [{
"kind": "updateExperimentReservation",
"experimentKey": "exp-key",
"reservationPercent": 10
}]
}
removeExperiment
Removes a traffic reservation for an experiment from a layer.
Parameters
experimentKey: The key of the experiment whose reservation you want to remove from the layer.
Here’s an example:
{
"environmentKey": "production",
"instructions": [{
"kind": "removeExperiment",
"experimentKey": "exp-key"
}]
}
curl --request PATCH \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"comment": "Example comment describing the update",
"environmentKey": "production",
"instructions": [
{
"experimentKey": "checkout-button-color",
"kind": "updateExperimentReservation",
"reservationPercent": 25
}
]
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}"
payload = {
"comment": "Example comment describing the update",
"environmentKey": "production",
"instructions": [
{
"experimentKey": "checkout-button-color",
"kind": "updateExperimentReservation",
"reservationPercent": 25
}
]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
comment: 'Example comment describing the update',
environmentKey: 'production',
instructions: [
{
experimentKey: 'checkout-button-color',
kind: 'updateExperimentReservation',
reservationPercent: 25
}
]
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}', 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}/layers/{layerKey}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'comment' => 'Example comment describing the update',
'environmentKey' => 'production',
'instructions' => [
[
'experimentKey' => 'checkout-button-color',
'kind' => 'updateExperimentReservation',
'reservationPercent' => 25
]
]
]),
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}/layers/{layerKey}"
payload := strings.NewReader("{\n \"comment\": \"Example comment describing the update\",\n \"environmentKey\": \"production\",\n \"instructions\": [\n {\n \"experimentKey\": \"checkout-button-color\",\n \"kind\": \"updateExperimentReservation\",\n \"reservationPercent\": 25\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"comment\": \"Example comment describing the update\",\n \"environmentKey\": \"production\",\n \"instructions\": [\n {\n \"experimentKey\": \"checkout-button-color\",\n \"kind\": \"updateExperimentReservation\",\n \"reservationPercent\": 25\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"comment\": \"Example comment describing the update\",\n \"environmentKey\": \"production\",\n \"instructions\": [\n {\n \"experimentKey\": \"checkout-button-color\",\n \"kind\": \"updateExperimentReservation\",\n \"reservationPercent\": 25\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"key": "checkout-flow",
"name": "Checkout Flow",
"description": "The checkout flow for the application",
"createdAt": 123,
"randomizationUnit": "user",
"environments": {}
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Authorizations
Path Parameters
The project key
The layer key
Body
The instructions to perform when updating. This should be an array with objects that look like {"kind": "update_action"}. Some instructions also require a value field in the array element.
Show child attributes
Show child attributes
"[{\"kind\": \"updateName\", \"name\": \"Updated layer name\"}]"
Optional comment describing the update
"Optional comment"
The environment key used for making environment specific updates. For example, updating the reservation of an experiment
"production"
Response
Layer response
The key of the layer
"checkout-flow"
The name of the layer
"Checkout Flow"
The description of the layer
"The checkout flow for the application"
The date and time when the layer was created
The unit of randomization for the layer
"user"
The layer configurations for each requested environment
Show child attributes
Show child attributes
curl --request PATCH \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"comment": "Example comment describing the update",
"environmentKey": "production",
"instructions": [
{
"experimentKey": "checkout-button-color",
"kind": "updateExperimentReservation",
"reservationPercent": 25
}
]
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}"
payload = {
"comment": "Example comment describing the update",
"environmentKey": "production",
"instructions": [
{
"experimentKey": "checkout-button-color",
"kind": "updateExperimentReservation",
"reservationPercent": 25
}
]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
comment: 'Example comment describing the update',
environmentKey: 'production',
instructions: [
{
experimentKey: 'checkout-button-color',
kind: 'updateExperimentReservation',
reservationPercent: 25
}
]
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}', 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}/layers/{layerKey}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'comment' => 'Example comment describing the update',
'environmentKey' => 'production',
'instructions' => [
[
'experimentKey' => 'checkout-button-color',
'kind' => 'updateExperimentReservation',
'reservationPercent' => 25
]
]
]),
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}/layers/{layerKey}"
payload := strings.NewReader("{\n \"comment\": \"Example comment describing the update\",\n \"environmentKey\": \"production\",\n \"instructions\": [\n {\n \"experimentKey\": \"checkout-button-color\",\n \"kind\": \"updateExperimentReservation\",\n \"reservationPercent\": 25\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"comment\": \"Example comment describing the update\",\n \"environmentKey\": \"production\",\n \"instructions\": [\n {\n \"experimentKey\": \"checkout-button-color\",\n \"kind\": \"updateExperimentReservation\",\n \"reservationPercent\": 25\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/layers/{layerKey}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"comment\": \"Example comment describing the update\",\n \"environmentKey\": \"production\",\n \"instructions\": [\n {\n \"experimentKey\": \"checkout-button-color\",\n \"kind\": \"updateExperimentReservation\",\n \"reservationPercent\": 25\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"key": "checkout-flow",
"name": "Checkout Flow",
"description": "The checkout flow for the application",
"createdAt": 123,
"randomizationUnit": "user",
"environments": {}
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}