---
title: Update an Audience
slug: web-experimentation/api/update-an-audience
docTags: 
createdAt: 2026-10-02T13:15:18.296Z
---

{
  "id": "I3AEVztwXzA56QPyo8elC",
  "type": "api-oas-v2",
  "data": {
    "method": "PATCH",
    "url": "https://api.optimizely.com/v2/audiences/{audience_id}",
    "servers": [
      {
        "url": "https://api.optimizely.com/v2/audiences/{audience_id}"
      }
    ],
    "name": "Update an Audience",
    "description": "Update an Audience for a Project",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "audience_id",
          "type": "integer<int64>",
          "description": "The Audience ID of the Audience you want to change",
          "format": "int64"
        }
      ],
      "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 you'd like to change for an Audience",
          "customType": "AudienceUpdate",
          "schema": [
            {
              "name": "archived",
              "kind": "optional",
              "type": "boolean",
              "description": "True if the Audience has been archived"
            },
            {
              "name": "conditions",
              "kind": "optional",
              "type": "string",
              "description": "A string defining the targeting rules for an Audience"
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "description": "A short description of the Audience"
            },
            {
              "name": "for_journey",
              "kind": "optional",
              "type": "boolean",
              "description": "Whether the Audience has been part of journey or not",
              "default": false
            },
            {
              "name": "name",
              "kind": "optional",
              "type": "string",
              "description": "The name of the Audience",
              "example": "Spanish speaking San Franciscans"
            },
            {
              "name": "segmentation",
              "kind": "optional",
              "type": "boolean",
              "description": "<p>True if the Audience is available for segmentation on the results page (Enterprise plans only)</p>"
            }
          ],
          "modelRef": "#/components/schemas/AudienceUpdate",
          "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": "200",
        "description": "Return the created Audience",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Audience",
            "schema": [
              {
                "name": "archived",
                "kind": "optional",
                "type": "boolean",
                "description": "Whether the Audience has been archived",
                "default": false
              },
              {
                "name": "conditions",
                "kind": "optional",
                "type": "string",
                "description": "A string defining the targeting rules for an Audience",
                "example": "[\"and\", {\"type\": \"language\", \"value\": \"es\"}, {\"type\": \"location\", \"value\": \"US-CA-SANFRANCISCO\"}]"
              },
              {
                "name": "created",
                "kind": "optional",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "The time the Audience was initially created",
                "format": "date-time"
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "description": "A short description of the Audience",
                "example": "People that speak spanish and are in San Francisco"
              },
              {
                "name": "experiment_count",
                "kind": "optional",
                "type": "integer<int64>",
                "readOnly": true,
                "description": "<p>Number of experiments by audience_id</p>",
                "example": 123,
                "format": "int64"
              },
              {
                "name": "for_journey",
                "kind": "optional",
                "type": "boolean",
                "description": "Whether the Audience has been part of journey or not",
                "default": false
              },
              {
                "name": "id",
                "kind": "optional",
                "type": "integer<int64>",
                "readOnly": true,
                "description": "The unique identifier for the Audience",
                "example": 5000,
                "format": "int64"
              },
              {
                "name": "is_classic",
                "kind": "optional",
                "type": "boolean",
                "description": "<p>Whether or not Audience is a classic Audience. If true, the Audience is only compatible with classic Experiments. Otherwise, the Audience may be used in Optimizely X Campaigns.</p>"
              },
              {
                "name": "last_modified",
                "kind": "optional",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "The last time the Audience was modified",
                "format": "date-time"
              },
              {
                "name": "name",
                "kind": "optional",
                "type": "string",
                "description": "The name of the Audience",
                "example": "Spanish speaking San Franciscans"
              },
              {
                "name": "project_id",
                "kind": "required",
                "type": "integer<int64>",
                "description": "The ID of the Project the Audience was created in",
                "example": 1000,
                "format": "int64"
              },
              {
                "name": "segmentation",
                "kind": "optional",
                "type": "boolean",
                "description": "<p>True if the Audience is available for segmentation on the results page (Audiences can only be used for segmentation in Optimizely Classic). Set to False if you intend to use this Audience only in Optimizely X. Note that a maximum of 10 Audiences can have segmentation set to True in any given Optimizely Classic project.</p>",
                "default": false
              }
            ],
            "modelRef": "#/components/schemas/Audience",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Invalid ID supplied",
        "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 edit the specified Audience",
        "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": "404",
        "description": "Audience not found",
        "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": "FqncnhJf_03_ubIEUCpFO",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request PATCH \\\n     --url https://api.optimizely.com/v2/audiences/{audience_id} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "FlR_uZo82V0tGvK4lZtOS",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'PATCH',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.optimizely.com/v2/audiences/{audience_id}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "a33z9VNH8fKGNW3CbPIGM",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.optimizely.com/v2/audiences/{audience_id}\")\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\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "AffaPc-o3neXcsPr9LLjb",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/v2/audiences/{audience_id}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"PATCH\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "FqncnhJf_03_ubIEUCpFO"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Return the created Audience\n{\n  \"archived\": false,\n  \"conditions\": \"[\\\"and\\\", {\\\"type\\\": \\\"language\\\", \\\"value\\\": \\\"es\\\"}, {\\\"type\\\": \\\"location\\\", \\\"value\\\": \\\"US-CA-SANFRANCISCO\\\"}]\",\n  \"created\": \"\",\n  \"description\": \"People that speak spanish and are in San Francisco\",\n  \"experiment_count\": 123,\n  \"for_journey\": false,\n  \"id\": 5000,\n  \"is_classic\": false,\n  \"last_modified\": \"\",\n  \"name\": \"Spanish speaking San Franciscans\",\n  \"project_id\": 1000,\n  \"segmentation\": false\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid ID supplied\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 edit the specified Audience\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// Audience not found\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        },
        {
          "id": "response-5-default",
          "language": "default",
          "code": "// Unexpected error\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}