---
title: "Copy feature flag"
method: POST
path: "/api/v2/flags/{projectKey}/{featureFlagKey}/copy"
tags: ["Feature flags"]
---

# Copy feature flag

`POST /api/v2/flags/{projectKey}/{featureFlagKey}/copy`

> ### 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.

## Path parameters

- `projectKey` string, string, required — The project key
- `featureFlagKey` string, string, required — The feature flag key. The key identifies the flag in your code.

## Request body

- FlagCopyConfigPost
  - `source` FlagCopyConfigEnvironment, required
    - `key` string, required — The environment key
    - `currentVersion` integer — Optional flag version. If you include this, the operation only succeeds if the current flag version in the environment matches this version.
  - `target` FlagCopyConfigEnvironment, required
    - `key` string, required — The environment key
    - `currentVersion` integer — Optional flag version. If you include this, the operation only succeeds if the current flag version in the environment matches this version.
  - `comment` string — Optional comment
  - `includedActions` string[] — Optional list of the flag changes to copy from the source environment to the target environment. You may include either <code>includedActions</code> or <code>excludedActions</code>, but not both. If you include neither, then all flag changes will be copied.
  - `excludedActions` string[] — Optional list of the flag changes NOT to copy from the source environment to the target environment. You may include either <code>includedActions</code> or <code>excludedActions</code>, but not both. If you include neither, then all flag changes will be copied.

## Response `201`

Global flag response

