Before creating an ad, ensure that you have already created a
[Things to do campaign](https://developers.google.com/google-ads/api/docs/things-to-do-ads/create-campaign.md.txt) and a
[Things to do ad group](https://developers.google.com/google-ads/api/docs/things-to-do-ads/create-ad-group.md.txt).

Creating a Things to do ad involves two steps:

1. Create an [`Ad`](https://developers.google.com/google-ads/api/reference/rpc/v26/Ad.md.txt) and set its [`travel_ad`](https://developers.google.com/google-ads/api/reference/rpc/v26/Ad.md.txt#travel_ad) field to an instance of [`TravelAdInfo`](https://developers.google.com/google-ads/api/reference/rpc/v26/TravelAdInfo.md.txt).
2. Create an [`AdGroupAd`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupAd.md.txt), set its `ad_group` field to your ad group's resource name, and associate the `Ad` with it.

> [!IMPORTANT]
> **Key Point:** To serve ads for your ad group, you need at least one [`AdGroupAd`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupAd.md.txt) with its [`ad`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupAd.md.txt#ad) field set and its [`status`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupAd.md.txt#status) set to [`ENABLED`](https://developers.google.com/google-ads/api/reference/rpc/v26/AdGroupAdStatusEnum.AdGroupAdStatus.md.txt#enabled). Setting the ad status to `PAUSED` causes an error for Things to do campaigns (pause at the ad group or campaign level instead). While you can create multiple ads in an ad group, ad serving is arbitrary and distributes impressions across all active ads in that ad group. Because Things to do ads render dynamically from your Things to do Center feed data, we recommend creating only **one ad per ad group** to simplify performance tracking.

## Code example

The following code example demonstrates how to create a `TravelAdInfo` instance
and associate it with an `AdGroupAd`:


### Java

```java
private String addAddGroupAd(
    GoogleAdsClient googleAdsClient, long customerId, String adGroupResourceName) {
  // Creates a new travel ad.
  Ad ad = Ad.newBuilder().setTravelAd(TravelAdInfo.newBuilder()).build();
  // Creates a new ad group ad and sets its ad to the travel ad.
  AdGroupAd adGroupAd =
      AdGroupAd.newBuilder()
          // Sets the ad to the ad created above.
          .setAd(ad)
          // Set the ad group ad to enabled. Setting this to paused will cause an error for
          // Things to do campaigns. Pausing should happen at either the ad group or campaign
          // level.
          .setStatus(AdGroupAdStatus.ENABLED)
          // Sets the ad group.
          .setAdGroup(adGroupResourceName)
          .build();

  // Creates an ad group ad operation.
  AdGroupAdOperation operation = AdGroupAdOperation.newBuilder().setCreate(adGroupAd).build();

  // Issues a mutate request to add an ad group ad.
  try (AdGroupAdServiceClient adGroupAdServiceClient =
      googleAdsClient.getLatestVersion().createAdGroupAdServiceClient()) {
    MutateAdGroupAdResult mutateAdGroupAdResult =
        adGroupAdServiceClient
            .mutateAdGroupAds(Long.toString(customerId), Collections.singletonList(operation))
            .getResults(0);
    System.out.printf(
        "Added an ad group ad with resource name: '%s'%n",
        mutateAdGroupAdResult.getResourceName());
    return mutateAdGroupAdResult.getResourceName();
  }
}
      
```

### C#

```c#
private static void CreateAdGroupAd(GoogleAdsClient client, long customerId,
    string adGroup)
{

    // Get the AdGroupAdService.
    AdGroupAdServiceClient adGroupAdService =
        client.GetService(Services.V26.AdGroupAdService);

    // Creates a new ad group ad and sets a travel ad info.
    AdGroupAd adGroupAd = new AdGroupAd()
    {
        Ad = new Ad()
        {
            TravelAd = new TravelAdInfo()
        },
        // Set the ad group ad to enabled. Setting this to paused will cause an error for
        // Things to do campaigns. Pausing should happen at either the ad group or campaign
        // level.
        Status = AdGroupAdStatus.Enabled,
        AdGroup = adGroup
    };

    MutateAdGroupAdsResponse response = adGroupAdService.MutateAdGroupAds(
        customerId.ToString(), new AdGroupAdOperation[] { new AdGroupAdOperation() {
            Create = adGroupAd
        }}
    );

    string adGroupAdResourceName = response.Results[0].ResourceName;
    Console.WriteLine("Ad group ad with resource name = '{0}' was added.",
        adGroupAdResourceName);
}
      
```

### PHP

```php
    private static function addAdGroupAd(
        GoogleAdsClient $googleAdsClient,
        int $customerId,
        string $adGroupResourceName
    ) {
        // Creates a new ad group ad and sets a travel ad info.
        $adGroupAd = new AdGroupAd(
            [
            'ad' => new Ad(['travel_ad' => new TravelAdInfo()]),
            // Set the ad group ad to enabled. Setting this to paused will cause an error for Things
            // to do campaigns. Pausing should happen at either the ad group or campaign level.
            'status' => AdGroupAdStatus::ENABLED,
            // Sets the ad group.
            'ad_group' => $adGroupResourceName
            ]
        );

        // Creates an ad group ad operation.
        $adGroupAdOperation = new AdGroupAdOperation();
        $adGroupAdOperation->setCreate($adGroupAd);

        // Issues a mutate request to add an ad group ad.
        $adGroupAdServiceClient = $googleAdsClient->getAdGroupAdServiceClient();
        $response = $adGroupAdServiceClient->mutateAdGroupAds(
            MutateAdGroupAdsRequest::build($customerId, [$adGroupAdOperation])
        );

        /**
 * @var AdGroupAd $addedAdGroupAd
*/
        $addedAdGroupAd = $response->getResults()[0];
        printf(
            "Added an ad group ad with resource name '%s'.%s",
            $addedAdGroupAd->getResourceName(),
            PHP_EOL
        );
    }
      
```

### Python

```python
def add_ad_group_ad(
    client: GoogleAdsClient, customer_id: str, ad_group_resource_name: str
) -> None:
    """Creates a new ad group ad in the specified ad group.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        ad_group_resource_name: the resource name of ad group that a new ad
            group ad will belong to.
    """
    # Creates an ad group ad operation.
    operation: AdGroupAdOperation = client.get_type("AdGroupAdOperation")
    # Creates a new ad group ad and sets a travel ad info.
    ad_group_ad: AdGroupAd = operation.create
    # Sets the ad group ad to enabled. Setting this to paused will cause an error
    # for Things to do campaigns. Pausing should happen at either the ad group
    # or campaign level.
    ad_group_ad.status = client.enums.AdGroupAdStatusEnum.ENABLED
    ad_group_ad.ad.travel_ad = client.get_type("TravelAdInfo")
    # Sets the ad group.
    ad_group_ad.ad_group = ad_group_resource_name

    # Issues a mutate request to add an ad group ad.
    ad_group_ad_service: AdGroupAdServiceClient = client.get_service(
        "AdGroupAdService"
    )
    response: MutateAdGroupAdsResponse = (
        ad_group_ad_service.mutate_ad_group_ads(
            customer_id=customer_id, operations=[operation]
        )
    )

    resource_name: str = response.results[0].resource_name
    print(f"Added an ad group ad with resource name: '{resource_name}'.")
      
```

### Ruby

```ruby
def add_ad_group_ad(client, customer_id, ad_group_resource)
  # Creates a new ad group ad and sets a travel ad info.
  ad_group_ad_operation = client.operation.create_resource.ad_group_ad do |aga|
    aga.ad = client.resource.ad do |ad|
      ad.travel_ad = client.resource.travel_ad_info
    end
    # Set the ad group ad to enabled. Setting this to paused will cause an error
    # for Things to Do campaigns. Pausing should happen at either the ad group
    # or campaign level.
    aga.status = :ENABLED

    # Set the ad group.
    aga.ad_group = ad_group_resource
  end

  # Issue a mutate request to add the ad group ad.
  ad_group_ad_service = client.service.ad_group_ad
  response = ad_group_ad_service.mutate_ad_group_ads(
    customer_id: customer_id,
    operations: [ad_group_ad_operation],
  )

  # Fetch the new ad group ad's resource name.
  ad_group_ad_resource = response.results.first.resource_name

  puts "Added an ad group ad with resource name '#{ad_group_ad_resource}'."
end
      
```

### Perl

```perl
sub add_ad_group_ad {
  my ($api_client, $customer_id, $ad_group_resource_name) = @_;

  # Create an ad group ad and set a travel ad info.
  my $ad_group_ad = Google::Ads::GoogleAds::V26::Resources::AdGroupAd->new({
      # Set the ad group.
      adGroup => $ad_group_resource_name,
      ad      => Google::Ads::GoogleAds::V26::Resources::Ad->new({
          travelAd => Google::Ads::GoogleAds::V26::Common::TravelAdInfo->new()}
      ),
      # Set the ad group to enabled. Setting this to paused will cause an error
      # for Things to do campaigns. Pausing should happen at either the ad group
      # or campaign level.
      status => Google::Ads::GoogleAds::V26::Enums::AdGroupAdStatusEnum::ENABLED
    });

  # Create an ad group ad operation.
  my $ad_group_ad_operation =
    Google::Ads::GoogleAds::V26::Services::AdGroupAdService::AdGroupAdOperation
    ->new({create => $ad_group_ad});

  # Add the ad group ad.
  my $ad_group_ad_resource_name = $api_client->AdGroupAdService()->mutate({
      customerId => $customer_id,
      operations => [$ad_group_ad_operation]})->{results}[0]{resourceName};

  printf "Added an ad group ad with resource name: '%s'.\n",
    $ad_group_ad_resource_name;

  return $ad_group_ad_resource_name;
}
      
```

### 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 />

## What's next

- Partition your inventory with [Things to do listing groups](https://developers.google.com/google-ads/api/docs/things-to-do-ads/create-listing-groups.md.txt).
- Query performance metrics in [Things to do reporting](https://developers.google.com/google-ads/api/docs/things-to-do-ads/reporting.md.txt).