---
updatedAt: 2026-09-24T11:53:05.000Z
agentTools:
  projectIndex: https://developers.taboola.com/backstage-api/llms.txt
---

# Update Contextual Targeting

Update *Contextual* Targeting for the specified campaign.

<div class="not-prose mt-4 pt-4 border-t border-gray-100 text-sm text-gray-700"><strong class="font-semibold">Rate limit:</strong> <a href="#rate-limit">Tier 1</a></div>

> 🚧
>
> For a list of *Contextual Segments* that can be targeted by a given account, see the [Dictionary](https://developers.taboola.com/backstage-api/reference/get-contextual-segments) (`dictionary/contextual_segments` endpoint).

### Sample requests

#### Sample request path

```http Request path
POST https://backstage.taboola.com/backstage/api/1.0/demo-account/campaigns/1234/targeting/contextual_segments
```

#### Sample request objects

```json Remove targeting
{
   "collection": []
}
```
```json Apply an INCLUDE
{
    "collection": [
        {
            "collection": [
                1900004,
                1900024,
                1900037
            ],
            "type": "INCLUDE"
        }
    ]
}
```
```json Apply an INCLUDE and an EXCLUDE
{
    "collection": [
        {
            "collection": [
                1900004,
                1900024,
                1900037
            ],
            "type": "INCLUDE"
        },
        {
            "collection": [
                1905924,
                1899997
            ],
            "type": "EXCLUDE"
        }        
    ]
}
```

> 🚧 Guidelines
>
> 1. Contextual Targeting does *not* support a PATCH operation.
> 2. To *add/remove* segments, re-submit the *entire* collection.
> 3. To remove *all* segments, submit an *empty* collection.
> 4. For a given campaign, you can apply an INCLUDE *and* an EXCLUDE.

> 📘
>
> For a successful request, the *same* object is returned in the *response*.

### Campaign Object

#### Sample request path

```http Request path
GET https://backstage.taboola.com/backstage/api/1.0/demo-account/campaigns/1234
```

#### Sample responses

```json No targeting (default)
{
   // Other campaign fields omitted..
   "contextual_segments_targeting": {
      "state": "ALL",
      "value": null,
      "href": "https://backstage.taboola.com/backstage/api/1.0/demo-account/campaigns/1234/targeting/contextual_segments"
   }
}
```
```json Targeting exists
{
   // Other campaign fields omitted..
   "contextual_segments_targeting": {
      "state": "EXISTS",
      "value": null,
      "href": "https://backstage.taboola.com/backstage/api/1.0/demo-account/campaigns/1234/targeting/contextual_segments"
   }
}
```

## Rate limit

> 🚧 Rate limit
>
> **Tier 1.** Updating contextual segment targeting has its own budget, more permissive than the one used for reading it.
>
> See [Rate limits](https://developers.taboola.com/backstage-api/reference/rate-limits) for the request allowance each tier carries.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "backstage-api",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://backstage.taboola.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://backstage.taboola.com/backstage/oauth/token",
            "scopes": {}
          },
          "password": {
            "tokenUrl": "https://backstage.taboola.com/backstage/oauth/token",
            "scopes": {}
          }
        }
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "x-readme": {
    "headers": [],
    "explorer-enabled": false,
    "proxy-enabled": false
  },
  "paths": {
    "/backstage/api/1.0/{account_id}/campaigns/{campaign_id}/targeting/contextual_segments": {
      "post": {
        "summary": "Update Contextual Targeting",
        "description": "Update *Contextual* Targeting for the specified campaign.\n\n<div class=\"not-prose mt-4 pt-4 border-t border-gray-100 text-sm text-gray-700\"><strong class=\"font-semibold\">Rate limit:</strong> <a href=\"#rate-limit\">Tier 1</a></div>",
        "operationId": "update-contextual-targeting",
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "description": "An *alphabetic* ID. See [Get Account Details](https://developers.taboola.com/backstage-api/reference/get-account-details).",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "campaign_id",
            "in": "path",
            "description": "A *numeric* ID.",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "RAW_BODY": {
                    "type": "string",
                    "description": "An [Audience Targeting Object](https://developers.taboola.com/backstage-api/reference/audience-targeting-object)",
                    "default": "{     \"collection\": [         {             \"collection\": [                 1900004,                 1900024,                 1900037             ],             \"type\": \"INCLUDE\"         }     ] }",
                    "format": "json"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"collection\": [\n        {\n            \"collection\": [\n                1900004,\n                1900024,\n                1900037\n            ],\n            \"type\": \"INCLUDE\"\n        }\n    ]\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "collection": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "collection": {
                            "type": "array",
                            "items": {
                              "type": "integer",
                              "example": 1900004,
                              "default": 0
                            }
                          },
                          "type": {
                            "type": "string",
                            "example": "INCLUDE"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  }
}
```