- [Resource: AdRule](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRule)
  - [JSON representation](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRule.SCHEMA_REPRESENTATION)
- [AdRuleStatus](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleStatus)
- [AdRuleFrequencyCapBehavior](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleFrequencyCapBehavior)
- [AdRuleSlot](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot)
  - [JSON representation](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot.SCHEMA_REPRESENTATION)
- [AdRuleSlotBehavior](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBehavior)
- [AdRuleSlotMidrollFrequencyType](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotMidrollFrequencyType)
- [AdRuleSlotBumper](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBumper)
- [Methods](https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#METHODS_SUMMARY)

## Resource: AdRule

An AdRule contains data that the ad server will use to generate a playlist of video ads.

| JSON representation |
|---|
| ``` { "name": string, "midrolls": [ { object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot`) } ], "displayName": string, "priority": integer, "startTime": string, "endTime": string, "endTimeUnlimited": boolean, "status": enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleStatus`), "frequencyCapBehavior": enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleFrequencyCapBehavior`), "maxImpressionsPerLineItemPerStream": integer, "maxImpressionsPerLineItemPerPod": integer, "preroll": { object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot`) }, "postroll": { object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot`) }, "targeting": { object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/Targeting`) } } ``` |

| Fields ||
|---|---|
| `name` | `string` Identifier. The resource name of the `AdRule`. Format: `networks/{networkCode}/adRules/{ad_rule_id}` |
| `midrolls[]` | ``object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot`)`` Required. This AdRule object's video mid-roll slots. This attribute is required, and there must be at least one mid-roll. |
| `displayName` | `string` Required. The unique name of the AdRule. This attribute is required to create an ad rule and has a maximum length of 255 characters. |
| `priority` | `integer` Optional. The priority of the 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. |
| `startTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Required. The start time of the AdRule. This attribute is required and must be a date in the future for new ad rules. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `endTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Optional. This end time of the AdRule. This attribute is required unless `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRule.FIELDS.end_time_unlimited` is set to true. If specified, it must be after the `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRule.FIELDS.start_time`. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `endTimeUnlimited` | `boolean` Optional. Specifies whether or not the AdRule has an end time. This attribute is optional and defaults to false. |
| `status` | ``enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleStatus`)`` Output only. The AdRuleStatus of the AdRule. This attribute is read-only and defaults to `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleStatus.ENUM_VALUES.INACTIVE`. |
| `frequencyCapBehavior` | ``enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleFrequencyCapBehavior`)`` Optional. The FrequencyCapBehavior of the AdRule. This attribute is optional and defaults to `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleFrequencyCapBehavior.ENUM_VALUES.DEFER`. |
| `maxImpressionsPerLineItemPerStream` | `integer` Optional. This AdRule object's frequency cap for the maximum impressions per stream. This attribute is optional and defaults to 0. |
| `maxImpressionsPerLineItemPerPod` | `integer` Optional. This AdRule object's frequency cap for the maximum impressions per pod. This attribute is optional and defaults to 0. |
| `preroll` | ``object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot`)`` Required. This AdRule object's pre-roll slot. This attribute is required. |
| `postroll` | ``object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlot`)`` Required. This AdRule object's post-roll slot. This attribute is required. |
| `targeting` | ``object (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/Targeting`)`` Required. The targeting of the `AdRule`. |

## AdRuleStatus

Represents the status of ad rules and ad rule slots.

| Enums ||
|---|---|
| `AD_RULE_STATUS_UNSPECIFIED` | Default value. This value is unused. |
| `ACTIVE` | Created and ready to be served. Is user-visible. |
| `DELETED` | Marked as deleted, not user-visible. |
| `INACTIVE` | Inactive, not user-visible. |

## AdRuleFrequencyCapBehavior

Types of behavior for frequency caps within ad rules.

| Enums ||
|---|---|
| `AD_RULE_FREQUENCY_CAP_BEHAVIOR_UNSPECIFIED` | Default value. This value is unused. |
| `DEFER` | Defer frequency cap decisions to the next ad rule in priority order. |
| `TURN_OFF` | Turn off all frequency caps. |
| `TURN_ON` | Turn on at least one of the frequency caps. |

## AdRuleSlot

Simple object representing an ad slot within an AdRule. Ad rule slots contain information about the types/number of ads to display, as well as additional information on how the ad server will generate playlists.

