---
title: Create an approval policy
slug: feature-experimentation/api/create-an-approval-policy
docTags: 
createdAt: 2026-10-13T18:16:15.508Z
---

{
  "id": "hPI9Psg_NsER5D3v7qyR8",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "http://localhost:3002//projects/{project_id}/environments/{environment_id}/policies",
    "servers": [
      {
        "url": "http://localhost:3002//projects/{project_id}/environments/{environment_id}/policies",
        "description": "Local server"
      },
      {
        "url": "https://api.app.optimizely.com/flags-scheduling/projects/{project_id}/environments/{environment_id}/policies",
        "description": "Production server"
      }
    ],
    "name": "Create an approval policy",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "project_id",
          "type": "integer",
          "description": ""
        },
        {
          "kind": "required",
          "name": "environment_id",
          "type": "integer",
          "description": ""
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "PolicyCreateRequest",
          "schema": [
            {
              "name": "name",
              "kind": "required",
              "type": "string",
              "description": "The name of the policy"
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "description": "A description of the policy"
            },
            {
              "name": "approver_assignment_mode",
              "kind": "optional",
              "type": "string",
              "description": "How approvers are assigned to approval requests",
              "modelRef": "#/components/schemas/ApproverAssignmentMode",
              "customType": "ApproverAssignmentMode",
              "schema": []
            },
            {
              "name": "is_default",
              "kind": "required",
              "type": "boolean",
              "description": "<p>Whether this is the environment-level default policy</p>"
            },
            {
              "name": "default_preferences",
              "kind": "required",
              "type": "object",
              "description": "Change surfaces that require approval",
              "modelRef": "#/components/schemas/PolicyDefaultPreferences",
              "customType": "PolicyDefaultPreferences",
              "schema": [
                {
                  "name": "audiences",
                  "kind": "optional",
                  "type": "boolean",
                  "description": ""
                },
                {
                  "name": "metrics",
                  "kind": "optional",
                  "type": "boolean",
                  "description": ""
                },
                {
                  "name": "ramp_perc",
                  "kind": "optional",
                  "type": "boolean",
                  "description": ""
                },
                {
                  "name": "rules",
                  "kind": "optional",
                  "type": "boolean",
                  "description": ""
                },
                {
                  "name": "ruleset",
                  "kind": "optional",
                  "type": "boolean",
                  "description": ""
                },
                {
                  "name": "variations",
                  "kind": "optional",
                  "type": "boolean",
                  "description": ""
                }
              ]
            },
            {
              "name": "approvers",
              "kind": "required",
              "type": "array",
              "description": "List of approvers",
              "modelRef": "#/components/schemas/PolicyApproverInput",
              "customType": "PolicyApproverInput[]",
              "schema": [
                {
                  "name": "type",
                  "kind": "required",
                  "type": "string<user | team>",
                  "description": "The type of approver",
                  "enum": [
                    "user",
                    "team"
                  ]
                },
                {
                  "name": "email",
                  "kind": "optional",
                  "type": "string",
                  "description": "<p>Email of the approver (when type is user)</p>"
                },
                {
                  "name": "team_id",
                  "kind": "optional",
                  "type": "string",
                  "description": "<p>ID of the approver team (when type is team)</p>"
                }
              ]
            },
            {
              "name": "notification_recipients",
              "kind": "optional",
              "type": "array",
              "description": "<p>List of notification recipients (users and teams)</p>",
              "modelRef": "#/components/schemas/PolicyApproverInput",
              "customType": "PolicyApproverInput[]",
              "schema": [
                {
                  "name": "type",
                  "kind": "required",
                  "type": "string<user | team>",
                  "description": "The type of approver",
                  "enum": [
                    "user",
                    "team"
                  ]
                },
                {
                  "name": "email",
                  "kind": "optional",
                  "type": "string",
                  "description": "<p>Email of the approver (when type is user)</p>"
                },
                {
                  "name": "team_id",
                  "kind": "optional",
                  "type": "string",
                  "description": "<p>ID of the approver team (when type is team)</p>"
                }
              ]
            },
            {
              "name": "entities",
              "kind": "optional",
              "type": "array",
              "description": "Entity approval settings for this policy",
              "modelRef": "#/components/schemas/PolicyEntityInput",
              "customType": "PolicyEntityInput[]",
              "schema": [
                {
                  "name": "operation",
                  "kind": "required",
                  "type": "string<add | replace | remove>",
                  "description": "Operation for the entity",
                  "enum": [
                    "add",
                    "replace",
                    "remove"
                  ]
                },
                {
                  "name": "entity_key",
                  "kind": "required",
                  "type": "string",
                  "description": "Key of the entity",
                  "minLength": 1
                },
                {
                  "name": "entity_id",
                  "kind": "required",
                  "type": "integer",
                  "description": "ID of the entity"
                },
                {
                  "name": "preferences",
                  "kind": "optional",
                  "type": "map",
                  "description": "<p>Preference flags for the entity (audiences, metrics, ramp_perc, rules, ruleset, variations)</p>",
                  "example": "",
                  "customType": "map<string, boolean>",
                  "schema": []
                }
              ]
            }
          ],
          "modelRef": "#/components/schemas/PolicyCreateRequest",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "BearerAuth",
          "name": "BearerAuth",
          "kind": "optional",
          "type": "http",
          "description": "<p>To get a personal token, see <a href=\"https://docs.developers.optimizely.com/web/docs/personal-token\" target=\"_blank\">https://docs.developers.optimizely.com/web/docs/personal-token</a></p>",
          "scheme": "bearer"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "Policy created successfully",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "PolicyResponse",
            "schema": [
              {
                "name": "id",
                "kind": "required",
                "type": "integer",
                "description": "The unique identifier for the policy"
              },
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": "The name of the policy"
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "description": "A description of the policy"
              },
              {
                "name": "approver_assignment_mode",
                "kind": "optional",
                "type": "string",
                "description": "How approvers are assigned to approval requests",
                "modelRef": "#/components/schemas/ApproverAssignmentMode",
                "customType": "ApproverAssignmentMode",
                "schema": []
              },
              {
                "name": "entity_type",
                "kind": "required",
                "type": "string<flag | ruleset>",
                "description": "The policy's entity type",
                "enum": [
                  "flag",
                  "ruleset"
                ]
              },
              {
                "name": "environment_id",
                "kind": "required",
                "type": "integer",
                "description": "The environment this policy belongs to"
              },
              {
                "name": "project_id",
                "kind": "required",
                "type": "integer",
                "description": "The project this policy belongs to"
              },
              {
                "name": "is_default",
                "kind": "required",
                "type": "boolean",
                "description": "<p>Whether this is the environment-level default policy</p>"
              },
              {
                "name": "default_preferences",
                "kind": "required",
                "type": "object",
                "description": "Change surfaces that require approval",
                "modelRef": "#/components/schemas/PolicyDefaultPreferences",
                "customType": "PolicyDefaultPreferences",
                "schema": [
                  {
                    "name": "audiences",
                    "kind": "optional",
                    "type": "boolean",
                    "description": ""
                  },
                  {
                    "name": "metrics",
                    "kind": "optional",
                    "type": "boolean",
                    "description": ""
                  },
                  {
                    "name": "ramp_perc",
                    "kind": "optional",
                    "type": "boolean",
                    "description": ""
                  },
                  {
                    "name": "rules",
                    "kind": "optional",
                    "type": "boolean",
                    "description": ""
                  },
                  {
                    "name": "ruleset",
                    "kind": "optional",
                    "type": "boolean",
                    "description": ""
                  },
                  {
                    "name": "variations",
                    "kind": "optional",
                    "type": "boolean",
                    "description": ""
                  }
                ]
              },
              {
                "name": "approvers",
                "kind": "required",
                "type": "array",
                "description": "List of approvers for this policy",
                "modelRef": "#/components/schemas/PolicyApprover",
                "customType": "PolicyApprover[]",
                "schema": [
                  {
                    "name": "type",
                    "kind": "required",
                    "type": "string<user | team>",
                    "description": "The type of approver",
                    "enum": [
                      "user",
                      "team"
                    ]
                  },
                  {
                    "name": "email",
                    "kind": "optional",
                    "type": "string",
                    "description": "<p>Email of the approver (when type is user)</p>"
                  },
                  {
                    "name": "team_id",
                    "kind": "optional",
                    "type": "string",
                    "description": "<p>ID of the approver team (when type is team)</p>"
                  },
                  {
                    "name": "team_name",
                    "kind": "optional",
                    "type": "string",
                    "description": "<p>Name of the approver team (when type is team)</p>"
                  }
                ]
              },
              {
                "name": "notification_recipients",
                "kind": "optional",
                "type": "array",
                "description": "<p>List of notification recipients (users and teams)</p>",
                "modelRef": "#/components/schemas/PolicyApprover",
                "customType": "PolicyApprover[]",
                "schema": [
                  {
                    "name": "type",
                    "kind": "required",
                    "type": "string<user | team>",
                    "description": "The type of approver",
                    "enum": [
                      "user",
                      "team"
                    ]
                  },
                  {
                    "name": "email",
                    "kind": "optional",
                    "type": "string",
                    "description": "<p>Email of the approver (when type is user)</p>"
                  },
                  {
                    "name": "team_id",
                    "kind": "optional",
                    "type": "string",
                    "description": "<p>ID of the approver team (when type is team)</p>"
                  },
                  {
                    "name": "team_name",
                    "kind": "optional",
                    "type": "string",
                    "description": "<p>Name of the approver team (when type is team)</p>"
                  }
                ]
              },
              {
                "name": "entities",
                "kind": "required",
                "type": "array",
                "description": "Entity approval settings associated with this policy",
                "modelRef": "#/components/schemas/PolicyEntity",
                "customType": "PolicyEntity[]",
                "schema": [
                  {
                    "name": "id",
                    "kind": "required",
                    "type": "integer",
                    "description": "The entity record ID"
                  },
                  {
                    "name": "entity_id",
                    "kind": "required",
                    "type": "integer",
                    "description": "The flag ID"
                  },
                  {
                    "name": "entity_key",
                    "kind": "required",
                    "type": "string",
                    "description": "The flag key"
                  },
                  {
                    "name": "type",
                    "kind": "required",
                    "type": "string",
                    "description": "<p>The entity type (e.g. flag)</p>"
                  },
                  {
                    "name": "preferences",
                    "kind": "required",
                    "type": "map",
                    "description": "Preference overrides for this entity",
                    "example": "",
                    "customType": "map<string, boolean>",
                    "schema": []
                  },
                  {
                    "name": "archived",
                    "kind": "required",
                    "type": "boolean",
                    "description": "Whether the entity is archived"
                  }
                ]
              },
              {
                "name": "created_at",
                "kind": "required",
                "type": "string<date-time>",
                "description": "Timestamp when the policy was created",
                "format": "date-time"
              },
              {
                "name": "updated_at",
                "kind": "required",
                "type": "string<date-time>",
                "description": "Timestamp when the policy was last updated",
                "format": "date-time"
              },
              {
                "name": "revision",
                "kind": "optional",
                "type": "integer",
                "description": "Revision number for optimistic locking"
              },
              {
                "name": "archived",
                "kind": "optional",
                "type": "boolean",
                "description": "Whether the policy is archived"
              }
            ],
            "modelRef": "#/components/schemas/PolicyResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "Not Authenticated",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "details",
                "kind": "required",
                "type": "string",
                "description": "Details of Error."
              },
              {
                "name": "status",
                "kind": "required",
                "type": "integer",
                "description": "Status code of the response.",
                "example": 400
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "422",
        "description": "Validation Error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "HTTPValidationError",
            "schema": [
              {
                "name": "detail",
                "kind": "optional",
                "type": "array",
                "description": "",
                "modelRef": "#/components/schemas/ValidationError",
                "customType": "ValidationError[]",
                "schema": [
                  {
                    "name": "loc",
                    "kind": "required",
                    "type": "array",
                    "description": "Path to the invalid value",
                    "example": "",
                    "itemType": "object",
                    "customType": "object[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "msg",
                    "kind": "required",
                    "type": "string",
                    "description": "Error message"
                  },
                  {
                    "name": "type",
                    "kind": "required",
                    "type": "string",
                    "description": "Error type"
                  }
                ]
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "integer",
                "description": "Status code of the response.",
                "example": 422
              }
            ],
            "modelRef": "#/components/schemas/HTTPValidationError",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "fltAVFcOBOnyAoH14Da4T",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url http://localhost:3002//projects/{project_id}/environments/{environment_id}/policies \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"name\": \"\",\n     \"is_default\": \"\",\n     \"default_preferences\": {},\n     \"approvers\": [\n     {\n     \"type\": \"\"\n     }\n     ],\n     \"notification_recipients\": [\n     {\n     \"type\": \"\"\n     }\n     ],\n     \"entities\": [\n     {\n     \"operation\": \"\",\n     \"entity_key\": \"\",\n     \"entity_id\": \"\"\n     }\n     ]\n     }'"
        },
        {
          "id": "qDZSbxMWCE2-BCebgLO46",
          "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   \"name\": \"\",\n   \"is_default\": \"\",\n   \"default_preferences\": {},\n   \"approvers\": [\n      {\n         \"type\": \"\"\n      }\n   ],\n   \"notification_recipients\": [\n      {\n         \"type\": \"\"\n      }\n   ],\n   \"entities\": [\n      {\n         \"operation\": \"\",\n         \"entity_key\": \"\",\n         \"entity_id\": \"\"\n      }\n   ]\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"http://localhost:3002//projects/{project_id}/environments/{environment_id}/policies\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "aMOxewlsBtcnquQXLs26c",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"http://localhost:3002//projects/{project_id}/environments/{environment_id}/policies\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"name\": \"\",\n   \"is_default\": \"\",\n   \"default_preferences\": {},\n   \"approvers\": [\n      {\n         \"type\": \"\"\n      }\n   ],\n   \"notification_recipients\": [\n      {\n         \"type\": \"\"\n      }\n   ],\n   \"entities\": [\n      {\n         \"operation\": \"\",\n         \"entity_key\": \"\",\n         \"entity_id\": \"\"\n      }\n   ]\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "GRxj8B22lZHE5JKv2RGEP",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"http://localhost:3002//projects/{project_id}/environments/{environment_id}/policies\"\n\npayload = json.dumps({\n   \"name\": \"\",\n   \"is_default\": \"\",\n   \"default_preferences\": {},\n   \"approvers\": [\n      {\n         \"type\": \"\"\n      }\n   ],\n   \"notification_recipients\": [\n      {\n         \"type\": \"\"\n      }\n   ],\n   \"entities\": [\n      {\n         \"operation\": \"\",\n         \"entity_key\": \"\",\n         \"entity_id\": \"\"\n      }\n   ]\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": "fltAVFcOBOnyAoH14Da4T"
    },
    "results": {
      "languages": [
        {
          "id": "txJhzVUjUU86Ren4vIytC",
          "language": "201",
          "code": "// Policy created successfully\n{\n  \"id\": 0,\n  \"name\": \"\",\n  \"description\": \"\",\n  \"approver_assignment_mode\": \"\",\n  \"entity_type\": \"\",\n  \"environment_id\": 0,\n  \"project_id\": 0,\n  \"is_default\": false,\n  \"default_preferences\": {\n    \"audiences\": false,\n    \"metrics\": false,\n    \"ramp_perc\": false,\n    \"rules\": false,\n    \"ruleset\": false,\n    \"variations\": false\n  },\n  \"approvers\": [\n    {\n      \"type\": \"\",\n      \"email\": \"\",\n      \"team_id\": \"\",\n      \"team_name\": \"\"\n    }\n  ],\n  \"notification_recipients\": [\n    {\n      \"type\": \"\",\n      \"email\": \"\",\n      \"team_id\": \"\",\n      \"team_name\": \"\"\n    }\n  ],\n  \"entities\": [\n    {\n      \"id\": 0,\n      \"entity_id\": 0,\n      \"entity_key\": \"\",\n      \"type\": \"\",\n      \"preferences\": \"\",\n      \"archived\": false\n    }\n  ],\n  \"created_at\": \"\",\n  \"updated_at\": \"\",\n  \"revision\": 0,\n  \"archived\": false\n}"
        },
        {
          "id": "5Eeg2HyiQmj1l6k65i6bk",
          "language": "401",
          "code": "// Not Authenticated\n{\n  \"details\": \"\",\n  \"status\": 400\n}"
        },
        {
          "id": "vnFIfbp5CKgQefToT6UAJ",
          "language": "422",
          "code": "// Validation Error\n{\n  \"detail\": [\n    {\n      \"loc\": [\n        {}\n      ],\n      \"msg\": \"\",\n      \"type\": \"\"\n    }\n  ],\n  \"status\": 422\n}"
        }
      ],
      "selectedLanguageId": "txJhzVUjUU86Ren4vIytC"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}