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
    • Experiments
    • Feature Flags
      • POSTCopy feature flag
      • POSTCreate a feature flag
      • DELDelete feature flag
      • GETGet expiring context targets for feature flag
      • GETGet expiring user targets for feature flag
      • GETGet feature flag
      • GETGet feature flag status
      • GETGet flag status across environments
      • POSTGet migration safety issues
      • GETList feature flag statuses
      • GETList feature flags
      • PATCHUpdate expiring context targets on feature flag
      • PATCHUpdate expiring user targets on feature flag
      • PATCHUpdate feature flag
    • 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 overviewFeature Flags

Copy feature flag

POST
/api/v2/flags/:projectKey/:featureFlagKey/copy
POST
/api/v2/flags/:projectKey/:featureFlagKey/copy
$curl -X POST https://app.launchdarkly.com/api/v2/flags/projectKey/featureFlagKey/copy \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "source": {
> "key": "source-env-key-123abc",
> "currentVersion": 1
> },
> "target": {
> "key": "target-env-key-123abc",
> "currentVersion": 1
> },
> "comment": "optional comment"
>}'
1{
2 "name": "My Flag",
3 "kind": "boolean",
4 "key": "flag-key-123abc",
5 "_version": 1,
6 "creationDate": 1494437420312,
7 "variations": [
8 {
9 "value": null,
10 "_id": "e432f62b-55f6-49dd-a02f-eb24acf39d05"
11 },
12 {
13 "value": null,
14 "_id": "a00bf58d-d252-476c-b915-15a74becacb4"
15 }
16 ],
17 "temporary": true,
18 "tags": [
19 "example-tag"
20 ],
21 "_links": {
22 "parent": {
23 "href": "/api/v2/flags/my-project",
24 "type": "application/json"
25 },
26 "self": {
27 "href": "/api/v2/flags/my-project/my-flag",
28 "type": "application/json"
29 }
30 },
31 "experiments": {
32 "baselineIdx": 1,
33 "items": [
34 {
35 "metricKey": "my-metric",
36 "_metric": {
37 "_id": "5902deadbeef667524a01290",
38 "_versionId": "version-id-123abc",
39 "key": "metric-key-123abc",
40 "name": "My metric",
41 "kind": "custom",
42 "_links": {
43 "parent": {
44 "href": "/api/v2/metrics/my-project",
45 "type": "application/json"
46 },
47 "self": {
48 "href": "/api/v2/metrics/my-project/my-metric",
49 "type": "application/json"
50 }
51 },
52 "tags": [],
53 "_creationDate": 1628192791148,
54 "dataSource": {
55 "key": "string",
56 "environmentKey": "string",
57 "_name": "string",
58 "_integrationKey": "string"
59 },
60 "experimentCount": 0,
61 "metricGroupCount": 0,
62 "activeExperimentCount": 2,
63 "activeGuardedRolloutCount": 1,
64 "_version": 1,
65 "_attachedFlagCount": 0,
66 "_site": {},
67 "_access": {
68 "denied": [
69 {
70 "action": "string",
71 "reason": {
72 "effect": "allow",
73 "resources": [
74 "proj/*:env/*;qa_*:/flag/*"
75 ],
76 "notResources": [
77 "string"
78 ],
79 "actions": [
80 "*"
81 ],
82 "notActions": [
83 "string"
84 ],
85 "role_name": "string"
86 }
87 }
88 ],
89 "allowed": [
90 {
91 "action": "string",
92 "reason": {
93 "effect": "allow",
94 "resources": [
95 "proj/*:env/*;qa_*:/flag/*"
96 ],
97 "notResources": [
98 "string"
99 ],
100 "actions": [
101 "*"
102 ],
103 "notActions": [
104 "string"
105 ],
106 "role_name": "string"
107 }
108 }
109 ]
110 },
111 "lastModified": {
112 "date": "2021-08-05T19:46:31.148082Z"
113 },
114 "maintainerId": "569fdeadbeef1644facecafe",
115 "_maintainer": {
116 "_links": {
117 "self": {
118 "href": "/api/v2/members/569f183514f4432160000007",
119 "type": "application/json"
120 }
121 },
122 "_id": "569f183514f4432160000007",
123 "role": "admin",
124 "email": "ariel@acme.com"
125 },
126 "description": "string",
127 "category": "Error monitoring",
128 "isNumeric": true,
129 "successCriteria": "HigherThanBaseline",
130 "unit": "string",
131 "eventKey": "Order placed",
132 "analysisUnits": [
133 "user"
134 ],
135 "filters": {
136 "type": "contextAttribute",
137 "op": "in",
138 "values": [
139 "JP"
140 ],
141 "negate": false
142 },
143 "unitAggregationType": "average",
144 "analysisType": "mean",
145 "percentileValue": 95,
146 "eventDefault": {
147 "disabled": true,
148 "value": 0
149 },
150 "lastSeen": 1,
151 "archived": true,
152 "archivedAt": 1609459200000,
153 "selector": "string",
154 "urls": [
155 "[{\"kind\":\"exact\",\"url\":\"https://www.example.com/page1\"}]"
156 ],
157 "windowStartOffset": 1,
158 "windowEndOffset": 1,
159 "winsorLowerPercentile": 1,
160 "winsorUpperPercentile": 99.5,
161 "winsorExcludeImputed": false,
162 "traceQuery": "service.name = \"checkout\"",
163 "traceValueLocation": "duration",
164 "randomizationUnits": [
165 "user"
166 ]
167 },
168 "environments": [
169 "production",
170 "test",
171 "my-environment"
172 ],
173 "_environmentSettings": {}
174 }
175 ]
176 },
177 "customProperties": "{\"jira.issues\":{\"name\":\"Jira issues\",\"value\":[\"is-123\",\"is-456\"]}}",
178 "archived": false,
179 "description": "This flag controls the example widgets",
180 "clientSideAvailability": {},
181 "maintainerId": "569f183514f4432160000007",
182 "_maintainer": {
183 "_links": {
184 "self": {
185 "href": "/api/v2/members/569f183514f4432160000007",
186 "type": "application/json"
187 }
188 },
189 "_id": "569f183514f4432160000007",
190 "role": "admin",
191 "email": "ariel@acme.com",
192 "firstName": "Ariel",
193 "lastName": "Flores"
194 },
195 "maintainerTeamKey": "team-1",
196 "_maintainerTeam": {
197 "key": "team-key-123abc",
198 "name": "Example team",
199 "_links": {
200 "parent": {
201 "href": "/api/v2/teams",
202 "type": "application/json"
203 },
204 "roles": {
205 "href": "/api/v2/teams/example-team/roles",
206 "type": "application/json"
207 },
208 "self": {
209 "href": "/api/v2/teams/example-team",
210 "type": "application/json"
211 }
212 }
213 },
214 "archivedDate": 1494437420312,
215 "deprecated": false,
216 "deprecatedDate": 1494437420312,
217 "defaults": {
218 "onVariation": 0,
219 "offVariation": 1
220 },
221 "_purpose": "string",
222 "migrationSettings": {
223 "contextKind": "device",
224 "stageCount": 6
225 },
226 "environments": {
227 "my-environment": {
228 "on": false,
229 "archived": false,
230 "salt": "61eddeadbeef4da1facecafe3a60a397",
231 "sel": "810edeadbeef4844facecafe438f2999492",
232 "lastModified": 1627071171347,
233 "version": 1,
234 "_site": {
235 "href": "/default/my-environment/features/client-side-flag",
236 "type": "text/html"
237 },
238 "_environmentName": "My Environment",
239 "trackEvents": false,
240 "trackEventsFallthrough": false,
241 "targets": [
242 {
243 "values": [
244 "user-key-123abc"
245 ],
246 "variation": 0,
247 "contextKind": "user"
248 }
249 ],
250 "contextTargets": [
251 {
252 "values": [
253 "device-key-123abc"
254 ],
255 "variation": 0,
256 "contextKind": "device"
257 }
258 ],
259 "rules": [],
260 "fallthrough": {
261 "variation": 0
262 },
263 "offVariation": 1,
264 "prerequisites": [],
265 "_summary": {
266 "variations": {
267 "0": {
268 "rules": 0,
269 "nullRules": 0,
270 "targets": 1,
271 "contextTargets": 1,
272 "isFallthrough": true
273 },
274 "1": {
275 "rules": 0,
276 "nullRules": 0,
277 "targets": 0,
278 "isOff": true
279 }
280 },
281 "prerequisites": 0
282 }
283 }
284 },
285 "includeInSnippet": true,
286 "goalIds": []
287}
> ### Copying flag settings is an Enterprise feature > > Copying flag settings is available to customers on an Enterprise plan. To learn more, [read about our pricing](https://launchdarkly.com/pricing/). To upgrade your plan, [contact Sales](https://launchdarkly.com/contact-sales/). Copy flag settings from a source environment to a target environment. By default, this operation copies the entire flag configuration. You can use the `includedActions` or `excludedActions` to specify that only part of the flag configuration is copied. If you provide the optional `currentVersion` of a flag, this operation tests to ensure that the current flag version in the environment matches the version you've specified. The operation rejects attempts to copy flag settings if the environment's current version of the flag does not match the version you've specified. You can use this to enforce optimistic locking on copy attempts.
Was this page helpful?
Previous

