You can use the Google Ads API to set bid adjustments (also called bid modifiers) for
hotel ads. For details about how bid adjustments work, see
[About bid adjustments for Hotel ads](https://support.google.com/google-ads/answer/9244121).

## Campaign-level bid adjustments

To use the Google Ads API to set bid adjustments at the campaign level, see
[Manage bid modifiers](https://developers.google.com/google-ads/api/docs/campaigns/bidding/manage-bid-modifiers.md.txt).

## Ad group-level bid adjustments

Starting in v26, the five hotel-specific criteria on
[`AdGroupBidModifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupBidModifier.md.txt) are renamed to vertical-agnostic
names (such as start day of week and length of booking), replacing the
hotel-specific criteria from earlier versions. These bid adjustments remain
supported only for hotel ads---both in Hotel campaigns and in Search Campaigns
for Travel. Existing bid modifiers created in v25 or earlier carry over
automatically with identical criterion IDs and resource names. For a summary of
all v26 breaking changes, see the [release notes](https://developers.google.com/google-ads/api/docs/release-notes.md.txt#v26-breaking-changes).

To set bid adjustments at the ad group level, create a criterion object for the
dimension you want to target and set its fields to the appropriate values. In
v26 and later, use the vertical-agnostic criterion objects:
[`AdvanceBookingWindowInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdvanceBookingWindowInfo.md.txt),
[`UserSetDatesInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserSetDatesInfo.md.txt),
[`StartDayOfWeekInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/StartDayOfWeekInfo.md.txt),
[`LengthOfBookingInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/LengthOfBookingInfo.md.txt), or
[`StartDateRangeInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/StartDateRangeInfo.md.txt). In v25 and earlier, use the
hotel-specific criterion objects:
[`HotelAdvanceBookingWindowInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelAdvanceBookingWindowInfo.md.txt),
[`HotelDateSelectionTypeInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelDateSelectionTypeInfo.md.txt),
[`HotelCheckInDayInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelCheckInDayInfo.md.txt),
[`HotelLengthOfStayInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelLengthOfStayInfo.md.txt), or
[`HotelCheckInDateRangeInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelCheckInDateRangeInfo.md.txt).

The following table summarizes the `AdGroupBidModifier` criterion fields,
message types, subfields, and valid `bid_modifier` ranges across API versions:

| v25 and earlier | v26 and later | Subfields and types | Description and valid range |
|---|---|---|---|
| `hotel_date_selection_type` ([`HotelDateSelectionTypeInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelDateSelectionTypeInfo.md.txt)) | `user_set_dates` ([`UserSetDatesInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserSetDatesInfo.md.txt)) | [`type`](https://developers.google.com/google-ads/api/reference/rpc/v26/UserSetDatesInfo.md.txt#type): [`DateSelectionType`](https://developers.google.com/google-ads/api/reference/rpc/v26/DateSelectionTypeEnum.DateSelectionType.md.txt) in v26 (`HotelDateSelectionType` in v25). Values: `DEFAULT_SELECTION` (criterion ID `50`), `USER_SELECTED` (criterion ID `51`). `IMMUTABLE`. | Default dates versus user-selected dates. Valid `bid_modifier` range: `0.5` to `2.0` (does not support `0` opt-out). |
| `hotel_advance_booking_window` ([`HotelAdvanceBookingWindowInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelAdvanceBookingWindowInfo.md.txt)) | `advance_booking_window` ([`AdvanceBookingWindowInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdvanceBookingWindowInfo.md.txt)) | `min_days`, `max_days` (`int64`, `0`--`330`). `IMMUTABLE`, required. | Number of days before the start date of the booking. Valid `bid_modifier` range: `0.1` to `10.0`, or `0` to opt out. |
| `hotel_length_of_stay` ([`HotelLengthOfStayInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelLengthOfStayInfo.md.txt)) | `length_of_booking` ([`LengthOfBookingInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/LengthOfBookingInfo.md.txt)) | `min_days`, `max_days` in v26 (`min_nights`, `max_nights` in v25) (`int64`, `1`--`30`). `IMMUTABLE`, required. | Length of the booking. Valid `bid_modifier` range: `0.1` to `10.0`, or `0` to opt out. |
| `hotel_check_in_day` ([`HotelCheckInDayInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelCheckInDayInfo.md.txt)) | `start_day_of_week` ([`StartDayOfWeekInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/StartDayOfWeekInfo.md.txt)) | `day_of_week` (`DayOfWeek`, criterion IDs `60`--`66` for `MONDAY`--`SUNDAY`). `IMMUTABLE`. | Day of the week of the booking start date. Valid `bid_modifier` range: `0.1` to `10.0`, or `0` to opt out. |
| `hotel_check_in_date_range` ([`HotelCheckInDateRangeInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelCheckInDateRangeInfo.md.txt)) | `start_date_range` ([`StartDateRangeInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/StartDateRangeInfo.md.txt)) | `start_date`, `end_date` (`string`, `YYYY-MM-DD`). `IMMUTABLE`, required. | Date range of the booking start date. Valid `bid_modifier` range: `0.1` to `10.0`, or `0` to opt out. |

> [!NOTE]
> **Note:** In [`LengthOfBookingInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/LengthOfBookingInfo.md.txt), `min_nights` and `max_nights` are renamed to `min_days` and `max_days`, and existing numeric values carry over 1:1 (for example, `hotel_length_of_stay.min_nights = 3` is returned as `length_of_booking.min_days = 3` in v26). When migrating to v26, copy existing numeric values directly without converting between nights and days.

For example, to create an ad group bid modifier using an advance booking window
between 30 and 60 days in v26 and later, create an
[`AdvanceBookingWindowInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdvanceBookingWindowInfo.md.txt) object (or
[`HotelAdvanceBookingWindowInfo`](https://developers.google.com/google-ads/api/reference/rpc/v25/HotelAdvanceBookingWindowInfo.md.txt) in v25 and
earlier) and set `min_days` to `30` and `max_days` to `60`.

Associate the criterion object with an
[`AdGroupBidModifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupBidModifier.md.txt) object using the corresponding
criterion field (`advance_booking_window`, `user_set_dates`,
`start_day_of_week`, `length_of_booking`, or `start_date_range`), specify the
resource name of the target ad group using `ad_group`, and set the
[`bid_modifier`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupBidModifier.md.txt#bid_modifier) field to a multiplier:

- **`advance_booking_window`, `length_of_booking`, `start_day_of_week`,
  `start_date_range`, and `device`:** Specify a multiplier from `0.1` to `10.0` (for example, `1.5` for a +50% adjustment, or `0.5` for a -50% adjustment), or set `bid_modifier` to `0` (`0.0`) to opt out (`-100%`) of the criterion.
- **`user_set_dates`:** Specify a multiplier from `0.5` to `2.0`. Setting `bid_modifier` to `0` is not supported for `user_set_dates` and returns `RangeError.TOO_LOW`.

For more details about how each adjustment type works, see
[About bid adjustments for Hotel ads](https://support.google.com/google-ads/answer/9244121).

> [!NOTE]
> **Note:** These travel dimensions can be set only at the ad group level. Device bid adjustments can be set at both the campaign and ad group levels; if an ad group has a device adjustment, it overrides the campaign's device adjustment (unless the campaign opts out of that device with `bid_modifier = 0`).

The following reporting segment and resource limit details also apply in v26:

- **`segments.user_set_dates`:** In v26 and later, the enum type of `segments.user_set_dates` is [`DateSelectionType`](https://developers.google.com/google-ads/api/reference/rpc/v26/DateSelectionTypeEnum.DateSelectionType.md.txt) (updated from `HotelDateSelectionType` in v25 and earlier; Hotel campaign reports using `segments.hotel_date_selection_type` continue to use `HotelDateSelectionType`). The other itinerary segments (`segments.advance_booking_window`, `segments.length_of_booking`, `segments.start_date`, and `segments.start_day_of_week`) are unchanged.
- **Resource limits:** `ResourceLimitType.HOTEL_ADVANCE_BOOKING_WINDOW_BID_MODIFIERS_PER_AD_GROUP` and `ResourceLimitType.HOTEL_CHECK_IN_DATE_RANGE_BID_MODIFIERS_PER_AD_GROUP` retain their existing names in v26.

> [!NOTE]
> **Note:** The following client library code example shows v25 `hotel_*` field names. In v26 and later, use the vertical-agnostic field and message names listed in the preceding table.


### Java

```java
private void runExample(GoogleAdsClient googleAdsClient, long customerId, long adGroupId) {
  List<AdGroupBidModifierOperation> operations = new ArrayList<>();

  // Constructs the ad group resource name to use for each bid modifier.
  String adGroupResourceName = ResourceNames.adGroup(customerId, adGroupId);

  // 1) Creates an ad group bid modifier based on the hotel check-in day.
  AdGroupBidModifier checkInDayAdGroupBidModifier =
      AdGroupBidModifier.newBuilder()
          // Sets the resource name to the ad group resource name joined with the criterion ID
          // whose value corresponds to the desired check-in day.
          .setAdGroup(adGroupResourceName)
          .setStartDayOfWeek(StartDayOfWeekInfo.newBuilder().setDayOfWeek(DayOfWeek.MONDAY))
          // Sets the bid modifier value to 150%.
          .setBidModifier(1.5d)
          .build();
  operations.add(
      AdGroupBidModifierOperation.newBuilder().setCreate(checkInDayAdGroupBidModifier).build());

  // 2) Creates an ad group bid modifier based on the hotel length of stay.
  AdGroupBidModifier lengthOfStayAdGroupBidModifier =
      AdGroupBidModifier.newBuilder()
          // Sets the ad group.
          .setAdGroup(adGroupResourceName)
          // Creates the length of booking info.
          .setLengthOfBooking(
              LengthOfBookingInfo.newBuilder().setMinDays(3L).setMaxDays(7L).build())
          // Sets the bid modifier value to 170%.
          .setBidModifier(1.7d)
          .build();
  operations.add(
      AdGroupBidModifierOperation.newBuilder().setCreate(lengthOfStayAdGroupBidModifier).build());

  // Issues a mutate request to add the ad group bid modifiers.
  try (AdGroupBidModifierServiceClient adGroupBidModifierServiceClient =
      googleAdsClient.getLatestVersion().createAdGroupBidModifierServiceClient()) {
    MutateAdGroupBidModifiersResponse response =
        adGroupBidModifierServiceClient.mutateAdGroupBidModifiers(
            Long.toString(customerId), operations);

    // Prints the resource names of the added ad group bid modifiers.
    System.out.printf("Added %d hotel ad group bid modifiers:%n", response.getResultsCount());
    for (MutateAdGroupBidModifierResult mutateAdGroupBidModifierResult :
        response.getResultsList()) {
      System.out.printf("  %s%n", mutateAdGroupBidModifierResult.getResourceName());
    }
  }
}
      
```

### C#

```c#
public void Run(GoogleAdsClient client, long customerId, long adGroupId)
{
    // Get the AdGroupBidModifierService.
    AdGroupBidModifierServiceClient service = client.GetService(
        Services.V26.AdGroupBidModifierService);

    // Constructs the ad group resource name to use for each bid modifier.
    string adGroupResourceName = ResourceNames.AdGroup(customerId, adGroupId);

    // 1) Create an ad group bid modifier based on the hotel check-in day.
    AdGroupBidModifier checkInDayAdGroupBidModifier = new AdGroupBidModifier()
    {
        // Sets the resource name to the ad group resource name joined with the criterion
        // ID whose value corresponds to the desired check-in day.
        AdGroup = adGroupResourceName,
        StartDayOfWeek = new StartDayOfWeekInfo()
        {
            DayOfWeek = DayOfWeek.Monday
        },

        // Set the bid modifier value to 150%.
        BidModifier = 1.5,
    };

    // Creates an ad group bid modifier operation.
    var checkInDayAdGroupBidModifierOperation = new AdGroupBidModifierOperation()
    {
        Create = checkInDayAdGroupBidModifier
    };

    // 2) Create an ad group bid modifier based on the hotel length of stay.
    AdGroupBidModifier lengthOfStayAdGroupBidModifier = new AdGroupBidModifier()
    {
        // Set the ad group.
        AdGroup = ResourceNames.AdGroup(customerId, adGroupId),

        // Set the length of booking info.
        LengthOfBooking = new LengthOfBookingInfo()
        {
            MinDays = 3,
            MaxDays = 7
        },

        // Set the bid modifier value to 170%.
        BidModifier = 1.7
    };

    // Create an ad group bid modifier operation.
    var lengthOfStayAdGroupBidModifierOperation = new AdGroupBidModifierOperation()
    {
        Create = lengthOfStayAdGroupBidModifier
    };

    try
    {
        // Issue a mutate request to add an ad group bid modifiers.
        MutateAdGroupBidModifiersResponse response = service.MutateAdGroupBidModifiers(
            customerId.ToString(),
            new AdGroupBidModifierOperation[] {
      checkInDayAdGroupBidModifierOperation,
      lengthOfStayAdGroupBidModifierOperation
            }
        );

        // Display the resource names of the added ad group bid modifiers.
        Console.WriteLine($"Added {response.Results.Count} hotel ad group bid modifiers:");

        foreach (MutateAdGroupBidModifierResult result in response.Results)
        {
            Console.WriteLine($"- {result.ResourceName}");
        }
    }
    catch (GoogleAdsException e)
    {
        Console.WriteLine("Failure:");
        Console.WriteLine($"Message: {e.Message}");
        Console.WriteLine($"Failure: {e.Failure}");
        Console.WriteLine($"Request ID: {e.RequestId}");
        throw;
    }
}
      
```

### PHP

```php
    public static function runExample(
        GoogleAdsClient $googleAdsClient,
        int $customerId,
        int $adGroupId
    ) {
        $operations = [];

        // 1) Creates an ad group bid modifier based on the hotel check-in day.
        $checkInDayAdGroupBidModifier = new AdGroupBidModifier(
            [
            // Sets the ad group.
            'ad_group' => ResourceNames::forAdGroup($customerId, $adGroupId),
            'hotel_check_in_day' => new HotelCheckInDayInfo(
                [
                'day_of_week' => DayOfWeek::MONDAY
                ]
            ),
            // Sets the bid modifier value to 150%.
            'bid_modifier' => 1.5
            ]
        );

        // Creates an ad group bid modifier operation.
        $checkInDayAdGroupBidModifierOperation = new AdGroupBidModifierOperation();
        $checkInDayAdGroupBidModifierOperation->setCreate($checkInDayAdGroupBidModifier);
        $operations[] = $checkInDayAdGroupBidModifierOperation;

        // 2) Creates an ad group bid modifier based on the hotel length of stay.
        $lengthOfStayAdGroupBidModifier = new AdGroupBidModifier(
            [
            // Sets the ad group.
            'ad_group' => ResourceNames::forAdGroup($customerId, $adGroupId),
            // Creates the hotel length of stay info.
            'hotel_length_of_stay' => new HotelLengthOfStayInfo(
                [
                'min_nights' => 3,
                'max_nights' => 7,
                ]
            ),
            // Sets the bid modifier value to 170%.
            'bid_modifier' => 1.7
            ]
        );

        // Creates an ad group bid modifier operation.
        $lengthOfStayAdGroupBidModifierOperation = new AdGroupBidModifierOperation();
        $lengthOfStayAdGroupBidModifierOperation->setCreate(
            $lengthOfStayAdGroupBidModifier
        );
        $operations[] = $lengthOfStayAdGroupBidModifierOperation;

        // Issues a mutate request to add an ad group bid modifiers.
        $adGroupBidModifierServiceClient = $googleAdsClient->getAdGroupBidModifierServiceClient();
        $response = $adGroupBidModifierServiceClient->mutateAdGroupBidModifiers(
            MutateAdGroupBidModifiersRequest::build($customerId, $operations)
        );

        // Print out resource names of the added ad group bid modifiers.
        printf(
            "Added %d hotel ad group bid modifiers:%s",
            $response->getResults()->count(),
            PHP_EOL
        );
        foreach ($response->getResults() as $addedAdGroupBidModifier) {
            /**
 * @var AdGroupBidModifier $addedAdGroupBidModifier
*/
            print $addedAdGroupBidModifier->getResourceName() . PHP_EOL;
        }
    }
      
```

### Python

```python
def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None:
    ad_group_service: AdGroupServiceClient = client.get_service(
        "AdGroupService"
    )
    ag_bm_service: AdGroupBidModifierServiceClient = client.get_service(
        "AdGroupBidModifierService"
    )

    # Create ad group bid modifier based on hotel check-in day.
    check_in_ag_bm_operation: AdGroupBidModifierOperation = client.get_type(
        "AdGroupBidModifierOperation"
    )
    check_in_ag_bid_modifier: AdGroupBidModifier = (
        check_in_ag_bm_operation.create
    )
    check_in_ag_bid_modifier.hotel_check_in_day.day_of_week = (
        client.enums.DayOfWeekEnum.MONDAY
    )
    check_in_ag_bid_modifier.ad_group = ad_group_service.ad_group_path(
        customer_id, ad_group_id
    )
    # Sets the bid modifier value to 150%.
    check_in_ag_bid_modifier.bid_modifier = 1.5

    # Create ad group bid modifier based on hotel length of stay info.
    los_ag_bm_operation: AdGroupBidModifierOperation = client.get_type(
        "AdGroupBidModifierOperation"
    )
    los_ag_bid_modifier: AdGroupBidModifier = los_ag_bm_operation.create
    los_ag_bid_modifier.ad_group = ad_group_service.ad_group_path(
        customer_id, ad_group_id
    )
    # Creates the hotel length of stay info.
    hotel_length_of_stay_info: HotelLengthOfStayInfo = (
        los_ag_bid_modifier.hotel_length_of_stay
    )
    hotel_length_of_stay_info.min_nights = 3
    hotel_length_of_stay_info.max_nights = 7
    # Sets the bid modifier value to 170%.
    los_ag_bid_modifier.bid_modifier = 1.7

    # Add the bid modifiers
    ag_bm_response: MutateAdGroupBidModifiersResponse = (
        ag_bm_service.mutate_ad_group_bid_modifiers(
            customer_id=customer_id,
            operations=[check_in_ag_bm_operation, los_ag_bm_operation],
        )
    )

    # Print out resource names of the added ad group bid modifiers.
    print(f"Added {len(ag_bm_response.results)} hotel ad group bid modifiers:")

    result: MutateAdGroupBidModifierResult
    for result in ag_bm_response.results:
        print(result.resource_name)
      
```

### Ruby

```ruby
def add_hotel_ad_group_bid_modifiers(customer_id, ad_group_id)
  # GoogleAdsClient will read a config file from
  # ENV['HOME']/google_ads_config.rb when called without parameters
  client = Google::Ads::GoogleAds::GoogleAdsClient.new
  operations = []
  ad_group_resource = client.path.ad_group(customer_id, ad_group_id)

  # 1) Creates an ad group bid modifier based on the check-in day.
  operations << client.operation.create_resource.ad_group_bid_modifier do |bm|
    # Sets the ad group.
    bm.ad_group = ad_group_resource

    # Sets the check-in day to Monday.
    bm.start_day_of_week = client.resource.start_day_of_week_info do |info|
      info.day_of_week = :MONDAY
    end

    # Sets the bid modifier value to 150%.
    bm.bid_modifier = 1.5
  end

  # 2) Creates an ad group bid modifier based on the length of booking.
  operations << client.operation.create_resource.ad_group_bid_modifier do |bm|
    # Sets the ad group.
    bm.ad_group = ad_group_resource

    # Creates the length of booking info.
    bm.length_of_booking = client.resource.length_of_booking_info do |info|
      info.min_days = 3
      info.max_days = 7
    end

    # Sets the bid modifier value to 170%.
    bm.bid_modifier = 1.7
  end

  # 3) Issues a mutate request to add an ad group bid modifiers.
  ad_group_bid_modifier_service = client.service.ad_group_bid_modifier
  response = ad_group_bid_modifier_service.mutate_ad_group_bid_modifiers(
    customer_id: customer_id,
    operations: operations,
  )

  # Print out resource names of the added ad group bid modifiers.
  puts "Added #{response.results.size} hotel ad group bid modifiers:"
  response.results.each do |added_ad_group_bid_modifier|
    puts "\t#{added_ad_group_bid_modifier.resource_name}"
  end
end
      
```

### Perl

```perl
sub add_hotel_ad_group_bid_modifiers {
  my ($api_client, $customer_id, $ad_group_id) = @_;

  # 1) Create an ad group bid modifier based on the hotel check-in day.
  my $check_in_day_ad_group_bid_modifier =
    Google::Ads::GoogleAds::V26::Resources::AdGroupBidModifier->new({
      # Set the ad group.
      adGroup => Google::Ads::GoogleAds::V26::Utils::ResourceNames::ad_group(
        $customer_id, $ad_group_id
      ),
      hotelCheckInDay =>
        Google::Ads::GoogleAds::V26::Common::HotelCheckInDayInfo->new({
          dayOfWeek => MONDAY
        }
        ),
      # Set the bid modifier value to 150%.
      bidModifier => 1.5
    });

  # Create an ad group bid modifier operation.
  my $check_in_day_ad_group_bid_modifier_operation =
    Google::Ads::GoogleAds::V26::Services::AdGroupBidModifierService::AdGroupBidModifierOperation
    ->new({
      create => $check_in_day_ad_group_bid_modifier
    });

  # 2) Create an ad group bid modifier based on the hotel length of stay.
  my $length_of_stay_ad_group_bid_modifier =
    Google::Ads::GoogleAds::V26::Resources::AdGroupBidModifier->new({
      # Set the ad group.
      adGroup => Google::Ads::GoogleAds::V26::Utils::ResourceNames::ad_group(
        $customer_id, $ad_group_id
      ),
      # Create the hotel length of stay info.
      hotelLengthOfStay =>
        Google::Ads::GoogleAds::V26::Common::HotelLengthOfStayInfo->new({
          minNights => 3,
          maxNights => 7
        }
        ),
      # Set the bid modifier value to 170%.
      bidModifier => 1.7
    });

  # Create an ad group bid modifier operation.
  my $length_of_stay_ad_group_bid_modifier_operation =
    Google::Ads::GoogleAds::V26::Services::AdGroupBidModifierService::AdGroupBidModifierOperation
    ->new({
      create => $length_of_stay_ad_group_bid_modifier
    });

  # 3) Add the ad group bid modifiers.
  my $ad_group_bid_modifiers_response =
    $api_client->AdGroupBidModifierService()->mutate({
      customerId => $customer_id,
      operations => [
        $check_in_day_ad_group_bid_modifier_operation,
        $length_of_stay_ad_group_bid_modifier_operation
      ]});

  # Print out resource names of the added ad group bid modifiers.
  my $ad_group_bid_modifier_results =
    $ad_group_bid_modifiers_response->{results};
  printf "Added %d hotel ad group bid modifiers:\n",
    scalar @$ad_group_bid_modifier_results;

  foreach my $ad_group_bid_modifier_result (@$ad_group_bid_modifier_results) {
    printf "\t%s\n", $ad_group_bid_modifier_result->{resourceName};
  }

  return 1;
}
      
```

### curl

> [!NOTE]
> **Note:** While a direct REST code sample for this step isn't provided here, you can achieve this using a manual REST request.   
>
> Refer to the Google Ads API REST interface documentation and the method-specific reference pages. You will need to construct the JSON payload based on the proto definitions.   
>
> Key Resources:
>
> - [Using REST](https://developers.google.com/google-ads/api/rest/overview.md.txt)
> - [REST Interface Structure](https://developers.google.com/google-ads/api/rest/design/overview.md.txt)
> - [JSON Field Mappings](https://developers.google.com/google-ads/api/rest/design/json-mappings.md.txt)
> - Consult the [REST API Reference](https://developers.google.com/google-ads/api/reference/rpc/latest/overview) for the specific service and method.

<br />

## Examples

The following examples show how to query, create, update, and remove ad group
bid modifiers using GAQL and REST JSON payloads.

### Reading bid modifiers with GAQL

The following queries illustrate retrieving length of booking bid modifiers in
v25 and earlier compared to v26 and later:

**v25 and earlier:**

```sql
SELECT
  ad_group_bid_modifier.resource_name,
  ad_group_bid_modifier.bid_modifier,
  ad_group_bid_modifier.hotel_length_of_stay.min_nights,
  ad_group_bid_modifier.hotel_length_of_stay.max_nights
FROM ad_group_bid_modifier
WHERE ad_group_bid_modifier.hotel_length_of_stay.min_nights = 5
```

**v26 and later:**

```sql
SELECT
  ad_group_bid_modifier.resource_name,
  ad_group_bid_modifier.bid_modifier,
  ad_group_bid_modifier.length_of_booking.min_days,
  ad_group_bid_modifier.length_of_booking.max_days
FROM ad_group_bid_modifier
WHERE ad_group_bid_modifier.length_of_booking.min_days = 5
```

### Creating bid modifiers (JSON payload)

The following JSON payloads demonstrate creating ad group bid modifiers in v26
and later.

**Creating a length of booking bid modifier in v26:**

```json
{
  "customerId": "1234567890",
  "operations": [
    {
      "create": {
        "adGroup": "customers/1234567890/adGroups/987654321",
        "bidModifier": 1.2,
        "lengthOfBooking": {
          "minDays": "3",
          "maxDays": "5"
        }
      }
    }
  ]
}
```

In v25 and earlier, this used `hotelLengthOfStay` with `minNights` and
`maxNights`.

**Creating a start date range bid modifier in v26:**

```json
{
  "customerId": "1234567890",
  "operations": [
    {
      "create": {
        "adGroup": "customers/1234567890/adGroups/987654321",
        "bidModifier": 1.5,
        "startDateRange": {
          "startDate": "2026-12-20",
          "endDate": "2026-12-31"
        }
      }
    }
  ]
}
```

**Creating a user set dates bid modifier in v26:**

```json
{
  "customerId": "1234567890",
  "operations": [
    {
      "create": {
        "adGroup": "customers/1234567890/adGroups/987654321",
        "bidModifier": 1.3,
        "userSetDates": {
          "type": "USER_SELECTED"
        }
      }
    }
  ]
}
```

### Updating and removing bid modifiers

You can update the multiplier on an existing bid modifier or remove the bid
modifier entirely:

- **Updating:** Criterion fields are `IMMUTABLE`. To modify the bid multiplier, send an `update` operation with `updateMask` (`update_mask` in protobuf) set to `"bidModifier"` (`"bid_modifier"`) and set `bidModifier` (`bid_modifier`) to a valid value (`0.1` to `10.0` or `0` to opt out for `advance_booking_window`, `length_of_booking`, `start_day_of_week`, `start_date_range`, and `device`; `0.5` to `2.0` for `user_set_dates`). To change the targeting criteria, remove the bid modifier and create a new one.
- **Removing:** Send a `remove` operation with the resource name:

```json
{
  "customerId": "1234567890",
  "operations": [
    {
      "remove": "customers/1234567890/adGroupBidModifiers/987654321~555444333"
    }
  ]
}
```

## Validation rules and error handling

Validation rules stay the same across versions, but six `CriterionError` enum
values are renamed in v26 as shown in the following table:

| Scenario | v25 and earlier | v26 and later |
|---|---|---|
| Length of booking range overlaps existing criterion | `HOTEL_LENGTH_OF_STAY_OVERLAPS_WITH_EXISTING_CRITERION` | `LENGTH_OF_BOOKING_OVERLAPS_WITH_EXISTING_CRITERION` |
| Advance booking window range overlaps existing criterion | `HOTEL_ADVANCE_BOOKING_WINDOW_OVERLAPS_WITH_EXISTING_CRITERION` | `ADVANCE_BOOKING_WINDOW_OVERLAPS_WITH_EXISTING_CRITERION` |
| Start date range overlaps existing criterion | `HOTEL_CHECK_IN_DATE_RANGE_OVERLAPS_WITH_EXISTING_CRITERION` | `START_DATE_RANGE_OVERLAPS_WITH_EXISTING_CRITERION` |
| `start_date` earlier than yesterday (UTC) | `HOTEL_CHECK_IN_DATE_RANGE_START_DATE_TOO_EARLY` | `START_DATE_RANGE_START_DATE_TOO_EARLY` |
| `end_date` more than 330 days in future (UTC) | `HOTEL_CHECK_IN_DATE_RANGE_END_DATE_TOO_LATE` | `START_DATE_RANGE_END_DATE_TOO_LATE` |
| `start_date` after `end_date` | `HOTEL_CHECK_IN_DATE_RANGE_REVERSED` | `START_DATE_RANGE_REVERSED` |

The following validation errors apply across all API versions:

- **`FieldError.REQUIRED`:** Missing a required range bound (such as `advance_booking_window` without `min_days` or `max_days`).
- **`RangeError.TOO_HIGH` / `RangeError.TOO_LOW`:** Value out of bounds, such as `advance_booking_window.max_days` greater than 330, `min_days` greater than `max_days` on `advance_booking_window` or `length_of_booking`, `bid_modifier` outside `0.1`--`10.0` for `advance_booking_window`, `length_of_booking`, `start_day_of_week`, or `start_date_range`, or `bid_modifier` outside `0.5`--`2.0` (including `0`) for `user_set_dates`.
- **`ResourceCountLimitExceededError.RESOURCE_LIMIT`:** Ad group exceeds the per-ad-group limit for bid modifiers.
- **`MutateError.INCONSISTENT_FIELD_VALUES`:** A fixed-ID enum subfield (such as `user_set_dates.type`, `start_day_of_week.day_of_week`, or `device.type`) does not match the criterion ID specified in `resource_name`.
- **`ContextError.OPERATION_NOT_PERMITTED_FOR_CONTEXT`:** Attempting to add a travel bid modifier on an unsupported campaign type or ineligible Search campaign.