Available for customers using Experimentation
Layers are available to customers using Experimentation.
This feature is in beta
To use this feature, pass in a header including the
LD-API-Version
key with value set tobeta
. Use this header with each call. To learn more, read Beta resources.Resources that are in beta are still undergoing testing and development. They may change without notice, including becoming backwards incompatible.
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 a collection of all layers for a project
Layer Collection response
Invalid request
Forbidden
Invalid resource identifier
Rate limited
{- "items": [
- {
- "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
}
]
}
}
}
], - "totalCount": 0,
- "_links": {
- "self": {
- "href": "/api/v2/projects/my-project/layers",
- "type": "application/json"
}
}
}
Create a layer. Experiments running in the same layer are granted mutually-exclusive traffic.
Layer response
Invalid request
Forbidden
Invalid resource identifier
Rate limited
{- "key": "checkout-flow",
- "name": "Checkout Flow",
- "description": "string"
}
{- "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
}
]
}
}
}
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.
Semantic patch requests support the following kind
instructions for updating layers.
Updates the layer name.
name
: The new layer name.Here's an example:
{
"instructions": [{
"kind": "updateName",
"name": "New name"
}]
}
Updates the layer description.
description
: The new description.Here's an example:
{
"instructions": [{
"kind": "updateDescription",
"description": "New description"
}]
}
Adds or updates a traffic reservation for an experiment in a layer.
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
}]
}
Removes a traffic reservation for an experiment from a layer.
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"
}]
}
Layer response
Invalid request
Forbidden
Invalid resource identifier
Rate limited
{- "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
}
]
}
}
}