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
    • Custom Roles
    • Data Export Destinations
    • Environments
      • POSTCreate environment
      • DELDelete environment
      • GETGet environment
      • GETList environments
      • POSTReset environment mobile SDK key
      • POSTReset environment SDK key
      • PATCHUpdate environment
    • 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 overviewEnvironments

Update environment

PATCH
/api/v2/projects/:projectKey/environments/:environmentKey
PATCH
/api/v2/projects/:projectKey/environments/:environmentKey
$curl -X PATCH https://app.launchdarkly.com/api/v2/projects/projectKey/environments/environmentKey \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '[
> {
> "op": "replace",
> "path": "/requireComments",
> "value": null
> }
>]'
1{
2 "_links": {
3 "self": {
4 "href": "/api/v2/projects/my-project/environments/my-environment",
5 "type": "application/json"
6 }
7 },
8 "_id": "57be1db38b75bf0772d11384",
9 "key": "environment-key-123abc",
10 "name": "My Environment",
11 "apiKey": "sdk-xxx",
12 "mobileKey": "mob-xxx",
13 "color": "F5A623",
14 "defaultTtl": 5,
15 "secureMode": true,
16 "defaultTrackEvents": false,
17 "requireComments": true,
18 "confirmChanges": true,
19 "tags": [
20 "ops"
21 ],
22 "critical": true,
23 "_access": {
24 "denied": [
25 {
26 "action": "string",
27 "reason": {
28 "effect": "allow",
29 "resources": [
30 "proj/*:env/*;qa_*:/flag/*"
31 ],
32 "notResources": [
33 "string"
34 ],
35 "actions": [
36 "*"
37 ],
38 "notActions": [
39 "string"
40 ],
41 "role_name": "string"
42 }
43 }
44 ],
45 "allowed": [
46 {
47 "action": "string",
48 "reason": {
49 "effect": "allow",
50 "resources": [
51 "proj/*:env/*;qa_*:/flag/*"
52 ],
53 "notResources": [
54 "string"
55 ],
56 "actions": [
57 "*"
58 ],
59 "notActions": [
60 "string"
61 ],
62 "role_name": "string"
63 }
64 }
65 ]
66 },
67 "approvalSettings": {
68 "required": true,
69 "bypassApprovalsForPendingChanges": false,
70 "minNumApprovals": 1,
71 "canReviewOwnRequest": false,
72 "canApplyDeclinedChanges": true,
73 "serviceKind": "launchdarkly",
74 "serviceConfig": {},
75 "requiredApprovalTags": [
76 "require-approval"
77 ],
78 "autoApplyApprovedChanges": true,
79 "serviceKindConfigurationId": "1ef45a85-218f-4428-a8b2-a97e5f56c258"
80 },
81 "resourceApprovalSettings": {}
82}
Update an environment. Updating an environment uses a [JSON patch](https://datatracker.ietf.org/doc/html/rfc6902) representation of the desired changes. To learn more, read [Updates](https://launchdarkly.com/docs/api#updates). To update fields in the environment object that are arrays, set the `path` to the name of the field and then append `/<array index>`. Using `/0` appends to the beginning of the array. ### Approval settings This request only returns the `approvalSettings` and `resourceApprovalSettings` if the [approvals](https://launchdarkly.com/docs/home/releases/approvals/) feature is enabled. Only the `canReviewOwnRequest`, `canApplyDeclinedChanges`, `minNumApprovals`, `required` and `requiredApprovalTagsfields` are editable. If you try to patch the environment by setting both `required` and `requiredApprovalTags`, the request fails and an error appears. You can specify either required approvals for all flags in an environment or those with specific tags, but not both.
Was this page helpful?
Previous

Experiments

Next
Built with

Update an environment. Updating an environment uses a JSON patch representation of the desired changes. To learn more, read Updates.

To update fields in the environment object that are arrays, set the path to the name of the field and then append /<array index>. Using /0 appends to the beginning of the array.

Approval settings

This request only returns the approvalSettings and resourceApprovalSettings if the approvals feature is enabled.

Only the canReviewOwnRequest, canApplyDeclinedChanges, minNumApprovals, required and requiredApprovalTagsfields are editable.

If you try to patch the environment by setting both required and requiredApprovalTags, the request fails and an error appears. You can specify either required approvals for all flags in an environment or those with specific tags, but not both.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
environmentKeystringRequiredformat: "string"
The environment key

Request

This endpoint expects a list of objects.
opstringRequired
The type of operation to perform
pathstringRequired
A JSON Pointer string specifying the part of the document to operate on
valueanyOptional
A JSON value used in "add", "replace", and "test" operations

Response

Environment response
_linksmap from strings to objects
The location and content type of related resources
_idstring

The ID for the environment. Use this as the client-side ID for authorization in some client-side SDKs, and to associate LaunchDarkly environments with CDN integrations in edge SDKs.

keystring

A project-unique key for the new environment

namestring

A human-friendly name for the new environment

apiKeystring

The SDK key for the environment. Use this for authorization in server-side SDKs.

mobileKeystring
The mobile key for the environment. Use this for authorization in mobile SDKs.
colorstring
The color used to indicate this environment in the UI
defaultTtlinteger

The default time (in minutes) that the PHP SDK can cache feature flag rules locally

secureModeboolean

Ensures that one end user of the client-side SDK cannot inspect the variations for another end user

defaultTrackEventsboolean
Enables tracking detailed information for new flags by default
requireCommentsboolean
Whether members who modify flags and segments through the LaunchDarkly user interface are required to add a comment
confirmChangesboolean
Whether members who modify flags and segments through the LaunchDarkly user interface are required to confirm those changes
tagslist of strings
A list of tags for this environment
criticalboolean
Whether the environment is critical
_accessobject
approvalSettingsobject
Details about the approval settings for flags in this environment
resourceApprovalSettingsmap from strings to objects

Details about the approval settings for other resources in this environment, organized by resource kind (for example, “aiconfig” and “segment”)

Errors

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