---
title: Duplicate a Flag
slug: feature-experimentation/api/duplicate-a-flag
docTags: 
createdAt: 2026-10-13T18:16:15.508Z
---

{
  "id": "o5XKe5TwBdqRSlCz15Ett",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/duplicate",
    "servers": [
      {
        "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/duplicate"
      }
    ],
    "name": "Duplicate a Flag",
    "description": "<p>Creates a new Flag in an Project, duplicating from an older flag.</p>\n<p>Required properties must be present in the request body.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "project_id",
          "type": "integer",
          "example": 12345,
          "description": "The project identifier"
        },
        {
          "kind": "required",
          "name": "flag_key",
          "type": "string",
          "example": "recurring_deposit",
          "description": "The Flag identifier"
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "FlagRequestBody",
          "schema": [
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "description": "",
              "example": "Flag used for driving customers to use recurring deposits by showing a graph of compound interest over time"
            },
            {
              "name": "is_permanent",
              "kind": "optional",
              "type": "boolean",
              "description": "<p>When true, marks the flag as intentionally permanent (e.g. a kill switch or operational toggle) so governance tooling excludes it from stale scoring and archive recommendations.</p>",
              "example": false,
              "default": false
            },
            {
              "name": "key",
              "kind": "required",
              "type": "string",
              "description": "",
              "example": "recurring_deposit"
            },
            {
              "name": "name",
              "kind": "optional",
              "type": "string",
              "description": "",
              "example": "Recurring Deposit"
            },
            {
              "name": "outlier_filtering_enabled",
              "kind": "optional",
              "type": "boolean",
              "description": "",
              "example": false,
              "default": false
            },
            {
              "name": "owner_user_id",
              "kind": "optional",
              "type": "string",
              "nullable": true,
              "description": "<p>Unique user ID of the flag owner. This is the user's unique identifier, not their email address. If not provided, defaults to the user making the request.</p>",
              "example": "1234-abcd-5678-efgh"
            },
            {
              "name": "team_ids",
              "kind": "optional",
              "type": "array",
              "description": "List of team IDs associated with this flag",
              "example": "[\"1234567890\",\"0987654321\"]",
              "default": [],
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "variable_definitions",
              "kind": "optional",
              "type": "map",
              "description": "",
              "example": "{\"advanced\":{\"default_value\":\"{\\n\\t\\\"hello\\\": 123\\n}\",\"description\":\"This variable is used to configure the advanced used for advanced purposes\",\"key\":\"advanced\",\"type\":\"json\"},\"amount\":{\"default_value\":\"0.0\",\"description\":\"This variable is used to configure the amount used for computing the discount\",\"key\":\"amount\",\"type\":\"double\"},\"message\":{\"default_value\":\"Use recurring deposits to compound interest\",\"description\":\"This variable is used to configure the message used for displaying the discount\",\"key\":\"message\",\"type\":\"string\"}}",
              "customType": "map<string, VariableDefinition>",
              "schema": []
            }
          ],
          "modelRef": "#/components/schemas/FlagRequestBody",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "apiKey",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        },
        {
          "id": "OAuth2",
          "name": "OAuth2",
          "kind": "optional",
          "type": "oauth2",
          "description": "Write applications that authenticate with the REST API via OAuth 2.0.",
          "oauth2Flows": {
            "authorizationCode": {
              "authorizationUrl": "https://app.optimizely.com/oauth2/authorize",
              "tokenUrl": "https://app.optimizely.com/oauth2/token",
              "scopes": {
                "all": "Grants all access"
              }
            }
          },
          "requiredScopes": [
            "read",
            "write"
          ]
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "<p>Successful retrieval, creation or update of a Flag.</p>\n<p>The response includes RESTful JSON (<a href=\"https://restfuljson.org/\" target=\"_blank\">https://restfuljson.org/</a>) styled links. If a\nlink is not present in the response, it indicates a user is not authorized to access\nthe related resource.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"account_id\":12345,\"archive_url\":\"...\",\"archived\":false,\"created_by_user_id\":\"testuser@optimizely.com\",\"created_time\":\"2019-05-08T00:00:00.000Z\",\"delete_url\":\"string\",\"description\":\"Flag used for driving customers to use recurring deposits by showing a graph of compound interest over time\",\"environments\":{\"development\":{\"disable_url\":\"...\",\"enable_url\":\"...\",\"enabled\":false,\"key\":\"development\",\"name\":\"Development\",\"priority\":2,\"rules_summary\":[{\"audience_ids\":[1],\"created_time\":\"2022-01-08T00:00:00.000Z\",\"days_running\":30,\"enabled\":true,\"key\":\"a/b\",\"name\":\"A/B Test\",\"primary_metric\":\"conversion_rate\",\"traffic_allocation\":100,\"type\":\"experiment\",\"updated_time\":\"2022-01-08T00:00:00.000Z\"}]},\"production\":{\"disable_url\":\"...\",\"enable_url\":\"...\",\"enabled\":false,\"key\":\"production\",\"name\":\"Production\",\"priority\":1,\"rules_detail\":[{\"audience_ids\":[1],\"created_time\":\"2022-01-08T00:00:00.000Z\",\"days_running\":30,\"enabled\":true,\"id\":123,\"key\":\"a/b\",\"name\":\"A/B Test\",\"primary_metric\":\"conversion_rate\",\"traffic_allocation\":100,\"type\":\"experiment\",\"updated_time\":\"2022-01-08T00:00:00.000Z\"}],\"rules_summary\":{\"a/b\":{\"keys\":[\"new_users\"]},\"targeted_delivery\":{\"keys\":[\"paid_users\",\"trial_users\"]}}}},\"id\":45633994,\"key\":\"recurring_deposit\",\"name\":\"Recurring Deposit\",\"outlier_filtering_enabled\":false,\"project_id\":12345,\"revision\":1,\"unarchive_url\":\"...\",\"update_url\":\"...\",\"updated_time\":\"2019-05-08T00:00:00.000Z\",\"url\":\"...\",\"urn\":\"flags.flag.optimizely.com::asdfsdf-2344-efadf03-343434-efrrr\",\"variable_definitions\":{\"advanced\":{\"default_value\":\"{\\n\\t\\\"hello\\\": 123\\n}\",\"description\":\"This variable is used to configure the advanced used for advanced purposes\",\"key\":\"advanced\",\"type\":\"json\"},\"amount\":{\"default_value\":\"0.0\",\"description\":\"This variable is used to configure the amount used for computing the discount\",\"key\":\"amount\",\"type\":\"double\"},\"message\":{\"default_value\":\"Use recurring deposits to compound interest\",\"description\":\"This variable is used to configure the message used for displaying the discount\",\"key\":\"message\",\"type\":\"string\"}}}",
            "description": "",
            "customType": "Flag",
            "schema": [
              {
                "name": "account_id",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "The ID of the Account this Flag belongs to",
                "format": "int64"
              },
              {
                "name": "archive_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "archived",
                "kind": "optional",
                "type": "boolean",
                "description": "",
                "example": false
              },
              {
                "name": "created_by_user_email",
                "kind": "optional",
                "type": "string",
                "readOnly": true,
                "description": "",
                "example": "testuser@optimizely.com"
              },
              {
                "name": "created_time",
                "kind": "required",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "",
                "example": "2019-05-08T00:00:00.000Z",
                "format": "date-time"
              },
              {
                "name": "delete_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "description": "",
                "example": "Flag used for driving customers to use recurring deposits by showing a graph of compound interest over time"
              },
              {
                "name": "environments",
                "kind": "required",
                "type": "map",
                "readOnly": true,
                "description": "",
                "example": "",
                "customType": "map<string, FlagEnvironment>",
                "schema": []
              },
              {
                "name": "id",
                "kind": "required",
                "type": "integer",
                "readOnly": true,
                "description": "",
                "example": 45633994
              },
              {
                "name": "is_permanent",
                "kind": "optional",
                "type": "boolean",
                "description": "<p>When true, marks the flag as intentionally permanent (e.g. a kill switch or operational toggle) so governance tooling excludes it from stale scoring and archive recommendations.</p>",
                "example": false,
                "default": false
              },
              {
                "name": "key",
                "kind": "required",
                "type": "string",
                "description": "",
                "example": "recurring_deposit"
              },
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": "",
                "example": "Recurring Deposit"
              },
              {
                "name": "outlier_filtering_enabled",
                "kind": "optional",
                "type": "boolean",
                "description": "",
                "example": false,
                "default": false
              },
              {
                "name": "owner_user_id",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": "<p>Unique user ID of the flag owner. This is the user's unique identifier, not their email address. If no value was provided during creation, this defaults to the user who created the flag.</p>",
                "example": "1234-abcd-5678-efgh"
              },
              {
                "name": "project_id",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "The ID of the Project this Flag belongs to",
                "format": "int64"
              },
              {
                "name": "revision",
                "kind": "optional",
                "type": "integer",
                "readOnly": true,
                "description": "Revision number for tracking changes"
              },
              {
                "name": "role",
                "kind": "optional",
                "type": "string",
                "readOnly": true,
                "description": "Granular permission role",
                "example": "admin"
              },
              {
                "name": "team_ids",
                "kind": "optional",
                "type": "array",
                "description": "List of team IDs associated with this flag",
                "example": "[\"1234567890\",\"0987654321\"]",
                "default": [],
                "itemType": "string",
                "customType": "string[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "unarchive_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "update_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "updated_time",
                "kind": "required",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "",
                "example": "2019-05-08T00:00:00.000Z",
                "format": "date-time"
              },
              {
                "name": "url",
                "kind": "required",
                "type": "object",
                "readOnly": true,
                "description": "Link to self",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "urn",
                "kind": "required",
                "type": "string",
                "readOnly": true,
                "description": "The URN for the Flag",
                "example": "flags.flag.optimizely.com::asdfsdf-2344-efadf03-343434-efrrr"
              },
              {
                "name": "variable_definitions",
                "kind": "optional",
                "type": "map",
                "description": "",
                "example": "",
                "default": {},
                "customType": "map<string, VariableDefinition>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/Flag",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Malformed requests and invalid parameter names and types",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "401",
        "description": "Invalid credentials",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "403",
        "description": "Do not have permission to perform the operation",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "dMYE3Ta2hALUKyrju15T1",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/duplicate \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"key\": \"recurring_deposit\",\n     \"team_ids\": []\n     }'"
        },
        {
          "id": "wmBdnk9W_cP2cu_AncrZv",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"key\": \"recurring_deposit\",\n   \"team_ids\": []\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/duplicate\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "voOVfdufe1ZAsdxYm5zph",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/duplicate\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"key\": \"recurring_deposit\",\n   \"team_ids\": []\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "y8QpNYimv9oc8iBhRvPc_",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/duplicate\"\n\npayload = json.dumps({\n   \"key\": \"recurring_deposit\",\n   \"team_ids\": []\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "dMYE3Ta2hALUKyrju15T1"
    },
    "results": {
      "languages": [
        {
          "id": "fa69YX1uHyZly6784qlbe",
          "language": "201",
          "code": "// Successful retrieval, creation or update of a Flag.\nThe response includes RESTful JSON (https://restfuljson.org/) styled links. If a\nlink is not present in the response, it indicates a user is not authorized to access\nthe related resource.\n{\n  \"account_id\": \"\",\n  \"archive_url\": {},\n  \"archived\": false,\n  \"created_by_user_email\": \"testuser@optimizely.com\",\n  \"created_time\": \"2019-05-08T00:00:00.000Z\",\n  \"delete_url\": {},\n  \"description\": \"Flag used for driving customers to use recurring deposits by showing a graph of compound interest over time\",\n  \"environments\": \"\",\n  \"id\": 45633994,\n  \"is_permanent\": false,\n  \"key\": \"recurring_deposit\",\n  \"name\": \"Recurring Deposit\",\n  \"outlier_filtering_enabled\": false,\n  \"owner_user_id\": \"1234-abcd-5678-efgh\",\n  \"project_id\": \"\",\n  \"revision\": 0,\n  \"role\": \"admin\",\n  \"team_ids\": [\n    \"\"\n  ],\n  \"unarchive_url\": {},\n  \"update_url\": {},\n  \"updated_time\": \"2019-05-08T00:00:00.000Z\",\n  \"url\": {},\n  \"urn\": \"flags.flag.optimizely.com::asdfsdf-2344-efadf03-343434-efrrr\",\n  \"variable_definitions\": \"\"\n}"
        },
        {
          "id": "yS-cC6xE8_AER8-VQXfNH",
          "language": "400",
          "code": "// Malformed requests and invalid parameter names and types\n"
        },
        {
          "id": "AqJJ7ZFODAPW0NQaUEaHA",
          "language": "401",
          "code": "// Invalid credentials\n"
        },
        {
          "id": "QiTcQy2d-T_qFAfvhsz-6",
          "language": "403",
          "code": "// Do not have permission to perform the operation\n"
        }
      ],
      "selectedLanguageId": "fa69YX1uHyZly6784qlbe"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}