# Best practices

This page details limits and best practices for managing targeting using the
Display \& Video 360 API.

## Targeting assigned at line item creation

Some targeting types have default values assigned at line item creation. Those
targeting types are:

- [`TARGETING_TYPE_DEVICE_TYPE`](https://developers.google.com/display-video/api/reference/rest/current/TargetingType#ENUM_VALUES.TARGETING_TYPE_DEVICE_TYPE)
- [`TARGETING_TYPE_EXCHANGE`](https://developers.google.com/display-video/api/reference/rest/current/TargetingType#ENUM_VALUES.TARGETING_TYPE_EXCHANGE)
- [`TARGETING_TYPE_ON_SCREEN_POSITION`](https://developers.google.com/display-video/api/reference/rest/current/TargetingType#ENUM_VALUES.TARGETING_TYPE_ON_SCREEN_POSITION)

To avoid errors, be aware of the full targeting suite that is assigned to your
line items upon creation. You can retrieve all targeting assigned to a line item
across use [`bulkListAssignedTargetingOptions`](https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems/bulkListAssignedTargetingOptions).

Some settings are implied when no targeting of a type is assigned. For example,
if a line item doesn't have a
[`TARGETING_TYPE_AUTHORIZED_SELLER_STATUS`](https://developers.google.com/display-video/api/reference/rest/current/TargetingType#ENUM_VALUES.TARGETING_TYPE_AUTHORIZED_SELLER_STATUS)
targeting option assigned, the line item will use "Authorized Direct Sellers
and Resellers" when serving ads.

## Targeting options may be deprecated

Targeting options are not static. A small number of options may be deprecated
from time to time. Deprecated targeting options don't affect a line item's ad
serving. After deprecation, these options will be unassigned. Requests
attempting to retrieve or assign these options will result in errors.

To avoid these errors, **regularly check stored targeting option IDs** . To
conserve quota, we recommend [caching regularly-used IDs](https://developers.google.com/display-video/api/guides/concepts/optimization/quota#cache_ids).
Storing IDs means that you may not realize a targeting option has been
deprecated. Regularly use the [`get`](https://developers.google.com/display-video/api/reference/rest/current/targetingTypes.targetingOptions/get) method to retrieve all stored
targeting option IDs to confirm that they are still supported by
Display \& Video 360.

## Concurrent targeting requests to the same line item will fail

Attempting to update settings or assigned targeting for a line item using
concurrent requests will return an error.

To add or remove multiple assigned targeting options for a single line item at
the same time, use a single
[`bulkEditAssignedTargetingOptions`](https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems/bulkEditAssignedTargetingOptions) request. If you want to
update a line item's settings and targeting, queue your requests to ensure that
they are sent in sequence.

## Common targeting errors

There are three common causes of errors when managing targeting using the
Display \& Video 360 API.

### Configuration errors

Targeting is bound by configuration restrictions. If a request attempts to
update targeting so that it violates these rules, the request will return an
error.

Configuration errors are often caused by existing targeting. To avoid this, do
the following:

1. Get existing targeting of a given type using a [`list`](https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems.targetingTypes.assignedTargetingOptions/list) request.
2. Review existing targeting. Assess what targeting needs to be added or removed to result in wanted configuration.
3. Update targeting using a [`bulkEditAssignedTargetingOptions`](https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems/bulkEditAssignedTargetingOptions) request.

Targeting inherited by parent resources can't be removed but can cause these
errors.

### YouTube \& Partners errors

You can't update YouTube \& Partners targeting using the Display \& Video 360 API. Requests
that attempt to update this targeting will return an error.

This targeting is defined as:

- Any targeting assigned to a YouTube \& partners [line
  item](https://developers.google.com/display-video/api/guides/concepts/campaign-resources/youtube#line_items) or [ad group](https://developers.google.com/display-video/api/guides/concepts/campaign-resources/youtube#ad_groups_and_ads).
- Advertiser targeting of session positions and individual YouTube channels and videos.

### Concurrency errors

Requests updating the settings or targeting of the same line item at the same
time can return an error.

To avoid this:

- Manage targeting in bulk using a [bulk edit request](https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems/bulkEditAssignedTargetingOptions).
- Queue requests that [update](https://developers.google.com/display-video/api/reference/rest/current/advertisers.lineItems/patch) the same line item. Don't send a request until the previous request returns a response.