Add, remove or exclude Microsoft Advertising campaign locations
msads_set_locationsChange where a campaign's ads can show. action 'remove' stops targeting locations the campaign has now (pass targetIds from msads_get_targeting, or locationIds); action 'add' starts targeting new Microsoft location ids; action 'exclude' blocks a location even when a wider one is targeted (e.g. exclude a country inside a region). It refuses to remove the last targeted location, because a campaign with none shows everywhere. Removing a location cuts reach and its spend; adding one widens it. Location ids are Microsoft's, from learn.microsoft.com/advertising/guides/geographical-location-codes (US 190). Returns what changed so it can be reversed with the opposite action. Edits the campaign's own locations only: an ad group with its own location targeting overrides them (check msads_get_targeting with adGroupId). Use dryRun first when unsure.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"campaignId": "<campaignId>",
"action": "<action>"
},
"name": "msads_set_locations"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | remove = stop targeting; add = start targeting; exclude = block. | |
| dryRun | No | Preview only. Microsoft has no validate-only mode, so Caybl reads the current value and shows exactly what would change (before and after) without sending anything. Free, and cannot affect spend. | |
| accountId | No | Microsoft Advertising account id or account number (e.g. 'F123ABCD'), as listed by msads_list_accounts. Only needed when the sign-in can reach more than one account. | |
| targetIds | No | For remove: location criterion ids (the `id` in msads_get_targeting). | |
| campaignId | Yes | Campaign id, from msads_get_campaigns. | |
| locationIds | No | Microsoft location ids. Required for add and exclude; for remove an alternative to targetIds. |