v4

latestOpenAPI 3.0.02026-08-04109113304.5 KB
Campaigns

Update a Campaign

Update a campaign's metadata.

patch/campaigns/{campaign_id}

Path parameters

campaign_idinteger required

The Campaign ID of the Campaign you want to change

Query parameters

action'publish' | 'start' | 'pause' | 'resume' | 'unarchive'

Action to change the state of the Campaign. 'publish' publishes your campaign, making any changes live to the world without changing the status of the campaign. 'start' publishes your campaign, making any changes live to the world. Status will be 'running'. 'pause' stops the campaign. Status will be 'paused'. No new visitors will see the campaign until it is resumed. 'resume' resumes the campaign from a paused status without publishing any new changes. Status will be 'running'. 'unarchive' unarchives an archived campaign. Status will be 'paused'.

Request body

descriptionstring

The description or goal for a Campaign

for_journeyboolean

Whether the Campaign has been part of journey or not

holdbackinteger

Percentage of visitors to exclude from personalization, measured in basis points. 100 basis points = 1% traffic. For example, a value of 500 would mean that 95% of visitors will see a personalized experience and 5% will see the holdback.

journey_idstring

The journey this campaign is associated with, or null if not set

namestring

The name of the Campaign

page_idsinteger[]

A list of Page IDs used in the Campaign. Only url_targeting or page_ids can be used when updating a Campaign, but not both.

Example request

{
  "changes": [
    {
      "dependencies": [
        "993fd09c-b64a-4c13-95a9-13b3ed2c454e",
        "95cf0144-fb63-431d-829b-193fe55ada18"
      ],
      "name": "Setting button text",
      "selector": "head",
      "value": "window.someGlobalFunction();"
    }
  ],
  "description": "Tailor the landing page hero element for specific audiences",
  "holdback": 500,
  "name": "Landing Page Optimization",
  "url_targeting": {
    "activation_code": "function callbackFn(activate, options) { activate(); }",
    "activation_type": "callback",
    "conditions": "[\"and\", {\"type\": \"url\", \"match_type\": \"substring\", \"value\": \"optimize\"}]",
    "edit_url": "https://www.optimizely.com",
    "key": "home_page",
    "page_id": 6700
  }
}

Response

Return the updated Campaign

archivedboolean

Whether the Campaign has been archived

createdstring date-time

The time the Campaign was initially created

custom_field_valuesobject

Map of custom field api_name to value for this Campaign. Keys correspond to the api_name of a custom field definition for the Project, and values are typed according to that definition's field_type. Returns an empty object when no values are set.

descriptionstring

The description or goal for a Campaign

earlieststring date-time

The first time the Campaign was activated

for_journeyboolean

Whether the Campaign has been part of journey or not

holdbackinteger

Percentage of visitors to exclude from personalization, measured in basis points. 100 basis points = 1% traffic. For example, a value of 500 would mean that 95% of visitors will see a personalized experience and 5% will see the holdback.

idinteger

The unique identifier for the Campaign

journey_idstring

The journey this campaign is associated with, or null if not set

last_modifiedstring date-time

The last time the Campaign was modified

lateststring date-time

The last time the Campaign was paused (not present if the Campaign still running)

namestring

The name of the Campaign

page_idsinteger[]

A list of Page IDs used in the Campaign

project_idinteger required

The Project ID the Campaign is in

status'not_started' | 'running' | 'paused' | 'archived'

Current state of the Campaign. not_started means the Campaign has never been published to the world. running means the Campaign is currently live to the world. paused means the Campaign has been published, but is currently not running. archived means the Campaign is paused and not visible in the web UI.

type'personalization' | 'other'

Indicates the type of this campaign. Campaigns created or fetched via the API should currently all have a type of personalization, but if you get a campaign_id for an experiment and look it up, you may get an other value.

Example response

{
  "changes": [
    {
      "dependencies": [
        "993fd09c-b64a-4c13-95a9-13b3ed2c454e",
        "95cf0144-fb63-431d-829b-193fe55ada18"
      ],
      "name": "Setting button text",
      "selector": "head",
      "value": "window.someGlobalFunction();"
    }
  ],
  "description": "Tailor the landing page hero element for specific audiences",
  "holdback": 500,
  "id": 2000,
  "name": "Landing Page Optimization",
  "project_id": 1000,
  "url_targeting": {
    "activation_code": "function callbackFn(activate, options) { activate(); }",
    "activation_type": "callback",
    "conditions": "[\"and\", {\"type\": \"url\", \"match_type\": \"substring\", \"value\": \"optimize\"}]",
    "edit_url": "https://www.optimizely.com",
    "key": "home_page",
    "page_id": 6700
  }
}