## Why Update Flights?

Occasionally you may find it useful to update an existing flight in your campaign to reflect changes in your campaign strategy. For example, you may wish to optimize your campaign by changing your `GoalType` or `PriorityId` to determine whether these changes positively impact the overall performance of the campaign.

> 📘
>
> ### Note
>
> You may update any flight field except `id`.

## API Syntax

When using the _Update 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:

`PUT https://api.kevel.co/v1/flight/{flightId}`

Where:

- `PUT` \- 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 of the specific flight you wish to update.

## 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.

> 📘
>
> ### Clearing attribute values
>
> To unset or clear an attribute, set its value to `NULL`.

| Field            | Type     |Required | Description |
|------------------|----------|---------|-------------|
| FlightID        | int32    | required| This is the ID of the Flight |
| excludeAds      | boolean  |         | If true, the endpoint returns only the flight metadata without ad objects |
| Id               | int32    | required| The ID of the Flight |
| Name             | string   | required| The name of the Flight |
| StartDateISO    | string   | required| Start date in ISO 8601 format: `YYYY-MM-DDTHH:MM:SS.SSSSSSS`. You can also just use `YYYY-MM-DD` |
| EndDateISO      | string   |         | End date in ISO 8601 format: `YYYY-MM-DDTHH:MM:SS.SSSSSSS`. You can also just use `YYYY-MM-DD` |
| NoEndDate       | boolean  |         | If flight has no specified End Date, set to `true` |
| CampaignId      | int32    | required| The ID of the campaign |
| PriorityId      | int32    | required| The ID of the 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.kevel.com/docs/flights#section-goals) |
| Impressions      | int32    | required| The Goal Amount |
| IsActive        | boolean  | required| Active/inactive state of the flight |
| IsDeleted       | boolean  |         | If want to delete, set to `true` |
| IsArchived      | boolean  |         | Specifies whether flight is archived. |

## Example Request

```bash
curl -X PUT \
     -H "X-Adzerk-ApiKey:4ADZERK_API_KEY" \
     -H "Content-Type:application/json" \
     --data-binary '{"Id":123456,"PriorityId":12345,"GoalType":2,"RateType":2,"CampaignId":123456,"Name":"A Different Name","StartDateISO":"2018-06-03","IsActive":true}' \
     "https://api.kevel.co/v1/flight/123456"
```

### Example Response

```json
{
  "Name": "A Different Name",
  "StartDateISO": "2017-05-01T00:00:00.00.0000000",
  "EndDateISO": "2017-12-31T00:00:00.00.0000000",
  "CampaignId": 1234,
  "PriorityId": 1234,
  "GoalType": 1,
  "Impressions": 20000,
  "RateType": 2,
  "Price": 5,
  "CapType": 1,
  "DailyCapAmount": 5000,
  "LifetimeCapAmount": 50000,
  "IsActive": true,
  "Keywords": "exercise",
  "CustomTargeting": null,
  "GeoTargeting": [
    {
      "CountryCode": "US",
      "Region": "NC",
      "MetroCode": 560,
      "IsExclude": false
    }
  ],
  "SiteZoneTargeting": [
    {
      "SiteId": 123,
      "ZoneId": 321,
      "IsExclude": false
    }
  ],
  "IsFreqCap": true,
  "FreqCap": 2,
  "FreqCapDuration": 10,
  "FreqCapType": 1,
  "DontAffectParentFreqCap": true,
  "IsCompanion": true,
  "IsNoDuplicates": false,
  "IsTrackingConversions": true,
  "CanPassback": true,
  "PassbackSortOrder": 1,
  "IsArchived": false,
  "IsSunday": true,
  "IsMonday": false,
  "IsTuesday": false,
  "IsWednesday": false,
  "IsThursday": false,
  "IsFriday": false,
  "IsSaturday": true,
  "IsECPMOptimized": true,
  "ECPMOptimizePeriod": 30,
  "ECPMMultiplier": 1.25,
  "FloorECPM": 0.15,
  "CeilingECPM": 0.35,
  "DefaultECPM": 0.28,
  "ECPMBurnInImpressions": 1000,
  "BehavioralTargeting": {
    "onClick": {
      "stopShowingAdsFromFlight": true,
      "stopShowingAdsFromAdvertiser": true,
      "storeCategoriesFromFlightAsInterest": true
    },
    "onConvert": {
      "stopShowingAdsFromFlight": true,
      "stopShowingAdsFromAdvertiser": true,
      "storeCategoriesFromFlightAsInterest": true
    }
  }
}
```

Updated 10 months ago

---
