## What are Flights?  
A flight is a collection of ads grouped under a campaign. Most targeting and delivery rules are set at the flight level. These rules include items such as:

- impression goals
- tracking methods
- dates to run
- targeting

For example, if an advertiser wants to place an advertisement for summer clothing, the best time to display the ad may be in the summer months, and not in the autumn or winter months.

Kevel enables users to create flights by either using the Kevel UI or API. This section describes how to use the _Create Flight_ API to create flights.

For more information on flights and how they can be used for optimizing performance using the Kevel UI, please refer to the [Kevel UI Flight documentation](https://dev.kevel.co/v1.0/docs/flights) overview page.

## API Syntax  
When using the _Create Flight_ API, it is important to understand the syntax required to make the request. Because the Kevel API is a RESTful API, 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`

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.

## Flight Fields  
There are a number of fields that can be used when creating a flight. These fields are described in detail in the [Flight Fields](https://dev.kevel.com/docs/flights#flight-fields) documentation.

## Geotargeting  
Geotargeting is a type of advertising that uses location data to display ads to a user within a specific geographic region. For example, if a user is based in Japan, ads can be directed to users within that region that may be of interest, such as anime, technology, etc.

Although certain assumptions are made about users in a region, geotargeting can be a powerful tool for publishers and advertisers to provide ad inventory to users in different regions and parts of the world.

When a user opts in to location services, this type of advertising allows a publisher or advertiser to be more focused in campaigns to ensure maximum return on investment.

Put simply, geotargeting helps advertisers create more engaging, relevant, targeted advertisements for users, which can result in increased user engagement.

## Behavioral Targeting  
The Create Flight API also enables behavior targeting through the use of behavioral objects.

The Behavioral object is used for [Interest/Behavioral Targeting](https://dev.kevel.co/docs/interest-targeting) and [Excluding Ads Based on Behavior](https://dev.kevel.co/docs/behavioral).

The `BehavioralTargeting` object contains six boolean statements, three under `onClick` and three under `onConvert`. All default to `false`. All are optional.

| Property | Description |
| --- | --- |
| `onClick: {"stopShowingAdsFromFlight":XX}` | Stops showing ads from flight if someone clicks. |
| `onClick: {"stopShowingAdsFromAdvertiser":XX}` | Stops showing ads from advertiser if someone clicks. |
| `onClick: {"storeCategoriesFromFlightAsInterest":XX}` | Saves the category of the flight to UserDB, tied to `user`, based on click. |
| `onConvert: {"stopShowingAdsFromFlight":XX}` | Stops showing ads from flight if someone converts. |
| `onConvert: {"stopShowingAdsFromAdvertiser":XX}` | Stops showing ads from advertiser if someone converts. |
| `onConvert: {"storeCategoriesFromFlightAsInterest":XX}` | Saves the category of the flight to UserDB, tied to `user`, based on conversion. |

JSON

```json
"BehavioralTargeting": {
    "onClick": {
      "stopShowingAdsFromFlight": true,
      "stopShowingAdsFromAdvertiser": true,
      "storeCategoriesFromFlightAsInterest": true
    },
    "onConvert": {
      "stopShowingAdsFromFlight": true,
      "stopShowingAdsFromAdvertiser": true,
      "storeCategoriesFromFlightAsInterest": true
    }
  }
```

## Segment Targeting  
Segment targeting lets you deliver more relevant ads by limiting who sees them based on predefined user groups, or “segments.” These segments can be built in Kevel Audience or imported from an external system—such as a customer data platform (CDP). Once set up, you can use segments to target users based on behavior, demographics, shopping habits, or any custom criteria, enabling more personalized and effective ad experiences.

Learn more on the [Segment Targeting knowledge base page](https://dev.kevel.com/docs/segment-targeting).

---
- Name: string
  - required: The flight name. Max length is 300 characters.
- StartDateISO: string
  - required: UTC start date in ISO 8601 format: `YYYY-MM-DDTHH:MM:SS.SSSSSSS`. This can also be sent in the format of `YYYY-MM-DD`.
- CampaignId: int32  
  - required: The ID of the campaign.
- PriorityId: int32  
  - required: The ID of the [Priority](https://dev.adzerk.com/docs/priorities). Here are the [Priority API endpoints](https://dev.adzerk.com/v1.0/reference/priority).
- GoalType: int32  
  - required: This is the metric that Kevel uses to pace the ads so it hits the desired goal by the end date.  Key follows: `1 = Impressions 2 = Percentage 3 = Click 7 = Conversion 8 = Revenue 9 = Daily Revenue  10 = Monthly Revenue`. Instructions are [here](https://dev.adzerk.com/v1.0/docs/flights#section-goals)  
- Impressions: int32
  - required: The goal amount - specifies the number of GoalTypes to aim for during the life of the campaign. For Revenue, Daily Revenue and Monthly Revenue Goal Types the maximum Goal Amount is 500000000. For all other GoalTypes the maximum Goal Amount is 2147483647. Instructions are [here](https://dev.kevel.com/docs/flights#section-goals). Note: the field is named Impressions even if Goal Type is not set to Impressions.
- IsActive: boolean
  - required: Defaults to false
  - Specifies whether campaigns should be active or inactive. Defaults to `false`.
- RateType: int32
  - required: The Rate value - instructions [here](https://dev.adzerk.com/v1.0/docs/flights#section-rateprice). Key: `1 = Flat 2 = CPM 3 = CPC 4 = CPA View 5 = CPA Click 6 = CPA View & Click`.
- EndDateISO: string
  - UTC end date in ISO 8601 format: `YYYY-MM-DDTHH:MM:SS.SSSSSSS`. You can also send in a standard date of `YYYY-MM-DD`. **Required** if `GoalType` is not `2`,`9` or `10`.
- IsDeleted: boolean
  - Defaults to false  
  - Specifies whether flight should be deleted. Do not use when creating a flight. Defaults to `false`.
