Layers

Update layer

PATCH
/api/v2/projects/{projectKey}/layers/{layerKey}

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.

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"  }]}

Authorization

ApiKey read, write
Authorization<token>

In: header

Scope: read, write

Path Parameters

projectKey*string

The project key

Formatstring
layerKey*string

The layer key

Formatstring

Request Body

application/json

comment?string

Optional comment describing the update

environmentKey?string

The environment key used for making environment specific updates. For example, updating the reservation of an experiment

instructions*array<>

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.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X PATCH "https://example.com/api/v2/projects/string/layers/string" \  -H "Content-Type: application/json" \  -d '{    "comment": "Example comment describing the update",    "environmentKey": "production",    "instructions": [      {        "experimentKey": "checkout-button-color",        "kind": "updateExperimentReservation",        "reservationPercent": 25      }    ]  }'
{  "key": "checkout-flow",  "name": "Checkout Flow",  "description": "The checkout flow for the application",  "createdAt": 0,  "randomizationUnit": "user",  "environments": {    "property1": {      "reservations": [        {          "experimentKey": "checkout-flow-experiment",          "flagKey": "checkout-flow-flag",          "reservationPercent": 20        }      ]    },    "property2": {      "reservations": [        {          "experimentKey": "checkout-flow-experiment",          "flagKey": "checkout-flow-flag",          "reservationPercent": 20        }      ]    }  }}

Create layer POST

Create a layer. Experiments running in the same layer are granted mutually-exclusive traffic.

List metric groups GET

Get a list of all metric groups for the specified project. ### Expanding the metric groups response This endpoint does not support response expansion. Although the API accepts an `expand` query parameter for compatibility reasons, it does not currently modify the response. The parameter is reserved for future use. ### Filtering metric groups The `filter` parameter supports the following operators: `contains`, `equals`, `anyOf`. #### Supported fields and operators You can only filter certain fields in metrics when using the `filter` parameter. Additionally, you can only filter some fields with certain operators. When you search for metrics, the `filter` parameter supports the following fields and operators: |<div style="width:120px">Field</div> |Description |Supported operators | |---|---|---| | `experimentStatus` | The experiment's status. One of `not_started`, `running`, `stopped`, `started`. | `equals` | | `hasConnections` | Whether the metric group has connections to experiments or guarded rollouts. One of `true`, `false`. | `equals` | | `kind` | The metric group kind. One of `funnel`, `standard`. | `equals` | | `maintainerIds` | The metric maintainer IDs. | `anyOf` | | `maintainerTeamKey` | The metric maintainer team key. | `equals` | | `query` | A "fuzzy" search across metric group key and name. Supply a string or list of strings to the operator. | `equals` | ### Sorting metric groups LaunchDarkly supports the following fields for sorting: - `name` sorts by metric group name. - `createdAt` sorts by the creation date of the metric group. - `connectionCount` sorts by the number of connections to experiments the metric group has. By default, the sort is in ascending order. Use `-` to sort in descending order. For example, `?sort=name` sorts the response by metric group name in ascending order, and `?sort=-name` sorts in descending order. #### Sample query `filter=experimentStatus equals 'not_started' and query equals 'metric name'`