---
title: Update Flags
slug: feature-experimentation/api/update-flags
docTags: 
createdAt: 2026-08-28T15:54:06.731Z
---

{
  "id": "tjUTSf8pZBPU9-m3PjiLB",
  "type": "api-oas-v2",
  "data": {
    "method": "PATCH",
    "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/flags",
    "servers": [
      {
        "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/flags"
      }
    ],
    "name": "Update Flags",
    "description": "Update one or more Flags in a project using a json patch structure.\n\nProperties that are readOnly that are present in the request body will be ignored as well as\nunknown properties.\n",
    "contentType": "application/json-patch+json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "project_id",
          "type": "integer",
          "example": 12345,
          "description": "The project identifier"
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [],
      "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": "200",
        "description": "<p>Successful update, archive or unarchive of Flags.</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": "{\"recurring_deposit\":{\"account_id\":12345,\"archive_url\":\"...\",\"archived\":false,\"created_time\":\"2019-05-08T00:00:00.000Z\",\"delete_url\":\"string\",\"description\":\"Updated description for recurring deposit flag\",\"environments\":{\"development\":{\"disable_url\":\"...\",\"enable_url\":\"...\",\"enabled\":false,\"is_primary\":false,\"key\":\"development\",\"name\":\"Development\",\"priority\":2,\"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\"]}}},\"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,\"distribution_mode\":\"manual\",\"enabled\":true,\"fetch_results_ui_url\":\"...\",\"id\":123,\"key\":\"a/b\",\"layer_experiment_id\":345,\"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,\"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": "Map of flags that include flag key as key and flag payload as value.",
            "customType": "FlagMap",
            "schema": [],
            "modelRef": "#/components/schemas/FlagMap",
            "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
      },
      {
        "statusCode": "404",
        "description": "Not found. No content",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "409",
        "description": "Conflicting resource state with requested action",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "ETgiGC6n8r5mJovaUCEGh",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request PATCH \\\n     --url https://api.optimizely.com/flags/v1//projects/{project_id}/flags \\\n     --header 'accept: application/json'"
        },
        {
          "id": "0cFwV9QXe8Ql-9FZMnyYz",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json-patch+json\");\n\nvar requestOptions = {\n   method: 'PATCH',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.optimizely.com/flags/v1//projects/{project_id}/flags\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "S6ajV4Fargi4LXdWvnmeT",
          "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\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Patch.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json-patch+json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "wspYfDV2DQBfWJrZhMrV_",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/flags/v1//projects/{project_id}/flags\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json-patch+json'\n}\n\nresponse = requests.request(\"PATCH\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "ETgiGC6n8r5mJovaUCEGh"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful update, archive or unarchive of Flags.\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{}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Malformed requests and invalid parameter names and types\n"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Invalid credentials\n"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// Do not have permission to perform the operation\n"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// Not found. No content\n"
        },
        {
          "id": "response-5-409",
          "language": "409",
          "code": "// Conflicting resource state with requested action\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}