For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • REST API overview
    • Access Tokens
    • Account Members
    • Account Usage Beta
    • AI Configs
    • Announcements
    • Applications Beta
    • Approvals
    • Approvals Beta
    • Audit Log
    • Code References
    • Contexts
    • Context Settings
    • Custom Roles
    • Data Export Destinations
    • Environments
    • Experiments
    • Feature Flags
    • Feature Flags Beta
    • Flag Import Configurations Beta
    • Flag Links Beta
    • Flag Triggers
    • Follow Flags
    • Holdouts Beta
    • Insights Charts Beta
    • Insights Deployments Beta
    • Insights Flag Events Beta
    • Insights Pull Requests Beta
    • Insights Repositories Beta
    • Insights Scores Beta
    • Integration Audit Log Subscriptions
    • Integration Delivery Configurations Beta
    • Integrations Beta
    • Layers
      • POSTCreate layer
      • GETGet layers
      • PATCHUpdate layer
    • Metrics
    • Metrics Beta
    • OAuth2 Clients
    • Persistent Store Integrations Beta
    • Projects
    • Relay Proxy Configurations
    • Release Pipelines Beta
    • Releases Beta
    • Scheduled Changes
    • Segments
    • Tags
    • Teams
    • Teams Beta
    • Users
    • Users Beta
    • User Settings
    • Views Beta
    • Webhooks
    • Workflows
    • Workflow Templates
    • Other
Sign inTry it free
LogoLogo
REST API overviewLayers

Update layer

PATCH
/api/v2/projects/:projectKey/layers/:layerKey
PATCH
/api/v2/projects/:projectKey/layers/:layerKey
$curl -X PATCH https://app.launchdarkly.com/api/v2/projects/projectKey/layers/layerKey \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "instructions": [
> {
> "experimentKey": "checkout-button-color",
> "kind": "updateExperimentReservation",
> "reservationPercent": 25
> }
> ],
> "comment": "Example comment describing the update",
> "environmentKey": "production"
>}'
1{
2 "key": "checkout-flow",
3 "name": "Checkout Flow",
4 "description": "The checkout flow for the application",
5 "createdAt": 1,
6 "randomizationUnit": "user",
7 "environments": {}
8}
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](https://launchdarkly.com/docs/api#updates-using-semantic-patch). ### Instructions Semantic patch requests support the following `kind` instructions for updating layers. <details> <summary>Click to expand instructions for <strong>updating layers</strong></summary> #### updateName Updates the layer name. ##### Parameters - `name`: The new layer name. Here's an example: ```json { "instructions": [{ "kind": "updateName", "name": "New name" }] } ``` #### updateDescription Updates the layer description. ##### Parameters - `description`: The new description. Here's an example: ```json { "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: ```json { "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: ```json { "environmentKey": "production", "instructions": [{ "kind": "removeExperiment", "experimentKey": "exp-key" }] } ``` </details>
Was this page helpful?
Previous

Metrics

Next
Built with

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:

1{
2 "instructions": [{
3 "kind": "updateName",
4 "name": "New name"
5 }]
6}

updateDescription

Updates the layer description.

Parameters
  • description: The new description.

Here’s an example:

1{
2 "instructions": [{
3 "kind": "updateDescription",
4 "description": "New description"
5 }]
6}

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:

1{
2 "environmentKey": "production",
3 "instructions": [{
4 "kind": "updateExperimentReservation",
5 "experimentKey": "exp-key",
6 "reservationPercent": 10
7 }]
8}

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:

1{
2 "environmentKey": "production",
3 "instructions": [{
4 "kind": "removeExperiment",
5 "experimentKey": "exp-key"
6 }]
7}

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
layerKeystringRequiredformat: "string"
The layer key

Request

This endpoint expects an object.
instructionslist of maps from strings to anyRequired

The instructions to perform when updating. This should be an array with objects that look like <code>{“kind”: “update_action”}</code>. Some instructions also require a <code>value</code> field in the array element.

commentstringOptional
Optional comment describing the update
environmentKeystringOptional
The environment key used for making environment specific updates. For example, updating the reservation of an experiment

Response

Layer response
keystring
The key of the layer
namestring
The name of the layer
descriptionstring
The description of the layer
createdAtlong
The date and time when the layer was created
randomizationUnitstring
The unit of randomization for the layer
environmentsmap from strings to objects
The layer configurations for each requested environment

Errors

400
Bad Request Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error