Context settings

You can use the context settings API to assign a context to a specific variation for any feature flag. To learn more, read View and manage contexts.

Update flag settings for context

Enable or disable a feature flag for a context based on its context kind and key.

Omitting the setting attribute from the request body, or including a setting of null, erases the current setting for a context.

If you previously patched the flag, and the patch included the context's data, LaunchDarkly continues to use that data. If LaunchDarkly has never encountered the combination of the context's key and kind before, it calculates the flag values based on the context kind and key.

Request
path Parameters
projectKey
required
string <string>

The project key

environmentKey
required
string <string>

The environment key

contextKind
required
string <string>

The context kind

contextKey
required
string <string>

The context key

featureFlagKey
required
string <string>

The feature flag key

Request Body schema: application/json
required
setting
any

The variation value to set for the context. Must match the flag's variation type.

comment
string

Optional comment describing the change

Responses
204

Action succeeded

400

Invalid request

401

Invalid access token

403

Forbidden

404

Invalid resource identifier

429

Rate limited

put/api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/{contextKind}/{contextKey}/flags/{featureFlagKey}
Request samples
application/json
{
  • "setting": "existing_variation_value_to_use",
  • "comment": "make sure this context experiences a specific variation"
}
Response samples
application/json
{
  • "code": "invalid_request",
  • "message": "Invalid request body"
}