## Why Create an Ad?

An ad is an important part of a flight and campaign, and can help in driving traffic to a website or domain. To create an ad, simply upload the creative associated with the ad to the system using the [Create Creative](https://dev.kevel.com/reference/create-creative) API call. After the creative is uploaded, pass the `CreativeID` as the `id` for the creative object.

An ad will be created, and the unique Ad ID returned may then be used to update or delete ads.

### Creating product-based ads?

If you're using Kevel [Catalog](docs:catalog), create ads directly from product data using the asynchronous [create ads from products](https://dev.kevel.com/reference/submit-jobs) Jobs endpoint.

## API Syntax

When using the Create Ads API call, it is important to understand the syntax required to make the request. There is a specific request format that must be followed to ensure the endpoint can process the request. The format is:

`POST https://api.kevel.co/v1/flight/{FlightID}/creative`

Where:

- `POST` - the type of API request being made.
- `https://api.kevel.co` - the URL for the request.
- `v1` - the API version.
- `flight` - the API endpoint being called.
- `FlightID` - the ID associated with the Flight.
- `creative` - indicates that we're mapping a Creative to the Flight.

## Additional Parameters

In addition to the parameters already listed above that can be passed as part of this request, there are a few additional parameters you can pass to further refine the ad being created. These parameters are listed in the table below.

| Property | Description |
| --- | --- |
| `IsNetworkAd`<br>(boolean) | Indicates that ad comes from a 3rd party (i.e. uses 3rd party ad tags) - for use with Click Bucketing. If `true` = multiple clicks from the same IP address count as Unique Clicks |
| `DontAffectParentFreqCap`<br>(boolean) | "Opts-out" of frequency cap settings imposed on it by above |
| `FreqCap`<br>(integer) | The cap of the frequency cap. Instructions [here](https://dev.kevel.com/docs/ad-frequency-capping) |
| `FreqCapDuration`<br>(integer) | How long the frequency cap should apply. Instructions [here](https://dev.kevel.com/docs/ad-frequency-capping) |
| `FreqCapType`<br>(integer) | The unit for the frequency cap: `1 = Hour 2 = Day 3 = Minute`. Instructions [here](https://dev.kevel.com/docs/ad-frequency-capping) |

_Misc Notes_

**Goal**: If GoalType is 2 (Percentage), then a Goal of 100 represents a 100% goal. If GoalType is 1 (Impressions), then a Goal of 200000 represents a goal of 200,000 impressions. Note: when you GET a creative, you will see a value of "null" for Goal, and the goal should be represented as e.g. "Impressions": 200000 or "Percentage": 100. Our API does this conversion behind the scenes.

**IsGoalOverride**: You will see this `IsGoalOverride` field in the results of a GET request for an ad -- this indicates whether or not the flight-level goal is being overridden by an ad-level goal. When creating or updating an ad, however, you do not need to explicitly set `IsGoalOverride` -- it is set automatically based on whether or not you are supplying `GoalType` and `Goal`.

**IsStartEndDateOverride**: You will see `IsStartEndDateOverride` field in the results of a GET request for an ad -- this indicates whether or not the ad has its own start/end dates. When creating or updating an ad, however, you do not need to explicitly set `IsStartEndDateOverride` -- it is set automatically based on whether or not you are supplying `StartDateISO` and `EndDateISO`.

### Example Request

```shell
curl -X POST -H "X-Adzerk-ApiKey:$ADZERK_API_KEY" -H "Content-Type:application/json" "https://api.kevel.co/v1/flight/12345/creative" --data-binary '{"Creative":{"Id":12345},"FlightId":12345,"IsActive":true}'
```

### A minimally viable ad example

```json
{
  "IsActive": true,
  "DontAffectParentFreqCap": false,
  "Creative": {
    "IsActive": true,
    "ImageName": "",
    "SaveEmptyCreative": null,
    "Body": "",
    "IsNetworkAd": null,
    "Alt": null,
    "Title": "Adzerk Creative",
    "IsDeleted": false,
    "IsSync": null,
    "Url": "http://adzerk.com",
    "IsIdOnly": false,
    "IsNoTrack": null,
    "TemplateValues": null,
    "TemplateId": null,
    "ImageLink": "http://s.zkcdn.net/Advertisers/",
    "ScriptBody": "",
    "AdvertiserId": 123,
    "Metadata": null,
    "AdTypeId": 5,
    "IsHTMLJS": false,
    "Id": 12345
  },
  "FreqCapType": null,
  "EndDate": null,
  "Iframe": null,
  "ZoneId": null,
  "PublisherAccountId": 0,
  "IsDeleted": false,
  "CustomTargeting": "$keywords contains \"dean\"",
  "EndDateISO": "2017-12-05T12:00:00.0000000",
  "RtbCustomFields": null,
  "Impressions": 100,
  "GoalType": 1,
  "Goal": 200000,
  "Price": 1,
  "FreqCapDuration": null,
  "Percentage": 0,
  "FreqCap": null,
  "IsStartEndDateOverride": true,
  "CustomRelevancyScore": null,
  "FlightId": 7290072,
  "ActiveKeywords": [
    "kittens",
    "cats"
  ],
  "SiteId": null,
  "CampaignId": 123,
  "Id": 12345,
  "IsGoalOverride": true,
  "StartDateISO": "2017-05-01T12:00:00.0000000"
}
```
