To generate a new Performance Max campaign from scratch, you must at the minimum
create the following:

- The [campaign](https://developers.google.com/google-ads/api/reference/rpc/v26/Campaign) itself
- A [budget](https://developers.google.com/google-ads/api/reference/rpc/v26/CampaignBudget)
- Account-level [assets](https://developers.google.com/google-ads/api/reference/rpc/v26/Asset)
- An [asset group](https://developers.google.com/google-ads/api/reference/rpc/v26/AssetGroup)
- [Links](https://developers.google.com/google-ads/api/reference/rpc/v26/AssetGroupAsset) between the assets in your account and the asset group you'll be using for this campaign.

The campaign and budget are useful for creating all sorts of campaign types,
while the asset-related operations will be specifically useful for creating
Performance Max campaigns. Visit the [Performance Max assets guide](https://developers.google.com/google-ads/scripts/docs/campaigns/performance-max/assets) to see
how assets can be created using scripts.

Make sure you're familiar with the [mutate strategy](https://developers.google.com/google-ads/scripts/docs/campaigns/performance-max/mutate-strategy), as this guide will only
provide the JavaScript objects to be used in the mutates.

## Budget

The budget must not be shared, and must have a unique name in your account. Use
a [`CampaignBudgetOperation`](https://developers.google.com/google-ads/api/reference/rpc/v26/CampaignBudgetOperation).

    const budgetOperation = {
      "campaignBudgetOperation": {
        "create": {
          "resourceName": `customers/${customerId}/campaignBudgets/${getNextTempId()}`,
          "name": "Performance Max campaign budget",
          "amountMicros": "50000000",
          "deliveryMethod": "STANDARD",
          "explicitlyShared": false
        }
      }
    }
    operations.push(budgetOperation);

## Campaign

The campaign must reference a budget, so you will need the exact budget resource
name you created in the previous step to identify and use that specific budget
object. Use a [`CampaignOperation`](https://developers.google.com/google-ads/api/reference/rpc/v26/CampaignOperation).

    const campaignOperation = {
      "campaignOperation": {
        "create": {
          "resourceName": `customers/${customerId}/campaigns/${getNextTempId()}`,
          "name": "Performance Max campaign",
          "status": "PAUSED",
          "advertisingChannelType": "PERFORMANCE_MAX",
          "campaignBudget": budgetOperation.campaignBudgetOperation.create.resourceName,
          "biddingStrategyType": "MAXIMIZE_CONVERSION_VALUE",
          "startDate": "20240314",
          "endDate": "20250313",
          "urlExpansionOptOut": false,
          "maximizeConversionValue": {
            "targetRoas": 3.5
          },
          "containsEuPoliticalAdvertising": "DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING"
        }
      }
    }
    operations.push(campaignOperation);

## Asset group

The asset group for this campaign requires a reference to the campaign, and will
need to be referenced later when you link assets to it. Use an
[`AssetGroupOperation`](https://developers.google.com/google-ads/api/reference/rpc/v26/AssetGroupOperation).

    const assetGroupOperation = {
      "assetGroupOperation": {
        "create": {
          "resourceName": `customers/${customerId}/assetGroups/${getNextTempId()}`,
          "campaign": campaignOperation.campaignOperation.create.resourceName,
          "name": "Performance Max asset group",
          "finalUrls": [
            "http://www.example.com"
          ],
          "finalMobileUrls": [
            "http://www.example.com"
          ],
          "status": "PAUSED"
        }
      }
    }
    operations.push(assetGroupOperation);

## Asset group links

Now that you have your asset groups and assets (from the previous step), you
need to link them together so that the Performance Max campaign knows which
assets you want to use. You *must* do this in the same request where you create
the asset group initially. To do this, use an [`AssetGroupAssetOperation`](https://developers.google.com/google-ads/api/reference/rpc/v26/AssetGroupAssetOperation).

You will need to provide the correct asset resource name, as well as modifying
the `fieldType` to the appropriate value for the asset you're linking. Check
out the [complete list of valid field types](https://developers.google.com/google-ads/api/reference/rpc/v26/AssetFieldTypeEnum.AssetFieldType).

You will need multiple of these operations to meet the
[minimum requirements](https://developers.google.com/google-ads/api/performance-max/asset-requirements) for a Performance Max campaign.

    operations.push({
      "assetGroupAssetOperation": {
        "create": {
          "assetGroup": assetGroupOperation.assetGroupOperation.create.resourceName,
          // assetResourceName here is a placeholder; you will need to determine
          // the correct resource name to use depending on which asset you want
          // to add to the asset group.
          "asset": assetResourceName,
          "fieldType": "HEADLINE"
        }
      }
    });