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
      • PUTUpdate flag settings for context
    • 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
    • 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 overviewContext Settings

Update flag settings for context

PUT
/api/v2/projects/:projectKey/environments/:environmentKey/contexts/:contextKind/:contextKey/flags/:featureFlagKey
PUT
/api/v2/projects/:projectKey/environments/:environmentKey/contexts/:contextKind/:contextKey/flags/:featureFlagKey
$curl -X PUT https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey/contexts/contextKind/contextKey/flags/featureFlagKey \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{}'
1{}
Enable or disable a feature flag for a context based on its context kind and key. In the request body, the `setting` should be the variation value to set for the context. It must match the flag's variation type. For example, for a boolean flag you can use `"setting": true` or `"setting": false` in the request body. For a string flag, you can use `"setting": "existing_variation_value_to_use"`. 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.
Was this page helpful?
Previous

Custom Roles

Next
Built with

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

In the request body, the setting should be the variation value to set for the context. It must match the flag’s variation type. For example, for a boolean flag you can use "setting": true or "setting": false in the request body. For a string flag, you can use "setting": "existing_variation_value_to_use".

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.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
environmentKeystringRequiredformat: "string"
The environment key
contextKindstringRequiredformat: "string"
The context kind
contextKeystringRequiredformat: "string"
The context key
featureFlagKeystringRequiredformat: "string"
The feature flag key

Request

This endpoint expects an object.
settinganyOptional
The variation value to set for the context. Must match the flag's variation type.
commentstringOptional
Optional comment describing the change

Response

Action succeeded

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
429
Too Many Requests Error