# The Trade Desk

> Manage advertisers, campaigns, flights, ad groups and creatives in The Trade Desk, and follow their changes.

App · 20 actions. Web page: https://docs.lodol.com/docs/integrations/the-trade-desk

## Actions

### Add campaign flight

Add a date range with its own budget to a campaign that already has a flight.

**Inputs**

- Campaign (`campaign_id`, text, required): The campaign.
- Start (`start_date`, date and time, required): When the flight starts.
- End (`end_date`, date and time): When the flight ends.
- Budget (`budget`, number, required): The most the flight may spend, in the advertiser's currency. At least 0.
- Daily spend target (`daily_target`, number): The most the flight should spend in a day, in the advertiser's currency. At least 0.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "BudgetInAdvertiserCurrency": 1,
    "CampaignFlightId": 1,
    "CampaignId": "example",
    "DailyTargetInAdvertiserCurrency": 1,
    "EndDateExclusiveUTC": "example",
    "StartDateInclusiveUTC": "example"
  }
}
```

### Archive ad group

Archive an ad group so it stops and is hidden. This can't be undone.

**Inputs**

- Ad group (`ad_group_id`, text, required): The ad group.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdGroupId": "example",
    "AdGroupName": "example",
    "Availability": "example",
    "CampaignId": "example",
    "ChannelId": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "IsEnabled": true,
    "LastUpdatedAtUTC": "example"
  }
}
```

### Archive campaign

Archive a campaign so it stops and is hidden. This can't be undone, and a campaign with an ad group that is turned on can't be archived.

**Inputs**

- Campaign (`campaign_id`, text, required): The campaign.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdvertiserId": "example",
    "Availability": "example",
    "Budget": {
      "Amount": 1,
      "CurrencyCode": "example"
    },
    "CampaignFlights": [
      {
        "BudgetInAdvertiserCurrency": 1,
        "CampaignFlightId": 1,
        "CampaignId": "example",
        "DailyTargetInAdvertiserCurrency": 1,
        "EndDateExclusiveUTC": "example",
        "StartDateInclusiveUTC": "example"
      }
    ],
    "CampaignId": "example",
    "CampaignName": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "EndDate": "example",
    "LastUpdatedAtUTC": "example",
    "PacingMode": "example",
    "PrimaryChannel": "example",
    "PurchaseOrderNumber": "example",
    "StartDate": "example"
  }
}
```

### Create ad group

Create an ad group in a campaign. It is created turned off, so it spends nothing until you turn it on.

**Inputs**

- Campaign (`campaign_id`, text, required): The campaign.
- Name (`name`, text, required): The ad group's name.
- Channel (`channel`, text, required): Where the ads run. Match the campaign's channel. One of: `Display`, `Video`, `Audio`, `TV`, `NativeDisplay` (Native display), `NativeVideo` (Native video), `OutOfHome` (Out-of-home).
- Base bid (CPM) (`base_bid`, number, required): The usual bid per thousand impressions, in the advertiser's currency. At least 0.
- Maximum bid (CPM) (`max_bid`, number, required): The most the ad group will ever bid per thousand impressions, in the advertiser's currency. At least 0.
- Description (`description`, text): A note about the ad group.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdGroupId": "example",
    "AdGroupName": "example",
    "Availability": "example",
    "CampaignId": "example",
    "ChannelId": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "IsEnabled": true,
    "LastUpdatedAtUTC": "example"
  }
}
```

### Create campaign

Create a campaign with one flight. It spends nothing until it has an ad group that is turned on.

**Inputs**

