> ## Documentation Index
> Fetch the complete documentation index at: https://docs.markifact.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Targeting

> Adds and removes targeting criteria on an X Ads ad group (keywords, locations, interests, demographics, followers, custom audiences and more) using X's batch endpoint

Adds and removes targeting criteria on an X Ads ad group (keywords, locations, interests, demographics, followers, custom audiences and more) using X's batch endpoint. Pass remove ALL together with add to replace the targeting entirely.

|                       |                       |
| --------------------- | --------------------- |
| **App**               | X Ads                 |
| **Operation ID**      | `x_ads_set_targeting` |
| **Type**              | Action                |
| **Connection**        | `x_ads` (required)    |
| **Credits per run**   | 1                     |
| **Agent / MCP tool**  | Yes                   |
| **Requires approval** | Yes (write operation) |

## Inputs

| Field         | Type                      | Required | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------- | ------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `account`     | DynamicAccount            | Yes      | -       | Select the X Ads account that owns the ad group.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `ad_group_id` | string or SelectItem      | Yes      | -       | Ad group (line item) whose targeting criteria to change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `add`         | array of object or string | No       | -       | Targeting criteria to add, as a list of objects matching the X Ads API payload: \[\{"targeting\_type": "...", "targeting\_value": "...", "operator\_type": "EQ"}]. operator\_type defaults to EQ; use NE to exclude (e.g. negated keywords), GTE/LT for AGE style ranges where X documents them. targeting\_type values: BROAD\_KEYWORD, EXACT\_KEYWORD, PHRASE\_KEYWORD, UNORDERED\_KEYWORD (targeting\_value is the keyword text), LOCATION, INTEREST, AGE (e.g. AGE\_25\_TO\_34), GENDER (1 male, 2 female), LANGUAGE, PLATFORM, PLATFORM\_VERSION, DEVICE, WIFI\_ONLY, EVENT, CONVERSATION, ENGAGEMENT\_TYPE, FOLLOWERS\_OF\_USER, SIMILAR\_TO\_FOLLOWERS\_OF\_USER (user ids), CAMPAIGN\_ENGAGEMENT, CAMPAIGN\_ENGAGEMENT\_LOOKALIKE, USER\_ENGAGEMENT, USER\_ENGAGEMENT\_LOOKALIKE, NETWORK\_OPERATOR, NETWORK\_ACTIVATION\_DURATION, TV\_SHOW, LIVE\_TV\_EVENT, CUSTOM\_AUDIENCE, CUSTOM\_AUDIENCE\_EXPANDED, APP\_STORE\_CATEGORY, APP\_STORE\_CATEGORY\_LOOKALIKE, APP\_LIST (NE only). Use x\_ads\_search\_targeting to find ids for LOCATION, INTEREST, EVENT, CONVERSATION, DEVICE, PLATFORM, LANGUAGE, TV\_SHOW and the like. Example: \[\{"targeting\_type": "BROAD\_KEYWORD", "targeting\_value": "marketing analytics"}, \{"targeting\_type": "LOCATION", "targeting\_value": "96683cc9126741d1"}] |
| `remove`      | string or array of string | No       | -       | Targeting criterion IDs to delete (list or comma-separated), from this node's output or a previous run. Pass the single value ALL to remove every existing criterion, which combined with add replaces the ad group's targeting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### SelectItem

| Field   | Type   | Required | Default | Description                                                                                          |
| ------- | ------ | -------- | ------- | ---------------------------------------------------------------------------------------------------- |
| `value` | string | Yes      | -       | The value of the selectable item.                                                                    |
| `label` | string | Yes      | -       | The label of the selectable item, used for display purposes. If not provided, defaults to the value. |

## Output

**Type**: `Dict`

Returns counts of added/removed criteria and the ad group's resulting targeting criteria with their ids.

**Fields**: dynamic (depend on the inputs)
