Targeting rules via API
The targeting endpoint pattern on all six entity levels, all 41 creatable dimensions with their create parameters, INCLUDE/EXCLUDE/MATCH/NOT_MATCH, the three permission checks, value lookups, curl examples, preset groups and category rules.
Targeting rules (demand side) and pretargeting rules (supply side) over REST: the one endpoint
pattern every entity level shares, the parameters of each of the 41 creatable dimensions, the
permission checks, the value lookups, worked examples, preset groups and category rules. Examples
send your API key in the X-Api-Key header — see the
API overview for authentication. Capping,
limits and pricing are on their own pages — see Targeting, capping and limits via
API.
Who this is for
Developers who script delivery control for a network — network managers, and publisher or advertiser users whose role holds the permissions named below. The calls behave the same for every role; what differs is which entities and dimensions your role may change.
Targeting: the endpoint pattern
Targeting rules exist on six entity levels. Demand side: advertiser, campaign, banner. Supply side (pretargeting): site, zone, placement. Each level has the same eight management operations:
GET /rest-api/{entity}/{entityId}/targetings.do list rules (filters: targetType, rule)
GET /rest-api/{entity}/{entityId}/targeting/{targetId}.do get one rule
DELETE /rest-api/{entity}/{entityId}/targeting/{targetId}/delete.do delete one rule
DELETE /rest-api/{entity}/{entityId}/targetings.do delete all rules (filters: targetType, rule)
POST /rest-api/{entity}/{entityId}/targeting/enable.do enable targeting on the entity
POST /rest-api/{entity}/{entityId}/targeting/disable.do disable targeting on the entity
POST /rest-api/{entity}/{entityId}/targeting/operation-between-rule-types.do AND / OR between rule types
GET /rest-api/{entity}/{entityId}/targeting/types.do dimensions available to you
plus one POST …/targeting/{dimension}/create.do per dimension, sixteen values.do
lookups, and POST …/targeting/screen-resolution/save-ranges.do, which saves several screen-size
ranges and replaces rules in one call (see Device and browser). {entity} is
advertiser, campaign, banner, site, zone or placement — singular in the path.
| Level | Operations | Create endpoints |
|---|---|---|
advertiser, campaign, banner | 65 each | 40 |
placement | 64 | 39 |
site, zone | 63 each | 38 |
The difference is entirely entity blocking: every one of the 38 ordinary dimensions exists on
all six levels, and only the three blocking dimensions are restricted (see the table below).
The operations are the eight above, the create endpoints, the sixteen lookups and save-ranges.
Every create call takes a rule parameter: INCLUDE (whitelist) or EXCLUDE
(blacklist). It is required everywhere except on browser at the advertiser, campaign, site and
zone levels, where leaving it out gives INCLUDE. MATCH / NOT_MATCH compare a pattern and are
accepted on channel only — on any other dimension they are a 400.
Corner case: values are checked the way the console’s form checks them, and a value outside its range is a
400naming the field and the range, with nothing created:ipFrom/ipTomust be IP addresses (10.0.0.300is refused rather than read as0.0.0.0, which would widen the rule to almost every address),timeFrom/timeToareHH:mmorHH:mm:ssfrom00:00to24:00(also ondate-time; see the note below the dimension tables), browser, hardware and platform ranks anddeviceRamare 1–999999,deviceReleaseYearis 1992 to next year,priceBand0–99999,screenWidthandscreenHeight0–9999 (theminWidth/maxWidth/minHeight/maxHeightlimits 1–9999), andcookieName/cookieValuemust not be blank.mobileCarriersis required, and the carriers of one call are created together. A comma-separated id list (placementId,siteId,advertiserIds) with something that is not a number is a400naming it.
Note: creating a rule auto-enables targeting on the entity if it was disabled — the first successful create switches
enableTargetingon. You don’t need a separate enable call.
Corner case: demand-side calls require the Manage Demand Targeting user permission plus UPDATE access to the entity; supply-side calls (site, zone, placement) require Manage Supply Pre-targeting instead — the demand permission does not open them.
targeting/types.doreflects your per-dimension permissions — a dimension missing from its output will be rejected on create, and a rule of that dimension cannot be deleted either:403on the single delete, and on the delete-all call nothing at all is deleted. The403message names what is missing — the dimension and its permission (Your role cannot use DATE_TIME targeting: it lacks the TARGETING_DAY_TIME permission.), the user permission (MANAGE_DEMAND_TARGETING) or the access to the entity.
Corner case: creating a rule that already exists is idempotent:
200, no second rule is stored, and the answer is the stored rule (itsid) marked"alreadyExisted": true. A multi-value create (severalcountryCodes) saves the new values and answers the list, the values that were already there marked the same way. A rule that differs — the same value with the otherrule(INCLUDE/EXCLUDE) — is a new rule. A re-post still switches targeting on, like a fresh create: on an entity whose targeting is off, re-posting a rule it already holds turns targeting on so the rule applies.
Corner case: a rule — in a create’s answer and in
targetings.do/targeting/{id}— carries"contradicted": truewhen the same entity also targets that value with the other rule (an excluded value never matches, so the include lets nothing through), and"contradictedAcrossLevels": truewhen a level above — the campaign or advertiser of a banner, the advertiser of a campaign, the zone or site of a placement, the site of a zone — targets it the other way. Both rules are saved either way. OnlyINCLUDE/EXCLUDEpairs count, a level whose targeting is off is left out, and channels compare exactly while other values ignore case.
Targeting dimensions
Forty-one dimensions are creatable over REST. The path segment is kebab-case; the targetType
filter on targetings.do uses the enum name instead, and for six dimensions the two do not
resemble each other — those are called out in the tables.
Parameters marked * are required. rule is required on every create except browser.
The tables name what each dimension needs; all fields of a create call, with descriptions and an
example request, are in the generated targeting rules reference —
for example
POST /rest-api/campaign/{campaignId}/targeting/country/create.do.
Each level has its own reference page:
advertiser, campaign,
banner, site,
zone, placement; the endpoints
shared by every level are on Targeting Rules API endpoints.
| Group | Dimension segments |
|---|---|
| Geography | country, browser-country, location, ip-range |
| Time | time-range, day-of-week, date-time |
| Device & browser | operating-system, browser, device-format, device-vendor, device-ram, device-release-year, screen-resolution, hardware-rank, platform-rank, browser-rank |
| Network & connection | mobile-carrier, connection-type, wifi-traffic, proxy, protocol, traffic-source |
| Context | domain, app-package, channel, language, is-web-app, incognito-mode |
| Data & API | custom (custom parameters), cookie-value, api-json-field, price-band, traffic-risk-score, dmp (audience segments) |
| Presets | preset-domain, preset-app-package, preset-ip-ranges |
| Entity blocking | site, placement (demand side: block sites/placements); advertiser (placement level only: block advertisers) |
Geographic
| Segment | targetType | Create parameters |
|---|---|---|
country | COUNTRY | countryCode* (array of ISO alpha-2), rule* |
browser-country | BROWSER_COUNTRY | countryCode* (array), rule* |
location | LOCATION | countryCode*, rule*, regionName, cityName |
language | LANGUAGE | languageCode*, rule* |
mobile-carrier | MOBILE_CARRIER | rule*, mobileCarriers* (array; names as targeting/mobile-carrier/bycountry/values.do lists them) |
Temporal
| Segment | targetType | Create parameters |
|---|---|---|
time-range | TIME_RANGE | timeFrom*, timeTo*, rule*, clientLocalTime |
day-of-week | DAY_OF_WEEK | dayOfWeek* (MONDAY…SUNDAY), rule* |
date-time | DATE_TIME — labelled Day and Time | timeFrom*, timeTo*, rule*, dayOfWeek (array), clientLocalTime |
clientLocalTime is optional on both and defaults to false — the network’s time zone (UTC
unless your network has been set to another zone), not the visitor’s. With true, a request that
carries no visitor offset (tz) — VAST, CTV, server-to-server — is matched in network time as
well. On date-time, dayOfWeek is optional too: left out, the rule covers every day. The
path …/targeting/datetime/create.do is accepted as an alias of date-time.
Corner case:
timeFromandtimeTotakeHH:mmorHH:mm:ss, from00:00to24:00. The seconds are dropped —09:00:30is stored as 09:00 — and24:00is the end of the day (stored as minute 1440; the ad server matches it like23:59), so18:00to24:00covers the evening.25:00,24:30,24:00:01, a minute or second of60and anything that is not a time are a400naming the field:timeTo must be a time from 00:00 to 24:00 (HH:mm[:ss]), got 25:00.AtimeFromequal totimeTois a400too (From and To must be different times: an equal pair never matches.), ontime-rangeanddate-timealike.
Device and browser
| Segment | targetType | Create parameters |
|---|---|---|
operating-system | OPERATING_SYSTEM | operatingSystem* (25 values), rule*, version, relation (required when version is sent) |
browser | BROWSER | browser* (69 values), rule (required on placement), browserVersion, relation |
device-format | DEVICE_FORMAT | deviceFormat* (DESKTOP, TABLET, MOBILE, SMART_TV), rule* |
device-vendor | DEVICE_VENDOR | deviceVendor* (39 values), rule* |
screen-resolution | RESOLUTION | rule*, and either relation + screenWidth + screenHeight (one relation on both sides), or one or more of minWidth, maxWidth, minHeight, maxHeight (inclusive; a limit left out is open) — not both forms |
protocol | PROTOCOL | protocol* (HTTP, HTTPS), rule* |
wifi-traffic | WIFI_TRAFFIC | rule* |
is-web-app | IS_WEB_APP | rule* |
incognito-mode | INCOGNITO_MODE | rule* |
relation is LOWER, GREATER, LOWER_EQUAL, GREATER_EQUAL or EQUAL everywhere it
appears. operatingSystem covers desktop, mobile and connected-TV platforms
(SAMSUNG_TIZEN, LG_WEB_OS, ROKU_TV_OS, AMAZON_FIRE_TV, APPLE_TV, ANDROID_TV among
them); browser covers in-app webviews (FACEBOOK_APP, TIKTOK_APP, INSTAGRAM_APP, …) as
well as browsers. Get the exact current lists from …/targeting/operating-system/values.do
and …/targeting/browser/values.do rather than hardcoding them.
A screen-size rule reads back with all seven fields: relation, screenWidth and screenHeight are
null for a range one relation cannot say (minWidth=1024&maxWidth=1439), and a limit that is
open is null.
Several screen-size ranges, or replacing a rule, in one call. POST …/targeting/screen-resolution/save-ranges.do takes a JSON body: rule (INCLUDE or
EXCLUDE, for every range), ranges (one to 20; each has the four limits above, a limit left
out or null is open) and an optional replaceIds list naming screen-size rules of the same
entity to delete. It is one transaction: if a range is unusable (400, the error keyed
ranges[i]), there are more than 20 (400, keyed ranges), a replaceIds entry is not a screen-size rule of this entity (404), or a
permission is missing (403), nothing is saved and nothing is deleted. A range equal to a stored
rule keeps that rule, the replaced one included. The answer lists the saved rules in targets, the
deleted ids in replaced, and a warning when a saved rule is now targeted both ways. This is
how the console saves the Screen width editor.
curl -X POST -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/banner/7890/targeting/screen-resolution/save-ranges.do" \
-H "Content-Type: application/json" \
-d '{"rule":"INCLUDE","ranges":[{"maxWidth":767},{"minWidth":1440}],"replaceIds":[4521]}'
Full entry: POST /rest-api/banner/{bannerId}/targeting/screen-resolution/save-ranges.do.
Corner case: the three boolean dimensions —
wifi-traffic,is-web-app,incognito-mode— take no value parameter at all.rule=INCLUDEmeans “only this traffic”,rule=EXCLUDEmeans “never this traffic”. There is nothing else to send.
Corner case:
browseris the one create endpoint whereruleis optional — on the advertiser, campaign, banner, site and zone levels; on placement it is required like everywhere else. Every other dimension rejects a create without it.
Device scores and specs
| Segment | targetType | Create parameters |
|---|---|---|
device-release-year | DEVICE_RELEASE_YEAR | deviceReleaseYear* (integer), rule*, relation |
device-ram | DEVICE_RAM | deviceRam* (integer), rule*, relation |
browser-rank | BROWSER_RANK | browserRank* (integer), rule*, relation |
hardware-rank | HARDWARE_RANK | hardwareRank* (integer), rule*, relation |
platform-rank | PLATFORM_RANK | platformRank* (integer), rule*, relation |
price-band | PRICE_BAND | priceBand* (number), rule*, relation |
relation is optional on the advertiser, campaign, banner, site and zone levels and required on
placement. Left out, it is GREATER_EQUAL on device-release-year, device-ram and
traffic-risk-score and LOWER_EQUAL on the three ranks and price-band — so send it, rather
than rely on a default that differs by dimension.
Content and apps
| Segment | targetType | Create parameters |
|---|---|---|
domain | DOMAIN | domain*, rule* |
channel | CHANNEL | channel*, rule* |
app-package | APP_PACKAGE | appPackage*, rule* |
cookie-value | COOKIE_VALUE | cookieName*, cookieValue*, rule* |
custom | CUSTOM — labelled Custom Parameter | customValue*, rule*, customType, operation, parameter |
custom is the most configurable of the set: customType is EXPRESSION, VALUE, ONE_OF
or SUBSTRING, and operation is one of EQUALS, NOT_EQUALS, CONTAINS, NOT_CONTAINS,
GREATER, GREATER_OR_EQUALS, LESS, LESS_OR_EQUALS, IN, NOT_IN. parameter names the
custom parameter to read.
Cookie Value, Custom Parameter, DMP and API JSON Field are the dimensions whose Include and
Exclude lists can each require every group instead of any one. The rules on one key a
visitor holds once (one cookie name, one custom parameter) are one group of alternatives; every
other rule is a group of its own. So tier=gold, tier=silver and region=eu under ALL read
(tier = gold or silver) and region = eu.
POST …/targeting/match-mode.do with type (COOKIE_VALUE, CUSTOM, DMP or
API_JSON_FIELD), rule (INCLUDE or EXCLUDE) and matchMode (ANY, the default, or ALL)
switches one list; any other type is refused with 400. A rule created later joins its list’s
mode, and every rule of these types reads back with its matchMode and, when it shares a group,
its matchGroup. See
And / or between groups.
Network
| Segment | targetType | Create parameters |
|---|---|---|
ip-range | IP_RANGE | ipFrom*, ipTo*, rule* |
proxy | PROXY | proxy* (VPN, TOR, DCH, PUB, WEB, SES), rule* |
connection-type | CONNECTION_TYPE | connectionType* (UNKNOWN, DIALUP, CABLE_DSL, CORPORATE, CELLULAR, WI_FI), rule* |
traffic-source | TRAFFIC_SOURCE | trafficSource*, rule* — trafficSource currently has exactly one value, HEADER_BIDDING |
Presets
Preset targeting references a reusable group by ID rather than carrying values inline. Note that two of the three path segments are singular where the enum name is plural.
| Segment | targetType | Create parameters |
|---|---|---|
preset-domain | PRESET_DOMAINS | domainGroupId* (integer), rule* |
preset-app-package | PRESET_APP_PACKAGES | appPackageGroupId* (integer; the banner level also accepts its earlier name presetApplicationPackageGroupId), rule* |
preset-ip-ranges | PRESET_IP_RANGES | presetIpRangesGroupId* (integer; ipRangesGroupId is accepted as the same value, and one of the two is required), rule* |
Data, API and risk
| Segment | targetType | Create parameters |
|---|---|---|
api-json-field | API_JSON_FIELD | apiUrl*, jsonField* (the banner level also accepts its earlier name jsonFieldName), jsonFieldValue*, rule* |
traffic-risk-score | TRAFFIC_RISK_SCORE | riskLevel*, rule*, relation, riskCategory (array) |
riskLevel is NOT_SCORED, LOW, LIKELY, HIGH, VERY_HIGH or CERTAIN; it also accepts the
internal states SERVICE_DISABLED and ERROR, and any level by its id (1–8). riskCategory takes any of 25 fraud categories (HIGH_RISK_IP, APP_SPOOFING,
DATACENTER, CLICK_FARM, TOR, …) — the generated
targeting-rules reference lists them in full.
Entity blocking
These three are the only asymmetric dimensions, and they are not offered in the UI’s add-targeting combo either — they are reached through the blocked-entity screens.
| Segment | targetType | Levels | Create parameters |
|---|---|---|---|
site | BLOCKED_SITES | advertiser, campaign, banner | siteId*, rule* |
placement | BLOCKED_PLACEMENTS | advertiser, campaign, banner | placementId*, rule* |
advertiser | BLOCKED_ADVERTISERS | placement only | advertiserIds*, rule* (EXCLUDE only — anything else is a 400 Please use only Exclude rule.) |
The three take several ids in one comma-separated parameter (siteId=11,12,
placementId=…, advertiserIds=…). The answer lists the ids blocked now in created and those
that already were in alreadyTargeted; an unknown or deleted id refuses the whole call and
nothing is created. A created or already-present target also switches the entity’s targeting on. On a placement,
every advertiser must also be one you may update (an update share, or campaign update at All
level).
Read an advertiser’s blocked inventory back with:
GET /rest-api/target/advertiser/{advertiserId}/blocked-placements.do
GET /rest-api/target/advertiser/{advertiserId}/blocked-sites.do
Two dimensions the API cannot create
There are 43 targeting types; 41 have a create endpoint. The two without one are:
targetType | Label | Where it lives |
|---|---|---|
BLOCKED_BANNERS | Blocked Banners | UI only — supply-side blocked-entity screens |
BLOCKED_CAMPAIGNS | Blocked Campaigns | UI only — supply-side blocked-entity screens |
Both still appear in the targetType filter enum on targetings.do, so rules created in
the UI are readable and deletable over the API — just not creatable.
Note: three counts describe the same enum and are easy to confuse. 43 rule types exist. 41 have a REST create endpoint (all but the two banner/campaign blocking types —
POST .../targeting/dmp/create.docovers DMP audience segments too). 38 appear in the UI’s add-targeting picker — that list excludes all five blocking types, which are reached from the blocked-entity screens instead. See Targeting dimensions for the UI-side view.
Rules: INCLUDE, EXCLUDE, MATCH, NOT_MATCH
The rule parameter accepts four values. MATCH and NOT_MATCH compare a pattern and are
meaningful on channel only:
| Rule | Meaning | Accepted on |
|---|---|---|
INCLUDE | Whitelist — serve only on matching traffic | Every dimension except blocked advertisers on a placement |
EXCLUDE | Blacklist — never serve on matching traffic | Every dimension |
MATCH | Pattern match against the value | channel only |
NOT_MATCH | Inverse pattern match | channel only |
Corner case:
MATCH/NOT_MATCHapply to Channel targeting only. On any other dimension the create call refuses them with a400naming the dimension (rule MATCH applies to channel targeting only; use INCLUDE or EXCLUDE for DOMAIN.). Rules saved withMATCHorNOT_MATCHon another dimension (blocked advertisers aside) before that check existed were converted on upgrade to the rule they behaved as —MATCHtoINCLUDE,NOT_MATCHtoEXCLUDE— so a read now returns the converted rule.
Permissions
Three separate checks run on every targeting call, and they are easy to conflate:
| Check | Demand side (advertiser, campaign, banner) | Supply side (site, zone, placement) |
|---|---|---|
| User-level permission | Manage Demand Targeting | Manage Supply Pre-targeting |
| Entity access | UPDATE on the entity, via campaign sharing | UPDATE on the entity, via inventory sharing |
| Per-dimension permission | TARGETING_<DIMENSION> | PRETARGETING_<DIMENSION> |
Corner case: on sites, zones and placements the user-level permission is Manage Supply Pre-targeting, not Manage Demand Targeting. A supply-side role needs only the pretargeting permissions.
GET …/targeting/types.do returns the dimensions your role may use on that entity, already
filtered. A dimension missing from its output will be rejected on create with 403, so use it
for discovery rather than hardcoding the list of forty-one.
Value lookups
Enumerated values are served by sixteen lookup endpoints that are identical on all six entity levels:
GET …/targeting/browser/values.do
GET …/targeting/browser/chrome/values.do (also /firefox, /ie, /safari — version lists)
GET …/targeting/connection-type/values.do
GET …/targeting/country/region/values.do
GET …/targeting/country/region/city/values.do
GET …/targeting/device-format/values.do
GET …/targeting/device-vendor/values.do
GET …/targeting/language/values.do
GET …/targeting/mobile-carrier/values.do
GET …/targeting/operating-system/values.do
GET …/targeting/operating-system/{osName}/versions.do
GET …/targeting/screen-resolution/values.do
GET …/targeting/traffic-source/values.do
Three more are global — no entity in the path:
GET /rest-api/targeting/operating-system/values.do
GET /rest-api/targeting/operating-system/{osName}/versions.do
GET /rest-api/targeting/mobile-carrier/bycountry/values.do
The other dimensions take free-form or enum values documented in the tables above; they have no lookup endpoint.
The geography, language and DMP lists also exist without an entity in the path, so a script can look them up before it has anything to target. They need Manage Demand Targeting or Manage Supply Pre-targeting (read-only is enough):
GET /rest-api/targeting/country/values.do {"US": "United States", ...}
GET /rest-api/targeting/country/region/values.do?countryCode=US region names
GET /rest-api/targeting/country/region/city/values.do?countryCode=US®ionName=California
GET /rest-api/targeting/language/values.do {"en": "English", ...}
GET /rest-api/targeting/dmp/values.do [{"dmp": "FIRST_PARTY", "name": "First-Party"}, ...]
GET /rest-api/targeting/dmp/{dmp}/segments.do?parentId= one level of the segment tree
An unknown countryCode answers 400. The country list comes from the geo service; when that
service does not answer, country/values.do and mobile-carrier/bycountry/values.do answer
503 rather than an empty object — retry it. dmp/values.do lists only the DMPs your role
holds the permission of, and dmp/{dmp}/segments.do answers 403 for any other DMP. Each
segment entry carries id, title and segment — false marks a folder: pass its id
as parentId to open it. Only entries with segment: true can be targeted.
Stale locations
The geo database renames and merges places between updates, and a location rule naming a place it no longer knows matches no visitor. Global endpoints find, count, suggest and clean them up across every entity the caller may manage — the same list as Account → Stale locations (guide):
GET /rest-api/targeting/stale-locations.do
GET /rest-api/targeting/stale-locations/count.do
GET /rest-api/targeting/stale-locations/suggestions.do
POST /rest-api/targeting/stale-locations/suggestions.do
POST /rest-api/targeting/stale-locations/remove.do targetIds=8012&targetIds=8013[&confirmChanges=true]
POST /rest-api/targeting/stale-locations/replace.do targetId=8013&countryCode=US®ionName=Kentucky&cityName=Lexington
POST /rest-api/targeting/stale-locations/replace.do targetIds=8013&targetIds=8021&targetIds=8022&countryCode=US®ionName=Kentucky&cityName=Lexington
Each listed rule carries kind: SAFE (removing it changes nothing — the ad server ignores it
already), OPENS_ALL (the entity’s only includes of that type are stale: removing them lifts the
location limit) or STARTS_DELIVERY (a stale location exclude that keeps every visitor out).
remove.do removes OPENS_ALL and STARTS_DELIVERY rules only with confirmChanges=true; any
rule it leaves comes back in skipped with reason CONFIRM_REQUIRED, NOT_STALE,
FORBIDDEN or FAILED (the removal failed and the rule was left as it was; the others are still
removed). count.do answers demand and supply: how many listed rules of kind OPENS_ALL
or STARTS_DELIVERY sit on advertisers, campaigns and banners, and on sites, zones and
placements, entities switched off or with targeting off included. It reads a check up to five
minutes old (one minute while the geo service is not answering well enough) that a list request
refreshes, so asking it when a page loads is cheap; once that check is out of date, or after any
change to a location or country rule, the next count scans the whole network again, so do not poll
it in a loop. When the geo service cannot tell stale places
from valid ones the list and the count answer status: GEO_UNAVAILABLE and list or count nothing,
and remove.do / replace.do answer 503.
replace.do with targetId alone replaces that one rule and answers removedId, targetId,
value and alreadyPresent, or 404 / 403 when the rule is not a stale one the caller may
change. With targetIds (a targetId beside it is replaced too) it moves every listed rule to
the new place in one request — each rule on its own, with its own include or exclude and its own
action-log rows — and answers value, replaced (one {removedId, targetId, value, alreadyPresent} per rule) and skipped ({targetId, reason, message}, reason NOT_STALE,
FORBIDDEN or FAILED — that rule’s swap failed and was rolled back); a skipped rule does not hold
back the others. All the rules of one request must
name the same stale place with the same include or exclude — the list’s value and rule — and
be location rules; otherwise the answer is 400 and nothing is changed. A new place that is the
stale place itself (compared as the geo service compares names) is refused with 400 too.
suggestions.do says what each stale place is called now, as Fix with AI shows it. It changes
nothing. groups holds one entry per stale place and include or exclude: value, place,
rule, targetIds, kinds (rules per kind), entities (entities per level) and suggestion:
| Field | Meaning |
|---|---|
action | REPLACE — move the rules to countryCode / regionName / cityName with replace.do (pass the group’s targetIds); REMOVE — no current place matches and removing the rules changes nothing; KEEP — nothing is proposed: removing them would change delivery, or the geo service did not answer for the place, so the user decides |
reason, reasonParams, reasonText | SPELLING, SUFFIX (an administrative word such as “County” or “Stationsby” dropped), REGION_RENAMED, RENAMED, MERGED, NO_SUCCESSOR, NOT_MATCHED (names did not match and the AI was not asked), COUNTRY_RULE or GEO_UNANSWERED; the old and new name; the reason in the caller’s language |
confidence | HIGH, MEDIUM or LOW |
source | DETERMINISTIC (names) or AI |
Names are compared first. GET answers from them and from the answers the server already holds,
and never calls the AI model: ai is NOT_NEEDED when every place was answered, otherwise
SKIPPED, and the places left open read NOT_MATCHED. POST to the same path — what Fix with
AI sends — also asks the AI assistant’s model about the places names leave open; it picks only
from the geo database’s own list. It asks in as few calls as the lists allow (at most 12 of up to 60
places, four at a time) and waits for them at most two minutes. Those calls need what the assistant
needs — the AI_ASSISTANT_CHAT permission, the assistant switched on, a key and monthly budget
left, checked again before each call after the first four — and are billed like assistant calls; a
place another request is asking about at the same moment is not asked twice. ai says what
happened: USED, NOT_NEEDED, DISABLED, PERMISSION, NO_KEY, LIMIT or FAILED, with
aiMessage explaining a fallback to names alone. Answers are kept in the server’s memory for up to
a week, until it restarts, for every user, so a repeat request is cheap. An MCP client reaches the
GET with api_read; the POST, being billed, only with api_write.
Corner case:
location/create.dochecks the region and city as well as the country — an unknown one is a400Unknown region: … or Unknown city: … — and the console’s targeting card now checks them the same way, so a new rule cannot be stale from the start. A region or city name with a comma is stored quoted (United States,"Washington, D.C."), as the ad server reads it. Names are matched as the geo service matches them — any case, but accents and spaces as listed. A look-up that fails for a moment is settled from the country’s or region’s own list, and when that list cannot be read either the answer is a503, never a400for a real place.
Targeting examples
Target a campaign at the US and Germany:
curl -X POST -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targeting/country/create.do" \
-d "countryCode=US" -d "countryCode=DE" \
-d "rule=INCLUDE"
countryCode can also be one comma-separated value (countryCode=US,DE); each code is
trimmed and upper-cased. The same holds for country/create.do and browser-country/create.do
on sites, zones and placements — every level takes several codes in one call.
Only serve on Windows 10 or newer:
curl -X POST -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targeting/operating-system/create.do" \
-d "operatingSystem=WINDOWS" \
-d "version=10" -d "relation=GREATER_EQUAL" \
-d "rule=INCLUDE"
Full entry: POST /rest-api/campaign/{campaignId}/targeting/operating-system/create.do.
version is one of the entries of operating-system/{osName}/versions.do: its version
value (10.0, 16.-1) or its versionTitle (10, iOS 16.x.x). Anything else answers
400 with the list of valid versions, and so does a version on an OS that has no version
list (Linux, Chrome OS…) — the rule is never saved as “every version”. A version needs a
relation (EQUAL, GREATER_EQUAL, …): without one the ad server would ignore the version,
so it is a 400 too. The versions list names each version once (Android 12 and 12L share
12.-1), and a saved OS rule reads back operatingSystem, relation and version next to its
encoded value. Browsers differ: a
browserVersion on a browser without version targeting (the ones the console offers no
version field for) is not applied — the rule is saved on the whole browser, and the answer
lists browserVersion in ignoredFields with the reason in ignoredFieldReasons. On a browser
that does take a version, a browserVersion the server cannot read is still a 400.
Business hours only, in the visitor’s local time:
curl -X POST -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targeting/time-range/create.do" \
-d "timeFrom=09:00" -d "timeTo=17:00" \
-d "clientLocalTime=true" \
-d "rule=INCLUDE"
Full entry: POST /rest-api/campaign/{campaignId}/targeting/time-range/create.do.
List, then delete a rule — note that the filter takes the enum name, not the path segment:
curl -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targetings.do?targetType=COUNTRY"
curl -X DELETE -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targeting/987/delete.do"
Full entries: GET /rest-api/campaign/{campaignId}/targetings.do and DELETE /rest-api/campaign/{campaignId}/targeting/{targetId}/delete.do.
Delete every EXCLUDE rule on a campaign, or every rule when you leave the filters out:
curl -X DELETE -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targetings.do?rule=EXCLUDE"
# → {"success":true,"deleted":3}
Full entry: DELETE /rest-api/campaign/{campaignId}/targetings.do.
Targeting stays enabled after the rules are gone, as in the console.
A rule read back (targeting/{targetId}.do, targetings.do) carries, next to the stored
value, the fields its create operation takes — under the same names, with enums as names — so
it can be compared with what you sent. value itself is the internal encoding and
is kept only for existing clients.
Corner case: a threshold rule sent without
relation(possible on every level but placement) is saved with a default, which the read shows:LOWER_EQUALfor the browser, hardware and platform ranks and the price band,GREATER_EQUALfor device RAM, release year and traffic risk.date-timewithoutdayOfWeekcovers every day. The preset IP ranges group ispresetIpRangesGroupIdon every entity (ipRangesGroupIdis accepted too).
Serve when any rule type matches instead of all of them:
curl -X POST -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targeting/operation-between-rule-types.do" \
-d "operator=OR"
# → {"success":true,"operationBetweenRuleTypes":"OR"}
Full entry: POST /rest-api/campaign/{campaignId}/targeting/operation-between-rule-types.do.
Rules of one type combine with OR, except a list switched to ALL with match-mode.do; operator decides how the types combine (AND, the default, or
OR). It needs the Manage Operation Between TargetingRule Types
permission on top of the side’s targeting permission.
Target a DMP audience segment:
curl -X POST -H "X-Api-Key: $APIKEY" "https://<your-network-domain>/rest-api/campaign/2001/targeting/dmp/create.do" \
-d "dmp=FIRST_PARTY" -d "dmpSegmentId=4812" \
-d "rule=INCLUDE"
Full entry: POST /rest-api/campaign/{campaignId}/targeting/dmp/create.do.
dmpSegmentId is an id from dmp/{dmp}/segments.do. A segment of another DMP, or one
that does not exist, answers 400; a DMP your role has no permission for answers 403.
Preset groups
Presets are reusable lists (domains, app packages, IP ranges) referenced by preset targeting rules. Each family has eight operations. The three families are almost symmetrical, and the differences are all in the path:
| Purpose | Domains | App packages | IP ranges |
|---|---|---|---|
| List groups | GET /rest-api/preset-domain/group/list.do | GET /rest-api/preset-app-package/group/list.do | GET /rest-api/preset-ip-ranges/ip-ranges/list.do |
| Create/rename a group | POST …/group/save.do | POST …/group/save.do | POST …/group/save.do |
| Bulk upload entries | POST …/group/upload-domains.do | POST …/upload-packages.do | POST …/group/upload-ip-ranges.do |
| Add one entry | POST …/domain/add.do | POST …/add.do | POST …/ip-range/add.do |
| List entries of a group | GET …/domain/all-by-group.do | GET …/all-by-group.do | GET …/ip-range/all-by-group.do |
| Delete one entry | DELETE …/domain/delete.do | DELETE …/delete.do | DELETE …/ip-range/delete.do |
| Empty a group | DELETE …/group/clear.do | DELETE …/group/clear.do | DELETE …/group/clear.do |
| Delete a group | DELETE …/group/delete.do | DELETE …/group/delete.do | DELETE …/group/delete.do |
Corner case: adding an entry a group already has is a
400naming it, on all three families, and nothing is added.
Corner case:
group/delete.dorefuses a group that targeting rules of non-deleted entities still use:409, withusageslisting each entity (type,id,name) and amsgsaying what deleting would remove. Repeat the call withforce=trueto delete the group together with every rule that points at it; the answer’sremovedTargetingRulessays how many went.
Corner case: the entry paths differ per family. Domains nest under
/domain/, IP ranges under/ip-range/, and app-package entries sit directly under/preset-app-package/with no sub-segment. The IP-range group list is/ip-ranges/list.do, not/group/list.do.
Note — permissions: the domain and IP-range families both require the Preset Domains Group permission on the caller’s role; there is no separate IP-range permission. The app-package family requires Preset App Packages Group. Grant Preset Domains Group to any API client that maintains IP-range groups.
Category rules (rules engine)
Separate from targeting rules, the rules engine pairs inventory and demand by category or label. Rules are created globally, then attached per entity — 55 operations in all:
| Method | Path | Purpose |
|---|---|---|
| POST | /rest-api/rule/create.do | Create a rule |
| GET | /rest-api/rules.do | List rules |
| GET | /rest-api/rule/{ruleId}.do | Get a rule |
| POST | /rest-api/rule/{ruleId}/update.do, /delete.do | Update / delete |
| POST | /rest-api/rule/{ruleId}/matches/add.do, /matches/remove.do | Manage match conditions |
| POST | /rest-api/rules/{entity}/{entityId}/add.do, /remove.do, /enable.do, /disable.do | Attach/detach/toggle on advertiser, campaign, banner, placement, site, zone. POST only — a GET gets 405 |
| GET | /rest-api/rules/{entity}/{entityId}/get.do | The entity’s rule groups and rulesEnabled — the groups are listed whether or not rules are switched on |
| GET | /rest-api/rules/{entity}/available-types.do, /available-rules.do, /show-details.do | Discovery |
{entity} is advertiser, campaign, banner, placement, site or zone — all six, with
the same eight operations each.
Corner case:
add.dotakesruleIds,includeandoperator; if any id inruleIdsis not an existing rule the call is a400naming the unknown ids and no group is created. The answer carriesrulesEnabled; when the entity’s rules are switched off it adds awarning— the group is saved but does nothing untilenable.do.remove.do?ruleGroupId=…deletes the group only if it belongs to the entity in the path — a group of another entity, or an unknown id, is a404and nothing is deleted. Reading needs view rights on the entity:get.dois a403without them, andshow-details.do?ruleGroupId=…answers only for a group attached to an entity of the path’s type that you may view — any other id is a404. Neither needs Manage Rules.