- Advertiser (`advertiser_id`, text, required): The advertiser.
- Name (`name`, text, required): The campaign's name.
- Budget (`budget`, number, required): The most the campaign may spend, in the advertiser's currency. At least 0.
- Start (`start_date`, date and time, required): When the campaign starts spending.
- End (`end_date`, date and time): When the campaign stops spending, if its budget isn't used up first.
- Channel (`channel`, text, required): Where the ads run. Each ad group in the campaign must use the same channel. One of: `Display`, `Video`, `Audio`, `TV`, `NativeDisplay` (Native display), `NativeVideo` (Native video), `DigitalOutOfHome` (Digital out-of-home).
- Goal (`goal`, text, required): What The Trade Desk should optimize the campaign for. One of: `MaximizeReach` (Reach as many people as possible), `CPAInAdvertiserCurrency` (Cost per acquisition), `CPCInAdvertiserCurrency` (Cost per click), `CPCVInAdvertiserCurrency` (Cost per completed view), `VCPMInAdvertiserCurrency` (Cost per thousand viewable impressions), `CTRInPercent` (Click-through rate (%)), `VCRInPercent` (Video completion rate (%)), `ViewabilityInPercent` (Viewability (%)), `ReturnOnAdSpendPercent` (Return on ad spend (%)).
- Goal target (`goal_target`, number): The target for the goal: an amount in the advertiser's currency, or a percentage (1 means 1%). Not needed for reach. At least 0.
- Description (`description`, text): A note about the campaign.
- Pacing (`pacing`, text): How the budget is spread over the flight. One of: `PaceToEndOfFlight` (Spread evenly to the end of the flight), `PaceAhead` (Spend slightly ahead of schedule), `PaceAsSoonAsPossible` (Spend as soon as possible), `Off` (No pacing (set daily targets on the flights)).
- Purchase order number (`purchase_order_number`, text): Your own reference, such as a purchase order number.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdvertiserId": "example",
    "Availability": "example",
    "Budget": {
      "Amount": 1,
      "CurrencyCode": "example"
    },
    "CampaignFlights": [
      {
        "BudgetInAdvertiserCurrency": 1,
        "CampaignFlightId": 1,
        "CampaignId": "example",
        "DailyTargetInAdvertiserCurrency": 1,
        "EndDateExclusiveUTC": "example",
        "StartDateInclusiveUTC": "example"
      }
    ],
    "CampaignId": "example",
    "CampaignName": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "EndDate": "example",
    "LastUpdatedAtUTC": "example",
    "PacingMode": "example",
    "PrimaryChannel": "example",
    "PurchaseOrderNumber": "example",
    "StartDate": "example"
  }
}
```

### Delete campaign flight

Delete a flight that hasn't started. A campaign's only flight can't be deleted.

**Inputs**

- Campaign flight (`campaign_flight_id`, number, required): The campaign flight: one of the campaign's date ranges with its own budget. At least 1.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {}
}
```

### Get ad group

Get an ad group's details, including its bids and whether it is turned on.

**Inputs**

- Ad group (`ad_group_id`, text, required): The ad group.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdGroupId": "example",
    "AdGroupName": "example",
    "Availability": "example",
    "CampaignId": "example",
    "ChannelId": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "IsEnabled": true,
    "LastUpdatedAtUTC": "example"
  }
}
```

### Get advertiser

Get an advertiser's details, including its currency.

**Inputs**

- Advertiser (`advertiser_id`, text, required): The advertiser.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdvertiserId": "example",
    "AdvertiserName": "example",
    "Availability": "example",
    "CurrencyCode": "example",
    "Description": "example",
    "DomainAddress": "example",
    "PartnerId": "example"
  }
}
```

### Get campaign

Get a campaign's details, including its budget and flights.

**Inputs**

- Campaign (`campaign_id`, text, required): The campaign.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdvertiserId": "example",
    "Availability": "example",
    "Budget": {
      "Amount": 1,
      "CurrencyCode": "example"
    },
    "CampaignFlights": [
      {
        "BudgetInAdvertiserCurrency": 1,
        "CampaignFlightId": 1,
        "CampaignId": "example",
        "DailyTargetInAdvertiserCurrency": 1,
        "EndDateExclusiveUTC": "example",
        "StartDateInclusiveUTC": "example"
      }
    ],
    "CampaignId": "example",
    "CampaignName": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "EndDate": "example",
    "LastUpdatedAtUTC": "example",
    "PacingMode": "example",
    "PrimaryChannel": "example",
    "PurchaseOrderNumber": "example",
    "StartDate": "example"
  }
}
```

### Get campaign pacing and goal metrics

Get how a campaign is pacing against its budget and how it is doing against its goal over the last four weeks.

**Inputs**

- Campaign (`campaign_id`, text, required): The campaign.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "CampaignFlightId": 1,
    "CampaignId": "example",
    "GoalInfo": {},
    "Pacing": {}
  }
}
```

### Get creative

Get a creative's details and its review status with each ad exchange.

**Inputs**

