**Service** **AdRuleService** **Dependencies** [AdRulePage](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRulePage) [createAdRules()](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService#createAdRules) [updateAdRules()](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService#updateAdRules) ▼ **AdRule**

An [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) contains data that the ad server will use to generate a playlist of video ads.

*** ** * ** ***

Namespace
:
    `https://www.google.com/apis/ads/publisher/v202605`

| ## Field ||
|---|---|
| ### `id` | ` xsd:long` The unique ID of the [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule). This value is readonly and is assigned by Google. |
| ### `name` | ` xsd:string` The unique name of the [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule). This attribute is required to create an ad rule and has a maximum length of 255 characters. |
| ### `priority` | ` xsd:int` The priority of the [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule). This attribute is required and can range from 1 to 1000, with 1 being the highest possible priority. Changing an ad rule's priority can affect the priorities of other ad rules. For example, increasing an ad rule's priority from 5 to 1 will shift the ad rules that were previously in priority positions 1 through 4 down one. <br /> |
| ### `targeting` | ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.Targeting ` The targeting criteria of the [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule). This attribute is required. |
| ### `startDateTime` | ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.DateTime ` This [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) object's start date and time. This attribute is required and must be a date in the future for new ad rules. |
| ### `startDateTimeType` | ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.StartDateTimeType ` Specifies whether to start using the [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) right away, in an hour, etc. This attribute is optional and defaults to [StartDateTimeType.USE_START_DATE_TIME](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.StartDateTimeType#USE_START_DATE_TIME). *** ** * ** *** **Enumerations** `USE_START_DATE_TIME` :   Use the value in [startDateTime](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule#startDateTime). `IMMEDIATELY` :   The entity will start serving immediately. [startDateTime](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule#startDateTime) in the request is ignored and will be set to the current time. Additionally, [startDateTimeType](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule#startDateTimeType) will be set to [StartDateTimeType.USE_START_DATE_TIME](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.StartDateTimeType#USE_START_DATE_TIME). `ONE_HOUR_FROM_NOW` :   The entity will start serving one hour from now. [startDateTime](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule#startDateTime) in the request is ignored and will be set to one hour from the current time. Additionally, [startDateTimeType](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule#startDateTimeType) will be set to [StartDateTimeType.USE_START_DATE_TIME](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.StartDateTimeType#USE_START_DATE_TIME). `UNKNOWN` :   The value returned if the actual value is not exposed by the requested API version. <br /> |
| ### `endDateTime` | ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.DateTime ` This [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) object's end date and time. This attribute is required unless `unlimitedEndDateTime` is set to `true`. If specified, it must be after the `startDateTime`. |
| ### `unlimitedEndDateTime` | ` xsd:boolean` Specifies whether the [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) has an end time. This attribute is optional and defaults to false. |
| ### `status` | ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRuleStatus ` The [AdRuleStatus](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRuleStatus) of the ad rule. This attribute is read-only and defaults to [AdRuleStatus.INACTIVE](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRuleStatus#INACTIVE). *** ** * ** *** **Enumerations** `ACTIVE` :   Created and ready to be served. Is user-visible. `INACTIVE` :   Paused, user-visible. `UNKNOWN` :   The value returned if the actual value is not exposed by the requested API version. <br /> |
| ### `frequencyCapBehavior` | ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.FrequencyCapBehavior ` The [FrequencyCapBehavior](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.FrequencyCapBehavior) of the [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule). This attribute is optional and defaults to [FrequencyCapBehavior.DEFER](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.FrequencyCapBehavior#DEFER). *** ** * ** *** **Enumerations** `TURN_ON` :   Turn on at least one of the frequency caps. `TURN_OFF` :   Turn off all frequency caps. `DEFER` :   Defer frequency cap decisions to the next ad rule in priority order. `UNKNOWN` :   The value returned if the actual value is not exposed by the requested API version. <br /> |
| ### `maxImpressionsPerLineItemPerStream` | ` xsd:int` This [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) object's frequency cap for the maximum impressions per stream. This attribute is optional and defaults to 0. |
| ### `maxImpressionsPerLineItemPerPod` | ` xsd:int` This [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) object's frequency cap for the maximum impressions per pod. This attribute is optional and defaults to 0. |
| ### `preroll` | 1. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.BaseAdRuleSlot ` 1. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.NoPoddingAdRuleSlot ` 2. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.OptimizedPoddingAdRuleSlot ` 3. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.StandardPoddingAdRuleSlot ` 4. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.UnknownAdRuleSlot ` <br /> This [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) object's pre-roll slot. This attribute is required. |
| ### `midroll` | 1. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.BaseAdRuleSlot ` 1. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.NoPoddingAdRuleSlot ` 2. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.OptimizedPoddingAdRuleSlot ` 3. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.StandardPoddingAdRuleSlot ` 4. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.UnknownAdRuleSlot ` <br /> This [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) object's mid-roll slot. This attribute is required. |
| ### `postroll` | 1. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.BaseAdRuleSlot ` 1. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.NoPoddingAdRuleSlot ` 2. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.OptimizedPoddingAdRuleSlot ` 3. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.StandardPoddingAdRuleSlot ` 4. ` https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.UnknownAdRuleSlot ` <br /> This [AdRule](https://developers.google.com/ad-manager/api/reference/v202605/AdRuleService.AdRule) object's post-roll slot. This attribute is required. |