> ## Documentation Index
> Fetch the complete documentation index at: https://developers.leadwaycrm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upsert Google campaign

> Create or update a full Google Ads campaign structure

Create or update a full Google Ads campaign structure

```http theme={null}
PUT https://services.leadconnectorhq.com/ad-publishing/google/ads
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Body

<ParamField body="id" type="string">
  Campaign identifier
</ParamField>

<ParamField body="name" type="string" required default="My Campaign">
  Campaign name
</ParamField>

<ParamField body="locationId" type="string" required default="loc_abc123">
  Account identifier
</ParamField>

<ParamField body="advertisingChannelType" type="string" required>
  Advertising channel Posibles valores: 'SEARCH', 'DISCOVERY', 'DISPLAY', 'HOTEL', 'LOCAL', 'MULTI\_CHANNEL', 'PERFORMANCE\_MAX', 'DEMAND\_GEN'
</ParamField>

<ParamField body="advertisingChannelSubType" type="string">
  Channel sub type Posibles valores: 'DEMAND\_GEN'
</ParamField>

<ParamField body="goalType" type="string">
  Goal type Posibles valores: 'WEBSITE\_TRAFFIC', 'LEAD'
</ParamField>

<ParamField body="budget" type="object">
  Campaign budget
</ParamField>

<ParamField body="audience" type="object">
  Campaign audience targeting
</ParamField>

<ParamField body="networkSettings" type="object">
  Network settings
</ParamField>

<ParamField body="biddingStrategy" type="object">
  Bidding strategy config
</ParamField>

<ParamField body="assets" type="object">
  Campaign assets
</ParamField>

<ParamField body="isEuPoliticalAds" type="boolean" default="False">
  EU political ads flag
</ParamField>

<ParamField body="adGroups" type="object[]">
  Campaign ad groups

  <Expandable title="cada item">
    <ParamField body="id" type="string">
      Ad group identifier
    </ParamField>

    <ParamField body="adGroupId" type="string">
      Google ad group identifier
    </ParamField>

    <ParamField body="name" type="string" default="Ad Group 1">
      Ad group name
    </ParamField>

    <ParamField body="adCampaignId" type="string">
      Ad campaign identifier
    </ParamField>

    <ParamField body="adContent" type="object[]">
      Ad content items

      <Expandable title="cada item">
        <ParamField body="id" type="string">
          Ad identifier
        </ParamField>

        <ParamField body="name" type="string">
          Ad name
        </ParamField>

        <ParamField body="mediaType" type="string">
          Media type Posibles valores: 'IMAGE', 'VIDEO', 'CAROUSEL'
        </ParamField>

        <ParamField body="headlines" type="string[]">
          Ad headlines
        </ParamField>

        <ParamField body="longHeadlines" type="string[]">
          Long headlines
        </ParamField>

        <ParamField body="descriptions" type="string[]">
          Ad descriptions
        </ParamField>

        <ParamField body="finalUrl" type="string" default="https://example.com">
          Final URL
        </ParamField>

        <ParamField body="path1" type="string" default="products">
          Display path 1
        </ParamField>

        <ParamField body="path2" type="string" default="deals">
          Display path 2
        </ParamField>

        <ParamField body="isDeleted" type="boolean">
          Whether the ad is soft-deleted
        </ParamField>

        <ParamField body="adError" type="string">
          Ad-level error message from Google
        </ParamField>

        <ParamField body="publishingStatus" type="string">
          Ad publishing status Posibles valores: 'DRAFT', 'SCHEDULED', 'PUBLISHED', 'PUBLISHING', 'FAILED', 'IN\_REVIEW', 'PAUSED', 'ARCHIVED', 'WITH\_ISSUES', 'REJECTED'
        </ParamField>

        <ParamField body="adId" type="string">
          Internal ad identifier
        </ParamField>

        <ParamField body="adCampaignId" type="string">
          Ad campaign identifier
        </ParamField>

        <ParamField body="adGroupId" type="string">
          Ad group identifier
        </ParamField>

        <ParamField body="googleAdId" type="string">
          Google Ads ad resource ID
        </ParamField>

        <ParamField body="media" type="object[]">
          Ad media items

          <Expandable title="cada item">
            <ParamField body="type" type="string">
              Media type Posibles valores: 'IMAGE'
            </ParamField>

            <ParamField body="src" type="string" default="https://example.com/image.jpg">
              Media source URL
            </ParamField>

            <ParamField body="isLogo" type="boolean" default="False">
              Is logo flag
            </ParamField>

            <ParamField body="error" type="string">
              Error message if media failed
            </ParamField>

            <ParamField body="url" type="string">
              Public URL of the media
            </ParamField>

            <ParamField body="imageType" type="string">
              Image type classification
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="callToActionLabel" type="string">
          Call to action label Posibles valores: 'AUTOMATED', 'LEARN\_MORE', 'GET\_QUOTE', 'APPLY\_NOW', 'SIGN\_UP', 'CONTACT\_US', 'SUBSCRIBE', 'DOWNLOAD', 'BOOK\_NOW', 'SHOP\_NOW', 'BUY\_NOW', 'DONATE\_NOW', 'ORDER\_NOW', 'PLAY\_NOW', 'SEE\_MORE'
        </ParamField>

        <ParamField body="businessName" type="string" default="Acme Corp">
          Business name
        </ParamField>

        <ParamField body="youtubeVideoLinks" type="object[]">
          YouTube video links

          <Expandable title="cada item">
            <ParamField body="youtubeVideoId" type="string" required>
              YouTube video ID
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="carouselCards" type="object[]">
          Carousel cards

          <Expandable title="cada item">
            <ParamField body="headline" type="string" default="Shop Now">
              Card headline
            </ParamField>

            <ParamField body="finalUrl" type="string" default="https://example.com">
              Card final URL
            </ParamField>

            <ParamField body="callToActionLabel" type="string">
              Call to action label
            </ParamField>

            <ParamField body="media" type="object[]">
              Card media items

              <Expandable title="cada item">
                <ParamField body="type" type="string">
                  Media type Posibles valores: 'IMAGE'
                </ParamField>

                <ParamField body="src" type="string" default="https://example.com/image.jpg">
                  Media source URL
                </ParamField>

                <ParamField body="isLogo" type="boolean" default="False">
                  Is logo flag
                </ParamField>

                <ParamField body="error" type="string">
                  Error message if media failed
                </ParamField>

                <ParamField body="url" type="string">
                  Public URL of the media
                </ParamField>

                <ParamField body="imageType" type="string">
                  Image type classification
                </ParamField>
              </Expandable>
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="placements" type="string[]">
          Channel placements
        </ParamField>

        <ParamField body="customChannels" type="boolean">
          Custom channels flag
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="keywords" type="object">
      Keyword targeting
    </ParamField>

    <ParamField body="publishingStatus" type="string">
      Ad group publishing status Posibles valores: 'DRAFT', 'SCHEDULED', 'PUBLISHED', 'PUBLISHING', 'FAILED', 'IN\_REVIEW', 'PAUSED', 'ARCHIVED', 'WITH\_ISSUES', 'REJECTED'
    </ParamField>

    <ParamField body="adGroupError" type="string">
      Ad group-level error from Google
    </ParamField>

    <ParamField body="googleAdGroupId" type="string">
      Google Ads ad group resource ID
    </ParamField>

    <ParamField body="customChannels" type="boolean">
      Custom channels flag
    </ParamField>

    <ParamField body="selectedChannels" type="string[]">
      Selected channel placements
    </ParamField>

    <ParamField body="googleAudienceId" type="string">
      Google audience resource ID
    </ParamField>

    <ParamField body="audience" type="object">
      Ad group audience targeting
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="campaignGoal" type="object">
  Campaign goal config
</ParamField>

<ParamField body="adSchedule" type="object[]">
  Ad schedule rules

  <Expandable title="cada item">
    <ParamField body="dayOfWeek" type="string" required>
      Day of week Posibles valores: 'FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'UNKNOWN', 'UNSPECIFIED', 'WEDNESDAY', 'ALL\_DAYS', 'MONDAY\_TO\_FRIDAY', 'SATURDAY\_AND\_SUNDAY'
    </ParamField>

    <ParamField body="from" type="string" required default="09:00">
      Start time (HH:MM)
    </ParamField>

    <ParamField body="to" type="string" required default="17:00">
      End time (HH:MM)
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="publishingStatus" type="string">
  Publishing status Posibles valores: 'DRAFT', 'SCHEDULED', 'PUBLISHED', 'PUBLISHING', 'FAILED', 'IN\_REVIEW', 'PAUSED', 'ARCHIVED', 'WITH\_ISSUES', 'REJECTED'
</ParamField>

<ParamField body="googleAdAccountId" type="string">
  Google Ad account identifier
</ParamField>

<ParamField body="unpublishedChanges" type="boolean">
  Whether the campaign has unpublished changes
</ParamField>

<ParamField body="maximumCpc" type="number">
  Maximum CPC bid in micros
</ParamField>

<ParamField body="googleCampaignId" type="string">
  Google Ads campaign resource ID
</ParamField>

<ParamField body="source" type="string" default="WEBSITE">
  Traffic source
</ParamField>

<ParamField body="advancedOptions" type="object">
  Advanced options
</ParamField>

## Respuestas

<Accordion title="200 - Response" />

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT 'https://services.leadconnectorhq.com/ad-publishing/google/ads' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "id": "string",
    "name": "My Campaign",
    "locationId": "loc_abc123",
    "advertisingChannelType": "SEARCH",
    "advertisingChannelSubType": "DEMAND_GEN",
    "goalType": "WEBSITE_TRAFFIC",
    "isEuPoliticalAds": false,
    "adGroups": [
      {
        "id": "string",
        "adGroupId": "string",
        "name": "Ad Group 1",
        "adCampaignId": "string",
        "adContent": [
          {}
        ],
        "publishingStatus": "DRAFT",
        "adGroupError": "string",
        "googleAdGroupId": "string",
        "customChannels": true,
        "selectedChannels": [
          "GMAIL"
        ],
        "googleAudienceId": "string"
      }
    ],
    "adSchedule": [
      {
        "dayOfWeek": "FRIDAY",
        "from": "09:00",
        "to": "17:00"
      }
    ],
    "publishingStatus": "DRAFT",
    "googleAdAccountId": "string",
    "unpublishedChanges": true,
    "maximumCpc": 0,
    "googleCampaignId": "string",
    "source": "WEBSITE",
    "advancedOptions": {}
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/google/ads', {
    method: 'PUT',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"id": "string", "name": "My Campaign", "locationId": "loc_abc123", "advertisingChannelType": "SEARCH", "advertisingChannelSubType": "DEMAND_GEN", "goalType": "WEBSITE_TRAFFIC", "isEuPoliticalAds": false, "adGroups": [{"id": "string", "adGroupId": "string", "name": "Ad Group 1", "adCampaignId": "string", "adContent": [{}], "publishingStatus": "DRAFT", "adGroupError": "string", "googleAdGroupId": "string", "customChannels": true, "selectedChannels": ["GMAIL"], "googleAudienceId": "string"}], "adSchedule": [{"dayOfWeek": "FRIDAY", "from": "09:00", "to": "17:00"}], "publishingStatus": "DRAFT", "googleAdAccountId": "string", "unpublishedChanges": true, "maximumCpc": 0, "googleCampaignId": "string", "source": "WEBSITE", "advancedOptions": {}}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'PUT',
      'https://services.leadconnectorhq.com/ad-publishing/google/ads',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"id": "string", "name": "My Campaign", "locationId": "loc_abc123", "advertisingChannelType": "SEARCH", "advertisingChannelSubType": "DEMAND_GEN", "goalType": "WEBSITE_TRAFFIC", "isEuPoliticalAds": false, "adGroups": [{"id": "string", "adGroupId": "string", "name": "Ad Group 1", "adCampaignId": "string", "adContent": [{}], "publishingStatus": "DRAFT", "adGroupError": "string", "googleAdGroupId": "string", "customChannels": true, "selectedChannels": ["GMAIL"], "googleAudienceId": "string"}], "adSchedule": [{"dayOfWeek": "FRIDAY", "from": "09:00", "to": "17:00"}], "publishingStatus": "DRAFT", "googleAdAccountId": "string", "unpublishedChanges": true, "maximumCpc": 0, "googleCampaignId": "string", "source": "WEBSITE", "advancedOptions": {}},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/ad-publishing/google/ads');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'PUT',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode({'id': 'string', 'name': 'My Campaign', 'locationId': 'loc_abc123', 'advertisingChannelType': 'SEARCH', 'advertisingChannelSubType': 'DEMAND_GEN', 'goalType': 'WEBSITE_TRAFFIC', 'isEuPoliticalAds': false, 'adGroups': [{'id': 'string', 'adGroupId': 'string', 'name': 'Ad Group 1', 'adCampaignId': 'string', 'adContent': [{}], 'publishingStatus': 'DRAFT', 'adGroupError': 'string', 'googleAdGroupId': 'string', 'customChannels': true, 'selectedChannels': ['GMAIL'], 'googleAudienceId': 'string'}], 'adSchedule': [{'dayOfWeek': 'FRIDAY', 'from': '09:00', 'to': '17:00'}], 'publishingStatus': 'DRAFT', 'googleAdAccountId': 'string', 'unpublishedChanges': true, 'maximumCpc': 0, 'googleCampaignId': 'string', 'source': 'WEBSITE', 'advancedOptions': {}}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