- Creative (`creative_id`, text, required): The creative (the ad itself: an image, video, audio or tag).

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdvertiserId": "example",
    "Availability": "example",
    "CreatedAtUTC": "example",
    "CreativeAuditStatuses": [
      {
        "AuditStatus": "example",
        "CreativeAuditor": "example",
        "ReasonForStatus": "example"
      }
    ],
    "CreativeId": "example",
    "CreativeName": "example",
    "CreativeType": "example",
    "Description": "example",
    "LastUpdatedAtUTC": "example"
  }
}
```

### List ad groups

List a campaign's ad groups.

**Inputs**

- Campaign (`campaign_id`, text, required): The campaign.
- Search terms (`search_terms`, list): Only return records whose name or description contains every one of these words.
- Status (`availability`, list): Show active records, archived ones, or both. Leave empty for active only. One or more of: `Available` (Active), `Archived`.
- Start at record (`page_start`, number): How many records to skip, for reading the next page. Leave empty to start at the first record. At least 0.
- Records per page (`page_size`, number): How many records to return, up to 1000. Leave empty for 100. From 1 to 1000.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "Result": [
      {
        "AdGroupId": "example",
        "AdGroupName": "example",
        "Availability": "example",
        "CampaignId": "example",
        "ChannelId": "example",
        "CreatedAtUTC": "example",
        "Description": "example",
        "IsEnabled": true,
        "LastUpdatedAtUTC": "example"
      }
    ],
    "ResultCount": 1,
    "TotalFilteredCount": 1,
    "TotalUnfilteredCount": 1
  }
}
```

### List advertisers

List the advertisers (brands) under a partner.

**Inputs**

- Partner (`partner_id`, text, required): The partner (your seat in The Trade Desk) the advertisers belong to.
- Search terms (`search_terms`, list): Only return records whose name or description contains every one of these words.
- Status (`availability`, list): Show active records, archived ones, or both. Leave empty for active only. One or more of: `Available` (Active), `Archived`.
- Start at record (`page_start`, number): How many records to skip, for reading the next page. Leave empty to start at the first record. At least 0.
- Records per page (`page_size`, number): How many records to return, up to 1000. Leave empty for 100. From 1 to 1000.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "Result": [
      {
        "AdvertiserId": "example",
        "AdvertiserName": "example",
        "Availability": "example",
        "CurrencyCode": "example",
        "Description": "example",
        "DomainAddress": "example",
        "PartnerId": "example"
      }
    ],
    "ResultCount": 1,
    "TotalFilteredCount": 1,
    "TotalUnfilteredCount": 1
  }
}
```

### List campaigns

List an advertiser's campaigns, newest first.

**Inputs**

- Advertiser (`advertiser_id`, text, required): The advertiser.
- Search terms (`search_terms`, list): Only return records whose name or description contains every one of these words.
- Status (`availability`, list): Show active records, archived ones, or both. Leave empty for active only. One or more of: `Available` (Active), `Archived`.
- Start at record (`page_start`, number): How many records to skip, for reading the next page. Leave empty to start at the first record. At least 0.
- Records per page (`page_size`, number): How many records to return, up to 1000. Leave empty for 100. From 1 to 1000.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "Result": [
      {
        "AdvertiserId": "example",
        "Availability": "example",
        "Budget": {
          "Amount": 1,
          "CurrencyCode": "example"
        },
        "CampaignFlights": [
          {
            "BudgetInAdvertiserCurrency": 1,
            "CampaignFlightId": 1,
            "CampaignId": "example",
            "DailyTargetInAdvertiserCurrency": 1,
            "EndDateExclusiveUTC": "example",
            "StartDateInclusiveUTC": "example"
          }
        ],
        "CampaignId": "example",
        "CampaignName": "example",
        "CreatedAtUTC": "example",
        "Description": "example",
        "EndDate": "example",
        "LastUpdatedAtUTC": "example",
        "PacingMode": "example",
        "PrimaryChannel": "example",
        "PurchaseOrderNumber": "example",
        "StartDate": "example"
      }
    ],
    "ResultCount": 1,
    "TotalFilteredCount": 1,
    "TotalUnfilteredCount": 1
  }
}
```

### List creatives

List an advertiser's creatives (the ads themselves) with their review status.

**Inputs**