- FeatureFlag
  - `name` string, required — A human-friendly name for the feature flag
  - `kind` 'boolean' | 'multivariate', required — Kind of feature flag
  - `description` string — Description of the feature flag
  - `key` string, required — A unique key used to reference the flag in your code
  - `_version` integer, required — Version of the feature flag
  - `creationDate` integer, required
  - `includeInSnippet` boolean — Deprecated, use <code>clientSideAvailability</code>. Whether this flag should be made available to the client-side JavaScript SDK
  - `clientSideAvailability` ClientSideAvailability
    - `usingMobileKey` boolean
    - `usingEnvironmentId` boolean
  - `variations` Variation[], required — An array of possible variations for the flag
    - `_id` string — The ID of the variation. Leave empty when you are creating a flag.
    - `value` unknown, required
    - `description` string — Description of the variation. Defaults to an empty string, but is omitted from the response if not set.
    - `name` string — A human-friendly name for the variation. Defaults to an empty string, but is omitted from the response if not set.
  - `temporary` boolean, required — Whether the flag is a temporary flag
  - `tags` string[], required — Tags for the feature flag
  - `_links` object, required — The location and content type of related resources
  - `maintainerId` string — Associated maintainerId for the feature flag
  - `_maintainer` MemberSummary
    - `_links` object, required — The location and content type of related resources
    - `_id` string, required — The member's ID
    - `firstName` string — The member's first name
    - `lastName` string — The member's last name
    - `role` string, required — The member's base role. If the member has no additional roles, this role will be in effect.
    - `email` string, required — The member's email address
  - `maintainerTeamKey` string — The key of the associated team that maintains this feature flag
  - `_maintainerTeam` MaintainerTeam
    - `key` string, required — The key of the maintainer team
    - `name` string, required — A human-friendly name for the maintainer team
    - `_links` object — The location and content type of related resources
  - `goalIds` string[] — Deprecated, use <code>experiments</code> instead
  - `experiments` ExperimentInfoRep, required
    - `baselineIdx` integer, required
    - `items` LegacyExperimentRep[], required
      - `metricKey` string
      - `_metric` MetricListingRep
        - `experimentCount` integer — The number of experiments using this metric
        - `metricGroupCount` integer — The number of metric groups using this metric
        - `activeExperimentCount` integer — The number of active experiments using this metric
        - `activeGuardedRolloutCount` integer — The number of active guarded rollouts using this metric
        - `_id` string, required — The ID of this metric
        - `_versionId` string, required — The version ID of the metric
        - `_version` integer — Version of the metric
        - `key` string, required — A unique key to reference the metric
        - `name` string, required — A human-friendly name for the metric
        - `kind` 'pageview' | 'click' | 'custom', required — The kind of event the metric tracks
        - `_attachedFlagCount` integer — The number of feature flags currently attached to this metric
        - `_links` object, required — The location and content type of related resources
        - `_site` Link
          - `href` string
          - `type` string
        - `_access` Access
          - `denied` AccessDenied[], required
            - `action` string, required
            - `reason` AccessDeniedReason, required
              - …
          - `allowed` AccessAllowedRep[], required
            - `action` string, required
            - `reason` AccessAllowedReason, required
              - …
        - `tags` string[], required — Tags for the metric
        - `_creationDate` integer, required
        - `lastModified` Modification
          - `date` string, date-time
        - `maintainerId` string — The ID of the member who maintains this metric
        - `_maintainer` MemberSummary
          - `_links` object, required — The location and content type of related resources
          - `_id` string, required — The member's ID
          - `firstName` string — The member's first name
          - `lastName` string — The member's last name
          - `role` string, required — The member's base role. If the member has no additional roles, this role will be in effect.
          - `email` string, required — The member's email address
        - `description` string — Description of the metric
        - `category` string — The category of the metric
        - `isNumeric` boolean — For custom metrics, whether to track numeric changes in value against a baseline (<code>true</code>) or to track a conversion when an end user takes an action (<code>false</code>).
        - `successCriteria` 'HigherThanBaseline' | 'LowerThanBaseline' — For custom metrics, the success criteria
        - `unit` string — For numeric custom metrics, the unit of measure
        - `eventKey` string — For custom metrics, the event key to use in your code
        - `randomizationUnits` string[] — An array of randomization units allowed for this metric
        - `filters` Filter
          - `type` 'group' | 'contextAttribute' | 'eventProperty', required — Filter type. One of [contextAttribute, eventProperty, group]
          - `attribute` string — If not a group node, the context attribute name or event property name to filter on
          - `op` string, required
          - `values` unknown[], required — The context attribute / event property values or group member nodes
            - unknown
          - `contextKind` string — For context attribute filters, the context kind.
          - `negate` boolean, required — If set, then take the inverse of the operator. 'in' becomes 'not in'.
        - `unitAggregationType` 'average' | 'sum' — The method by which multiple unit event values are aggregated
        - `analysisType` 'mean' | 'percentile' — The method for analyzing metric events
        - `percentileValue` integer — The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when <code>analysisType</code> is <code>percentile</code>.
        - `eventDefault` MetricEventDefaultRep
          - `disabled` boolean — Whether to disable defaulting missing unit events when calculating results. Defaults to false
          - `value` number — The default value applied to missing unit events. Set to 0 when <code>disabled</code> is false. No other values are currently supported.
        - `dataSource` MetricDataSourceRefRep, required
          - `key` string, required
          - `environmentKey` string
          - `_name` string
          - `_integrationKey` string
        - `lastSeen` integer
        - `archived` boolean — Whether the metric version is archived
        - `archivedAt` integer
        - `selector` string — For click metrics, the CSS selectors
        - `urls` UrlMatcher[]
      - `environments` string[]
      - `_environmentSettings` object
  - `customProperties` CustomProperties, required
  - `archived` boolean, required — Boolean indicating if the feature flag is archived
  - `archivedDate` integer
  - `deprecated` boolean — Boolean indicating if the feature flag is deprecated
  - `deprecatedDate` integer
  - `defaults` Defaults
    - `onVariation` integer, required — The index, from the array of variations for this flag, of the variation to serve by default when targeting is on.
    - `offVariation` integer, required — The index, from the array of variations for this flag, of the variation to serve by default when targeting is off.
  - `_purpose` string
  - `migrationSettings` FlagMigrationSettingsRep
    - `contextKind` string — The context kind targeted by this migration flag. Only applicable for six-stage migrations.
    - `stageCount` integer — The number of stages for this migration flag
  - `environments` object — Details on the environments for this flag. Only returned if the request is filtered by environment, using the <code>filterEnv</code> query parameter.

## Other responses

- `400` — Invalid request
- `401` — Invalid access token
- `405` — Method not allowed
- `409` — Status conflict
- `429` — Rate limited

## Changes

- **2026-02-28** `69c5c9aafe78` — 10 info
  - added the optional property `environments/additionalProperties/rules/items/disabled` to the response with the `201` status
  - added the optional property `experiments/items/items/_metric/_version` to the response with the `201` status
  - added the optional property `experiments/items/items/_metric/activeExperimentCount` to the response with the `201` status
  - added the optional property `experiments/items/items/_metric/activeGuardedRolloutCount` to the response with the `201` status
  - …6 more

[Change history](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api/changes/api/v2/flags/:projectKey/:featureFlagKey/copy/post.md)

---

[API](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api.md) · [All operations](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/launchdarkly/launchdarkly-rest-api/revisions/69c5c9aafe78/schema)
