Skip to main content
A targeting option (option) is a named set of Context IDs in a context targeting, such as “Sports” with sport, baseball, and soccer. In API paths and fields, an option is a category, and its Context IDs are contexts. An option has one of two types:
  • atomic: a list of Context IDs.
  • collection: an option that matches its own Context IDs and those of its sub-options. See Option groups.
Paths on this page are relative to https://lake.adrop.io. For authentication and request format, see Basic Information.

Option Object

The endpoints on this page return options in this shape. The object holds the number of Context IDs, not the Context IDs themselves. To read them, use Get an Option. Fields that don’t apply to an option are omitted.

List Options

Returns the options of a targeting page by page, in ascending _id order (roughly the order they were created). Option groups and sub-options are included. Each item is an option object.

Request

Requires the context-targeting:read scope.

Path Parameters

Query Parameters

Example Request

Example Response

To get the next page, send the same request with next=01JAB3XK5RA1B2C3D4E5F6G7H8.
  • The last page has no next. If you follow next until it’s absent, you get every option exactly once.
  • A page can have fewer items than limit even when more pages follow. Stop only when next is absent.
  • There’s no search by name. Filter the items by name, parent, or children on your side.
Errors

Get an Option

Returns an option with a page of its Context IDs.

Request

Requires the context-targeting:read scope.

Path Parameters

Query Parameters

Example Request

Example Response

The response is the option object with these fields added:
  • To read all Context IDs of an option, increase offset by limit until offset reaches contextCount.
  • For an option group, contexts holds only the option group’s own Context IDs, so page through them up to ownContextCount. To read the Context IDs of a sub-option, get the sub-option.
Errors

Add an Option

Adds an option to an existing targeting. You can add a regular option, an option group, or a sub-option of an existing option group.

Request

Requires the context-targeting:write scope. The response is 201 with the new option object.

Path Parameters

Request Body

The server issues all IDs. A body with _id or any other field not listed here fails with 400. These combinations fail with 400 TARGETING_CATEGORY_NOT_SUPPORTED, and nothing is created:
  • An option group with no sub-options and no Context IDs of its own
  • type: "atomic" with children
  • exposeChildren on a regular option
  • parent with type: "collection", children, or exposeChildren. An option added to an option group is always a regular option
  • parent set to an option that isn’t a top-level option group
One request can create up to 5,000 options, counting an option group and its sub-options, and can carry up to 10,000 Context IDs in total. To add many options in one request, use Add Options in Bulk.

Example Request

Example Response

A new top-level option can be added to the ad products that use the targeting, and to their campaigns. See Effects on Ad Products and Campaigns.
Errors For all error codes and the error format, see Error Codes.

Update an Option

Renames an option, changes its Context IDs, moves it into, out of, or between option groups, or changes whether an option group shows its sub-options to advertisers.

Request

Requires the context-targeting:write scope. The response is 200 with the updated option object.

Path Parameters

Request Body

All fields are optional. Send only the fields you want to change. Fields you omit stay as they are. These rules apply to the body:
  • contexts must include add, remove, or set, and set can’t be combined with add or remove. Otherwise the request fails with 400.
  • parent can’t be combined with contexts. Move or detach an option in one request and change its Context IDs in another. parent can be combined with name. If the move fails, the name doesn’t change either.
  • Only parent accepts null. null in name, contexts, exposeChildren, add, remove, or set fails with 400. To leave a field unchanged, omit it.
  • An option group can’t be moved. parent on an option group fails with 400 TARGETING_CATEGORY_NOT_SUPPORTED, and so does exposeChildren on a regular option.
  • For an option group, contexts changes its own Context IDs. Removing all own Context IDs of an option group that has no sub-options fails with 400 TARGETING_CATEGORY_NOT_SUPPORTED.
  • name, contexts, and exposeChildren are written together. If the Context ID change fails, the name and exposeChildren don’t change. If you send both add and remove, add is applied first, so the added Context IDs stay even if remove fails.
You can rename a sub-option and change its Context IDs in the same way as any regular option. To choose between add/remove and set, see Updating Context IDs.

Example Request

Example Response

Errors

Delete an Option

Deletes an option and its Context IDs.
  • Deleting an option group promotes its sub-options to the top level, and they take over the option group’s settings in ad products and campaigns. If the option group had Context IDs of its own, they stop matching. See Delete an option group.
  • You can’t delete the last sub-option of an option group that has no Context IDs of its own. Delete the option group instead.
Deleting an option isn’t blocked when campaigns use it. Check Effects on Ad Products and Campaigns before you delete an option.

Request

Requires the context-targeting:write scope. The response is 200 with the ID of the deleted option.

Path Parameters

Example Request

Example Response

Errors

Bulk Operations

The bulk endpoints add, update, or delete up to 5,000 options in one request. They require the context-targeting:write scope.
  • Unless the request fails as a whole, each bulk endpoint returns 200 with a result for each item, in request order. Check success on each result. A failed item has an error. See Bulk Responses.
  • A request with an invalid body fails as a whole with 400, even if only one item is invalid. Examples are a Context ID that breaks the Context ID Rules, set combined with add, or a field that isn’t accepted.
  • API writes for a project are processed one at a time. Send bulk requests one after another, not in parallel. See Concurrent Writes.
Each request must stay within these limits: Option group items are:
  • Add: items that create an option group (type: "collection" or children) and items with parent.
  • Update: items with parent, null included.
  • Delete: IDs of option groups and sub-options.