- Advertiser (`advertiser_id`, text, required): The advertiser.
- Search terms (`search_terms`, list): Only return records whose name or description contains every one of these words.
- Status (`availability`, list): Show active records, archived ones, or both. Leave empty for active only. One or more of: `Available` (Active), `Archived`.
- Start at record (`page_start`, number): How many records to skip, for reading the next page. Leave empty to start at the first record. At least 0.
- Records per page (`page_size`, number): How many records to return, up to 1000. Leave empty for 100. From 1 to 1000.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "Result": [
      {
        "AdvertiserId": "example",
        "Availability": "example",
        "CreatedAtUTC": "example",
        "CreativeAuditStatuses": [
          {
            "AuditStatus": "example",
            "CreativeAuditor": "example",
            "ReasonForStatus": "example"
          }
        ],
        "CreativeId": "example",
        "CreativeName": "example",
        "CreativeType": "example",
        "Description": "example",
        "LastUpdatedAtUTC": "example"
      }
    ],
    "ResultCount": 1,
    "TotalFilteredCount": 1,
    "TotalUnfilteredCount": 1
  }
}
```

### List partners

List the partners (seats) your token can reach.

**Inputs**

- Search terms (`search_terms`, list): Only return records whose name or description contains every one of these words.
- Start at record (`page_start`, number): How many records to skip, for reading the next page. Leave empty to start at the first record. At least 0.
- Records per page (`page_size`, number): How many records to return, up to 1000. Leave empty for 100. From 1 to 1000.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "Result": [
      {
        "PartnerId": "example",
        "PartnerName": "example"
      }
    ],
    "ResultCount": 1,
    "TotalFilteredCount": 1,
    "TotalUnfilteredCount": 1
  }
}
```

### Turn ad group on or off

Turn an ad group on so it can spend, or off so it stops.

**Inputs**

- Ad group (`ad_group_id`, text, required): The ad group.
- On (`enabled`, true/false, required): On lets the ad group spend; off stops it.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdGroupId": "example",
    "IsEnabled": true
  }
}
```

### Update ad group

Change an ad group's name or description. Fields left empty stay as they are.

**Inputs**

- Ad group (`ad_group_id`, text, required): The ad group.
- Name (`name`, text): The new name.
- Description (`description`, text): The new description.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdGroupId": "example",
    "AdGroupName": "example",
    "Availability": "example",
    "CampaignId": "example",
    "ChannelId": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "IsEnabled": true,
    "LastUpdatedAtUTC": "example"
  }
}
```

### Update campaign

Change a campaign's name, description, pacing, channel or purchase order number. Fields left empty stay as they are.

**Inputs**

- Campaign (`campaign_id`, text, required): The campaign.
- Name (`name`, text): The new name.
- Description (`description`, text): The new description.
- Pacing (`pacing`, text): How the budget is spread over the flight. One of: `PaceToEndOfFlight` (Spread evenly to the end of the flight), `PaceAhead` (Spend slightly ahead of schedule), `PaceAsSoonAsPossible` (Spend as soon as possible), `Off` (No pacing (set daily targets on the flights)).
- Channel (`channel`, text): Where the ads run. One of: `Display`, `Video`, `Audio`, `TV`, `NativeDisplay` (Native display), `NativeVideo` (Native video), `DigitalOutOfHome` (Digital out-of-home).
- Purchase order number (`purchase_order_number`, text): Your own reference, such as a purchase order number.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "AdvertiserId": "example",
    "Availability": "example",
    "Budget": {
      "Amount": 1,
      "CurrencyCode": "example"
    },
    "CampaignFlights": [
      {
        "BudgetInAdvertiserCurrency": 1,
        "CampaignFlightId": 1,
        "CampaignId": "example",
        "DailyTargetInAdvertiserCurrency": 1,
        "EndDateExclusiveUTC": "example",
        "StartDateInclusiveUTC": "example"
      }
    ],
    "CampaignId": "example",
    "CampaignName": "example",
    "CreatedAtUTC": "example",
    "Description": "example",
    "EndDate": "example",
    "LastUpdatedAtUTC": "example",
    "PacingMode": "example",
    "PrimaryChannel": "example",
    "PurchaseOrderNumber": "example",
    "StartDate": "example"
  }
}
```

### Update campaign flight

Change a flight's dates or budget. A flight that has ended can't be changed.

**Inputs**

- Campaign flight (`campaign_flight_id`, number, required): The campaign flight: one of the campaign's date ranges with its own budget. At least 1.
- Start (`start_date`, date and time): When the flight starts.
- End (`end_date`, date and time): When the flight ends.
- Budget (`budget`, number): The most the flight may spend, in the advertiser's currency. At least 0.
- Daily spend target (`daily_target`, number): The most the flight should spend in a day, in the advertiser's currency. At least 0.

**Outputs**

- `data` (object): The response from The Trade Desk.

**Example output**

```json
{
  "data": {
    "BudgetInAdvertiserCurrency": 1,
    "CampaignFlightId": 1,
    "CampaignId": "example",
    "DailyTargetInAdvertiserCurrency": 1,
    "EndDateExclusiveUTC": "example",
    "StartDateInclusiveUTC": "example"
  }
}
```