| JSON representation |
|---|
| ``` { "slotBehavior": enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBehavior`), "maxVideoAdDuration": string, "videoMidrollFrequencyType": enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotMidrollFrequencyType`), "videoMidrollFrequency": string, "bumper": enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBumper`), "maxBumperDuration": string, "maxPodDuration": string, "podMaxAdCount": integer } ``` |

| Fields ||
|---|---|
| `slotBehavior` | ``enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBehavior`)`` Optional. The AdRuleSlotBehavior for video ads for this slot. This attribute is optional and defaults to `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBehavior.ENUM_VALUES.DEFER`. Indicates whether video ads are allowed for this slot, or if the decision is deferred to alower-priority ad rule. |
| `maxVideoAdDuration` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Optional. The maximum duration in milliseconds of video ads within this slot. This attribute is optional and defaults to 0. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `videoMidrollFrequencyType` | ``enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotMidrollFrequencyType`)`` Optional. The frequency type for video ads in this ad rule slot. This attribute is required for mid-rolls, but if this is not a mid-roll, the value is set to `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotMidrollFrequencyType.ENUM_VALUES.NONE`. |
| `videoMidrollFrequency` | `string` Optional. The mid-roll frequency of this ad rule slot for video ads. This attribute is required for mid-rolls, but if MidrollFrequencyType is set to `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotMidrollFrequencyType.ENUM_VALUES.NONE`, this value should be ignored. For example, if this slot has a frequency type of `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotMidrollFrequencyType.ENUM_VALUES.EVERY_N_SECONDS` and #videoMidrollFrequency = "60", this would mean "play a mid-roll every 60 seconds." |
| `bumper` | ``enum (`https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBumper`)`` Optional. The AdRuleSlotBumper for this slot. This attribute is optional and defaults to `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotBumper.ENUM_VALUES.NONE`. |
| `maxBumperDuration` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Optional. The maximum duration of bumper ads within this slot. This attribute is optional and defaults to 0. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `maxPodDuration` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Optional. The maximum pod duration for this slot. This attribute is optional and defaults to 0. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `podMaxAdCount` | `integer` Optional. The maximum number of ads allowed in a pod in this slot. This attribute is optional and defaults to 0. |

## AdRuleSlotBehavior

The types of behaviors for ads within a BaseAdRuleSlot ad rule slot.

| Enums ||
|---|---|
| `AD_RULE_SLOT_BEHAVIOR_UNSPECIFIED` | Default value. This value is unused. |
| `ALWAYS_SHOW` | This ad rule always includes this slot's ads. |
| `DEFER` | Defer to lower priority rules. This ad rule doesn't specify guidelines for this slot's ads. |
| `NEVER_SHOW` | This ad rule never includes this slot's ads. |

## AdRuleSlotMidrollFrequencyType

Frequency types for mid-roll BaseAdRuleSlot ad rule slots.

| Enums ||
|---|---|
| `AD_RULE_SLOT_MIDROLL_FREQUENCY_TYPE_UNSPECIFIED` | Default value. This value is unused. |
| `EVERY_N_CUEPOINTS` | MidrollFrequency is a cue point interval and is a single integer value, such as "5", which means "play a mid-roll every 5th cue point". |
| `EVERY_N_SECONDS` | MidrollFrequency is a time interval and mentioned as a single numeric value in seconds. For example, "100" would mean "play a mid-roll every 100 seconds". |
| `FIXED_CUE_POINTS` | Same as `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules#AdRuleSlotMidrollFrequencyType.ENUM_VALUES.FIXED_TIME`, except the values represent the ordinal cue points ("1,3,5", for example). |
| `FIXED_TIME` | MidrollFrequency is a comma-delimited list of points in time (in seconds) when an ad should play. For example, "100,300" would mean "play an ad at 100 seconds and 300 seconds". |
| `NONE` | The ad rule slot is not a mid-roll and MidrollFrequency should be ignored. |
| `REVERSE_MIDROLL_INDEX` | After all other frequency type is applied and the number of midrolls are settled, this slot setting will override the mid-roll defined by ReverseMidrollIndex. |

## AdRuleSlotBumper

Types of bumper ads on an ad rule slot.

| Enums ||
|---|---|
| `AD_RULE_SLOT_BUMPER_UNSPECIFIED` | Default value. This value is unused. |
| `AFTER` | Show a bumper ad after the slot's other ads. |
| `BEFORE` | Show a bumper ad before the slot's other ads. |
| `BEFORE_AND_AFTER` | Show a bumper before and after the slot's other ads. |
| `NONE` | Do not show a bumper ad. |

| ## Methods ||
|---|---|
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/batchActivate` | Activates a list of `AdRule` objects. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/batchCreate` | Batch creates `AdRule` objects. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/batchDeactivate` | Deactivates a list of `AdRule` objects. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/batchDelete` | Deletes a list of `AdRule` objects. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/batchUpdate` | Batch updates `AdRule` objects. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/create` | Creates a `AdRule` object. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/get` | Retrieves an `AdRule` object. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/list` | Lists `AdRule` objects. |
| ### `https://developers.google.com/ad-manager/api/beta/reference/rest/v1/networks.adRules/patch` | Updates a `AdRule` object. |