---
title: Update an In-Page Event
slug: feature-experimentation/api/update-an-in-page-event
docTags: 
createdAt: 2026-10-01T19:58:02.336Z
---

{
  "id": "qB8Ur7YGF3ey5j0PQxI7C",
  "type": "api-oas-v2",
  "data": {
    "method": "PATCH",
    "url": "https://api.optimizely.com/v2/pages/{page_id}/events/{event_id}",
    "servers": [
      {
        "url": "https://api.optimizely.com/v2/pages/{page_id}/events/{event_id}"
      }
    ],
    "name": "Update an In-Page Event",
    "description": "<p>Update an Event that occurs in the context of a Page, such as measuring clicks</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "page_id",
          "type": "integer<int64>",
          "description": "<p>The Page ID of the In-Page Event you want to change</p>",
          "format": "int64"
        },
        {
          "kind": "required",
          "name": "event_id",
          "type": "integer<int64>",
          "description": "<p>The In-Page Event ID of the In-Page Event you want to change</p>",
          "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": "<p>A string in JSON format that includes all the fields you'd like to change for an In-Page Event</p>",
          "customType": "InPageEventUpdate",
          "schema": [
            {
              "name": "archived",
              "kind": "optional",
              "type": "boolean",
              "description": "Whether or not to archive this Event"
            },
            {
              "name": "category",
              "kind": "optional",
              "type": "string",
              "description": "",
              "modelRef": "#/components/schemas/EventCategories",
              "customType": "EventCategories",
              "schema": [
                {
                  "name": "name",
                  "kind": "optional",
                  "type": "string",
                  "description": ""
                }
              ]
            },
            {
              "name": "config",
              "kind": "optional",
              "type": "object",
              "description": "",
              "modelRef": "#/components/schemas/InPageEventConfig",
              "customType": "InPageEventConfig",
              "schema": [
                {
                  "name": "selector",
                  "kind": "required",
                  "type": "string",
                  "description": "<p>CSS selector for the page element(s) that trigger an Event</p>",
                  "example": ".menu-options"
                }
              ]
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "description": "A description of this Event"
            },
            {
              "name": "key",
              "kind": "optional",
              "type": "string",
              "description": "Unique string identifier for this Event within the Project",
              "example": "add_to_cart",
              "maxLength": 64,
              "pattern": "^[a-zA-Z0-9_\\-]+$"
            },
            {
              "name": "name",
              "kind": "optional",
              "type": "string",
              "description": "A human readable name for this Event",
              "example": "Add to Cart"
            },
            {
              "name": "page_id",
              "kind": "optional",
              "type": "integer<int64>",
              "description": "The Page ID associated with this Event",
              "format": "int64"
            },
            {
              "name": "variation_specific",
              "kind": "optional",
              "type": "boolean",
              "description": "Whether or not this Event is variation specific."
            }
          ],
          "modelRef": "#/components/schemas/InPageEventUpdate",
          "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": "<p>Successfully updated the In-Page event</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>An Event that can occur only within the context of a specific Page (allowed in Web Projects only)</p>",
            "customType": "InPageEvent",
            "schema": [
              {
                "name": "archived",
                "kind": "optional",
                "type": "boolean",
                "description": "Whether or not this Event is archived"
              },
              {
                "name": "category",
                "kind": "optional",
                "type": "string",
                "description": "",
                "modelRef": "#/components/schemas/EventCategories",
                "customType": "EventCategories",
                "schema": [
                  {
                    "name": "name",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  }
                ]
              },
              {
                "name": "config",
                "kind": "optional",
                "type": "object",
                "description": "",
                "modelRef": "#/components/schemas/InPageEventConfig",
                "customType": "InPageEventConfig",
                "schema": [
                  {
                    "name": "selector",
                    "kind": "required",
                    "type": "string",
                    "description": "<p>CSS selector for the page element(s) that trigger an Event</p>",
                    "example": ".menu-options"
                  }
                ]
              },
              {
                "name": "created",
                "kind": "optional",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "Creation date for this Event",
                "format": "date-time"
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "description": "A description of this Event"
              },
              {
                "name": "event_type",
                "kind": "required",
                "type": "string<click>",
                "description": "The type of this Event",
                "enum": [
                  "click"
                ]
              },
              {
                "name": "id",
                "kind": "optional",
                "type": "integer<int64>",
                "readOnly": true,
                "description": "The unique identifier of the Event",
                "format": "int64"
              },
              {
                "name": "is_classic",
                "kind": "optional",
                "type": "boolean",
                "readOnly": true,
                "description": "<p>Whether or not this Event is a classic Event. If true, the Event is read-only</p>",
                "default": false
              },
              {
                "name": "is_editable",
                "kind": "optional",
                "type": "boolean",
                "readOnly": true,
                "description": "Whether or not this Event may be edited"
              },
              {
                "name": "key",
                "kind": "optional",
                "type": "string",
                "description": "Unique string identifier for this Event within the Project",
                "example": "add_to_cart",
                "maxLength": 64,
                "pattern": "^[a-zA-Z0-9_\\-]+$"
              },
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": "A human readable name for this Event",
                "example": "Add to Cart"
              },
              {
                "name": "page_id",
                "kind": "optional",
                "type": "integer<int64>",
                "readOnly": true,
                "description": "The Page ID associated with this Event",
                "format": "int64"
              },
              {
                "name": "project_id",
                "kind": "optional",
                "type": "integer<int64>",
                "readOnly": true,
                "description": "The ID of this Event's parent Project",
                "example": 1000,
                "format": "int64"
              }
            ],
            "modelRef": "#/components/schemas/InPageEvent",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Invalid request body 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 access to the specified Event",
        "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": "Event 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": "6KvDBnGnM8oEWhB3SfLMJ",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request PATCH \\\n     --url https://api.optimizely.com/v2/pages/{page_id}/events/{event_id} \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"config\": {\n     \"selector\": \".menu-options\"\n     }\n     }'"
        },
        {
          "id": "mEeUzg1674Viah0NBe42l",
          "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   \"config\": {\n      \"selector\": \".menu-options\"\n   }\n});\n\nvar requestOptions = {\n   method: 'PATCH',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.optimizely.com/v2/pages/{page_id}/events/{event_id}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "91kfTTB4hGVu5cTzPSqqt",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.optimizely.com/v2/pages/{page_id}/events/{event_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\"\nrequest.body = JSON.dump({\n   \"config\": {\n      \"selector\": \".menu-options\"\n   }\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "R4Os4aeXfMPS2rAb9de-H",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/v2/pages/{page_id}/events/{event_id}\"\n\npayload = json.dumps({\n   \"config\": {\n      \"selector\": \".menu-options\"\n   }\n})\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": "6KvDBnGnM8oEWhB3SfLMJ"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successfully updated the In-Page event\n{\n  \"archived\": false,\n  \"category\": \"\",\n  \"config\": {\n    \"selector\": \".menu-options\"\n  },\n  \"created\": \"\",\n  \"description\": \"\",\n  \"event_type\": \"\",\n  \"id\": \"\",\n  \"is_classic\": false,\n  \"is_editable\": false,\n  \"key\": \"add_to_cart\",\n  \"name\": \"Add to Cart\",\n  \"page_id\": \"\",\n  \"project_id\": 1000\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid request body 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 access to the specified Event\n{\n  \"code\": \"\",\n  \"message\": \"\",\n  \"messages\": {},\n  \"uuid\": \"\"\n}"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// Event 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": ""
    }
  ]
}