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

Create environment

POST
/api/v2/projects/:projectKey/environments
POST
/api/v2/projects/:projectKey/environments
$curl -X POST https://app.launchdarkly.com/api/v2/projects/projectKey/environments \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "name": "My Environment",
> "key": "environment-key-123abc",
> "color": "DADBEE"
>}'
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}
> ### Approval settings > > You cannot configure approval settings when you create a new environment. Use [Update environment](https://launchdarkly.com/docs/api/environments/patch-environment) to update approval settings. > > The `approvalSettings` and `resourceApprovalSettings` keys are only returned when the [approvals](https://launchdarkly.com/docs/home/releases/approvals/) feature is enabled. Create a new environment in a specified project with a given name, key, swatch color, and default TTL.
Was this page helpful?
Previous

Delete environment

Next
Built with

Approval settings

You cannot configure approval settings when you create a new environment. Use Update environment to update approval settings.

The approvalSettings and resourceApprovalSettings keys are only returned when the approvals feature is enabled.

Create a new environment in a specified project with a given name, key, swatch color, and default TTL.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key

Request

This endpoint expects an object.
namestringRequired

A human-friendly name for the new environment

keystringRequired

A project-unique key for the new environment

colorstringRequired
A color to indicate this environment in the UI
defaultTtlintegerOptional

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

secureModebooleanOptional

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

defaultTrackEventsbooleanOptional
Enables tracking detailed information for new flags by default
confirmChangesbooleanOptional
Requires confirmation for all flag and segment changes via the UI in this environment
requireCommentsbooleanOptional
Requires comments for all flag and segment changes via the UI in this environment
tagslist of stringsOptional
Tags to apply to the new environment
sourceobjectOptional
Indicates that the new environment created will be cloned from the provided source environment
criticalbooleanOptional
Whether the environment is critical

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
403
Forbidden Error
404
Not Found Error
409
Conflict Error
429
Too Many Requests Error