Create a feature flag

Next
Built with

Copying flag settings is an Enterprise feature

Copying flag settings is available to customers on an Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.

Copy flag settings from a source environment to a target environment.

By default, this operation copies the entire flag configuration. You can use the includedActions or excludedActions to specify that only part of the flag configuration is copied.

If you provide the optional currentVersion of a flag, this operation tests to ensure that the current flag version in the environment matches the version you’ve specified. The operation rejects attempts to copy flag settings if the environment’s current version of the flag does not match the version you’ve specified. You can use this to enforce optimistic locking on copy attempts.

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key
featureFlagKeystringRequiredformat: "string"
The feature flag key. The key identifies the flag in your code.

Request

This endpoint expects an object.
sourceobjectRequired
The source environment
targetobjectRequired
The target environment
commentstringOptional
Optional comment
includedActionslist of enumsOptional

Optional list of the flag changes to copy from the source environment to the target environment. You may include either includedActions or excludedActions, but not both. If you include neither, then all flag changes will be copied.

excludedActionslist of enumsOptional

Optional list of the flag changes NOT to copy from the source environment to the target environment. You may include either includedActions or excludedActions, but not both. If you include neither, then all flag changes will be copied.

Response

Global flag response
namestring

A human-friendly name for the feature flag

kindenum
Kind of feature flag
Allowed values:
keystring
A unique key used to reference the flag in your code
_versioninteger
Version of the feature flag
creationDatelong
Timestamp of flag creation date
variationslist of objects
An array of possible variations for the flag
temporaryboolean
Whether the flag is a temporary flag
tagslist of strings
Tags for the feature flag
_linksmap from strings to objects
The location and content type of related resources
experimentsobject
Experimentation data for the feature flag
customPropertiesmap from strings to objects
Metadata attached to the feature flag, in the form of the property key associated with a name and array of values for the metadata to associate with this flag. Typically used to store data related to an integration.
archivedboolean
Boolean indicating if the feature flag is archived
descriptionstring
Description of the feature flag
clientSideAvailabilityobject

Which type of client-side SDKs the feature flag is available to

maintainerIdstring
Associated maintainerId for the feature flag
_maintainerobject
Associated maintainer member info for the feature flag
maintainerTeamKeystring
The key of the associated team that maintains this feature flag
_maintainerTeamobject
Associated maintainer team info for the feature flag
archivedDatelong
If archived is true, date of archive
deprecatedboolean
Boolean indicating if the feature flag is deprecated
deprecatedDatelong
If deprecated is true, date of deprecation
defaultsobject
The indices, from the array of variations, for the variations to serve by default when targeting is on and when targeting is off. These variations will be used for this flag in new environments. If omitted, the first and last variation will be used.
_purposestring
migrationSettingsobject

Migration-related settings for the flag

environmentsmap from strings to objects

Details on the environments for this flag. Only returned if the request is filtered by environment, using the filterEnv query parameter.

includeInSnippetbooleanDeprecated

Deprecated, use clientSideAvailability. Whether this flag should be made available to the client-side JavaScript SDK

goalIdslist of stringsDeprecated

Deprecated, use experiments instead

Errors

400
Bad Request Error
401
Unauthorized Error
405
Method Not Allowed Error
409
Conflict Error
429
Too Many Requests Error