A request that breaks a limit fails as a whole with 400, and nothing in it is applied. If a delete request has more than 150 option groups and sub-options, the error is TARGETING_CATEGORY_TREE_ITEMS_LIMIT_EXCEEDED, with the limit in detail.limit and the number of option groups and sub-options in your request in detail.count. To upload a large set, such as tens of thousands of options, send requests of up to 5,000 items one after another.

Add Options in Bulk

Adds options to existing targetings. Each item can add to a different targeting.

Request

Request Body

A successful item has the new option object in data.

Example Request

Example Response

The targeting already has an option named “Sports”, so only the third item fails.

Update Options in Bulk

Updates options. Each item can change a different option.

Request

Request Body

  • Each _id can appear only once per request. A repeated _id fails the whole request with 400, so put all changes for one option into one item.
  • Items are applied separately and can run at the same time. Results are still returned in request order.
  • A name that an earlier item frees can be used by a later item in the same request.
A successful item has the updated option object in data.

Example Request

Example Response

Delete Options in Bulk

Deletes options. The same rules as Delete an Option apply to each ID.
Don’t delete an option group and its sub-options in the same request. Option groups and sub-options are processed in request order. If the option group comes first, its sub-options are promoted to the top level and then deleted as top-level options. If the sub-options come first and the option group has no Context IDs of its own, deleting the last sub-option fails and it stays.

Request

Request Body

A successful item has the ID of the deleted option in data.

Example Request

Example Response


Context ID Rules

These rules apply to every Context ID you send, in contexts, children, add, remove, and set. If any Context ID in a request breaks these rules, the whole request fails with 400. The same Context ID can be in more than one option. A request with that Context ID matches all of those options. The exception is an option group’s own Context IDs, which can’t be an own Context ID of another option group in the project. See Constraints. Context IDs are also limited by count and size: A change that would put an option or the project over its limit fails with 400 TARGETING_CONTEXT_LIMIT_EXCEEDED. These limits are checked only when a change makes an option or the project larger, so a change that only removes Context IDs is never blocked. A request with more than 10,000 Context IDs fails as a whole with 400. For all limits, see Limits.

Updating Context IDs

Change Context IDs with add/remove or with set in Update an Option or Update Options in Bulk. add, remove, and set give the same result if you send the same request again, so you can resend them after a timeout. See Retries and Duplicate Requests. More than 10,000 Context IDs A request can carry up to 10,000 Context IDs, so set can’t replace a longer list in one request. Sync the option this way instead:
  1. Read the option’s current Context IDs with Get an Option, paging with offset and limit.
  2. Compare them with your list.
  3. Send only the differences with add and remove, up to 10,000 Context IDs per request, one request after another.
Don’t split a full list into several set requests. Each set replaces all Context IDs, so a later set drops the Context IDs of an earlier one. Even one set followed by add requests leaves the option with only part of its list between requests, and ad serving can pick up that partial list. Changes reach ad serving after a short delay. To check whether a change has been loaded, see When Changes Take Effect.

Effects on Ad Products and Campaigns

Ad products and campaigns select options, so changing an option can change where campaigns serve. Adding or removing Context IDs changes the pages where campaigns that include or exclude the option can serve. New top-level options When you add a top-level option, either a regular option or an option group, ad products that have settings for the targeting also get the option:
  • If an ad product sets every current top-level option of the targeting to Required Include, the new option is also set to Required Include, and the product’s campaigns that haven’t ended include it too. Required Exclude works the same way.
  • Otherwise, the new option is added to the ad product as an option advertisers can select. This is the case when some top-level options aren’t required, or when they mix Required Include and Required Exclude. Campaigns don’t change.
So for an ad product that requires every option, a new option widens where its campaigns serve (Required Include) or narrows it (Required Exclude). Once one top-level option of the targeting isn’t required in the ad product, later new options are added as selectable options too. To require them, change the ad product’s targeting in the console. See Selling Targeting. A sub-option added to an option group isn’t added to ad products by itself. Instead, the option group also matches the sub-option’s Context IDs. See Add an Option to an option group. Limit on required options An ad product can have up to 500 options set to Required Include or Required Exclude, across all its targetings. If the rule above would put an ad product over this limit, the new top-level options aren’t created and fail with 400 AD_PRODUCT_TARGETING_POLICY_LIMIT_EXCEEDED. In a bulk request, every new top-level option for that targeting fails, and the other items are applied. Reduce the required options of the ad product in the console, then send the request again. The same limit applies when you delete an option group or detach a sub-option, because the option group’s settings are copied to its sub-options. Deleting options Deleting an option isn’t blocked when campaigns use it, unlike deleting a targeting. The option is removed from the campaigns that select it. If it was the only option from the targeting that a campaign included, the campaign no longer requires any of the targeting’s Context IDs. Instead of stopping, it can serve on requests with other Context IDs or with none. Before you delete an option, check whether campaigns use it. In the console, an option with campaigns booked has the In Use status. See Managing Targeting. Change or end those campaigns before you delete the option. Excluding Context IDs An option only lists the Context IDs to match. There’s no condition for “not in this option”. To keep ads off certain pages, put the Context IDs of those pages in an option and exclude the option in the ad product or campaign, for example with Required Exclude on the ad product. Don’t build an option that lists every other Context ID.