---
title: Create an Exclusion Group
slug: web-experimentation/api/create-an-exclusion-group
docTags: 
createdAt: 2026-10-02T13:15:18.296Z
---

{
  "id": "s3CPzyf-T0XSVm3aGz9IW",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.optimizely.com/v2/groups",
    "servers": [
      {
        "url": "https://api.optimizely.com/v2/groups"
      }
    ],
    "name": "Create an Exclusion Group",
    "description": "Create a new Exclusion Group in a provided project",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "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": "A string in JSON format that includes all the fields to create an Exclusion Group",
          "customType": "Group",
          "schema": [
            {
              "name": "archived",
              "kind": "optional",
              "type": "boolean",
              "description": "Whether the group is archived"
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "description": "The description for an Exclusion Group"
            },
            {
              "name": "entities",
              "kind": "optional",
              "type": "array",
              "description": "Array of Group Entities in the Exclusion Group",
              "modelRef": "#/components/schemas/GroupEntity",
              "customType": "GroupEntity[]",
              "schema": [
                {
                  "name": "id",
                  "kind": "required",
                  "type": "integer",
                  "description": "The unique identifier for the Group Entity",
                  "example": 3000
                },
                {
                  "name": "kind",
                  "kind": "required",
                  "type": "string<Campaign | Experiment>",
                  "description": "The kind of the Group Entity",
                  "enum": [
                    "Campaign",
                    "Experiment"
                  ]
                },
                {
                  "name": "weight",
                  "kind": "required",
                  "type": "integer",
                  "description": "<p>The weight of the Group Entity. The weight is a value between 0 and 10000. An entity with weight 5000 will receive 50% of this group's traffic</p>",
                  "example": 1000
                }
              ]
            },
            {
              "name": "name",
              "kind": "required",
              "type": "string",
              "description": "Name of the Exclusion Group",
              "example": "Homepage Group"
            },
            {
              "name": "project_id",
              "kind": "required",
              "type": "integer<int64>",
              "description": "The Project the Exclusion Group is in",
              "example": 1000,
              "format": "int64"
            }
          ],
          "modelRef": "#/components/schemas/Group",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "apiKey",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        },
        {
          "id": "OAuth2",
          "name": "OAuth2",
          "kind": "optional",
          "type": "oauth2",
          "description": "<p>Write applications that authenticate with the REST API via OAuth 2.0. Or, to authenticate using 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>",
          "oauth2Flows": {
            "authorizationCode": {
              "authorizationUrl": "https://app.optimizely.com/oauth2/authorize",
              "tokenUrl": "https://app.optimizely.com/oauth2/token",
              "scopes": {
                "all": "Full access to your account"
              }
            }
          },
          "requiredScopes": [
            "read",
            "write"
          ]
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "Return the created Exclusion Group",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Group",
            "schema": [
              {
                "name": "archived",
                "kind": "optional",
                "type": "boolean",
                "description": "Whether the group is archived"
              },
              {
                "name": "created",
                "kind": "optional",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "The time when the Exclusion Group was initially created",
                "format": "date-time"
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "description": "The description for an Exclusion Group"
              },
              {
                "name": "entities",
                "kind": "optional",
                "type": "array",
                "description": "Array of Group Entities in the Exclusion Group",
                "modelRef": "#/components/schemas/GroupEntity",
                "customType": "GroupEntity[]",
                "schema": [
                  {
                    "name": "id",
                    "kind": "required",
                    "type": "integer",
                    "description": "The unique identifier for the Group Entity",
                    "example": 3000
                  },
                  {
                    "name": "kind",
                    "kind": "required",
                    "type": "string<Campaign | Experiment>",
                    "description": "The kind of the Group Entity",
                    "enum": [
                      "Campaign",
                      "Experiment"
                    ]
                  },
                  {
                    "name": "weight",
                    "kind": "required",
                    "type": "integer",
                    "description": "<p>The weight of the Group Entity. The weight is a value between 0 and 10000. An entity with weight 5000 will receive 50% of this group's traffic</p>",
                    "example": 1000
                  }
                ]
              },
              {
                "name": "id",
                "kind": "optional",
                "type": "integer<int64>",
                "readOnly": true,
                "description": "The unique identifier for the Exclusion Group",
                "example": 3000,
                "format": "int64"
              },
              {
                "name": "last_modified",
                "kind": "optional",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "The last time the Exclusion Group was modified",
                "format": "date-time"
              },
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": "Name of the Exclusion Group",
                "example": "Homepage Group"
              },
              {
                "name": "project_id",
                "kind": "required",
                "type": "integer<int64>",
                "description": "The Project the Exclusion Group is in",
                "example": 1000,
                "format": "int64"
              }
            ],
            "modelRef": "#/components/schemas/Group",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Invalid request body content",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Error",
            "schema": [
              {
                "name": "code",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "messages",
                "kind": "optional",
                "type": "object",
                "description": "",
                "example": "",
                "schema": []
              },
              {
                "name": "uuid",
                "kind": "optional",
                "type": "string<uuid>",
                "description": "",
                "format": "uuid"
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "Invalid credentials",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Error",
            "schema": [
              {
                "name": "code",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "messages",
                "kind": "optional",
                "type": "object",
                "description": "",
                "example": "",
                "schema": []
              },
              {
                "name": "uuid",
                "kind": "optional",
                "type": "string<uuid>",
                "description": "",
                "format": "uuid"
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "403",
        "description": "You do not have permission to create an Exclusion Group under the specified Project",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Error",
            "schema": [
              {
                "name": "code",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "messages",
                "kind": "optional",
                "type": "object",
                "description": "",
                "example": "",
                "schema": []
              },
              {
                "name": "uuid",
                "kind": "optional",
                "type": "string<uuid>",
                "description": "",
                "format": "uuid"
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "default",
        "description": "Unexpected error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Error",
            "schema": [
              {
                "name": "code",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "messages",
                "kind": "optional",
                "type": "object",
                "description": "",
                "example": "",
                "schema": []
              },
              {
                "name": "uuid",
                "kind": "optional",
                "type": "string<uuid>",
                "description": "",
                "format": "uuid"
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "xx873Jv-4GPpeoyXO0ai4",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.optimizely.com/v2/groups \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"entities\": [\n     {\n     \"id\": 3000,\n     \"kind\": \"\",\n     \"weight\": 1000\n     }\n     ],\n     \"name\": \"Homepage Group\",\n     \"project_id\": 1000\n     }'"
        },
        {
          "id": "GQxB8-k_keZq59x-BjPUq",
          "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   \"entities\": [\n      {\n         \"id\": 3000,\n         \"kind\": \"\",\n         \"weight\": 1000\n      }\n   ],\n   \"name\": \"Homepage Group\",\n   \"project_id\": 1000\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.optimizely.com/v2/groups\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "Fq0mcIkYJ2zpYxTQzim1n",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.optimizely.com/v2/groups\")\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   \"entities\": [\n      {\n         \"id\": 3000,\n         \"kind\": \"\",\n         \"weight\": 1000\n      }\n   ],\n   \"name\": \"Homepage Group\",\n   \"project_id\": 1000\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "EGcQH7ZVCv6x3PascKJE9",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/v2/groups\"\n\npayload = json.dumps({\n   \"entities\": [\n      {\n         \"id\": 3000,\n         \"kind\": \"\",\n         \"weight\": 1000\n      }\n   ],\n   \"name\": \"Homepage Group\",\n   \"project_id\": 1000\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": "xx873Jv-4GPpeoyXO0ai4"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// Return the created Exclusion Group\n{\n  \"archived\": false,\n  \"created\": \"\",\n  \"description\": \"\",\n  \"entities\": [\n    {\n      \"id\": 3000,\n      \"kind\": \"\",\n      \"weight\": 1000\n    }\n  ],\n  \"id\": 3000,\n  \"last_modified\": \"\",\n  \"name\": \"Homepage Group\",\n  \"project_id\": 1000\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid request body content\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Invalid credentials\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// You do not have permission to create an Exclusion Group under the specified Project\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        },
        {
          "id": "response-4-default",
          "language": "default",
          "code": "// Unexpected error\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}