Layers

Available for customers using Experimentation

Layers are available to customers using Experimentation.

There are some cases in which you may not want to include a context in more than one experiment at a time. For example, you may be concerned about collisions between experiments that are testing similar parts of your app, like two different changes to the same section of your app's user interface (UI), or experiments running on both the back end and front end of the same functionality. In this case you can eliminate the interaction effect between experiments using layers.

A layer contains a set of experiments that cannot share traffic with each other. All of the experiments within a layer are mutually exclusive, which means that if a context is included in one experiment, LaunchDarkly will exclude it from any other experiments in the same layer.

To learn more, read Mutually exclusive experiments.

Get layers

Get a collection of all layers for a project

Request
path Parameters
projectKey
required
string <string>

The project key

query Parameters
filter
string <string>

A comma-separated list of filters. This endpoint only accepts filtering by experimentKey. The filter returns layers which include that experiment for the selected environment(s). For example: filter=reservations.experimentKey contains expKey.

Responses
200

Layer Collection response

400

Invalid request

403

Forbidden

404

Invalid resource identifier

429

Rate limited

get/api/v2/projects/{projectKey}/layers
Request samples
Response samples
application/json
{
  • "items": [
    ],
  • "totalCount": 0,
  • "_links": {
    }
}

Create layer

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

Request
path Parameters
projectKey
required
string <string>

The project key

Request Body schema: application/json
required
key
required
string

Unique identifier for the layer

name
required
string

Layer name

description
required
string

The checkout flow for the application

Responses
201

Layer response

400

Invalid request

403

Forbidden

404

Invalid resource identifier

429

Rate limited

post/api/v2/projects/{projectKey}/layers
Request samples
application/json
{
  • "key": "checkout-flow",
  • "name": "Checkout Flow",
  • "description": "string"
}
Response samples
application/json
{
  • "key": "checkout-flow",
  • "name": "Checkout Flow",
  • "description": "The checkout flow for the application",
  • "createdAt": 0,
  • "randomizationUnit": "user",
  • "environments": {
    }
}

Update layer

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"
  }]
}
Request
path Parameters
projectKey
required
string <string>

The project key

layerKey
required
string <string>

The layer key

Request Body schema: application/json
required
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

required
Array of objects (Instructions)
Responses
200

Layer response

400

Invalid request

403

Forbidden

404

Invalid resource identifier

429

Rate limited

patch/api/v2/projects/{projectKey}/layers/{layerKey}
Request samples
application/json
{
  • "comment": "Example comment describing the update",
  • "environmentKey": "production",
  • "instructions": [
    ]
}
Response samples
application/json
{
  • "key": "checkout-flow",
  • "name": "Checkout Flow",
  • "description": "The checkout flow for the application",
  • "createdAt": 0,
  • "randomizationUnit": "user",
  • "environments": {
    }
}