## Why Update an Ad?

Sometimes, you may find it necessary to update an existing ad that is part of a flight or campaign. This may be needed if you want to use new graphics or images, or just make changes to the ad as part of an update to a flight or campaign. The Kevel API enables you to updates simply and easily by using the Update Ad API call.

### Note

You can update all fields from Create Ads except for `id`.

### Warning

Do not use this endpoint to update creatives from the Create Creatives endpoint. This API call is used to update ads from the Create Ads endpoint.

Also, any fields you do not include in a `PUT` request will be given the default values `null`, `false`, `0`, or `empty array`, depending on the field. This will overwrite any existing values. When making a `PUT` request, make sure you are supplying all the fields that should have values.

## API Syntax

When using the Update Ad 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`/creative/`AdID`

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 associated with the flight.
- `creative` - the creative associated with the Ad.
- `AdID` - the ID of the ad being updated.

### Clearing attribute values

To unset or clear an attribute, set its value to `NULL`.

### API Parameters

- **FlightID**  
  `int32`  
  required  
  The ID of the Flight

- **AdID**  
  `int32`  
  required  
  This is the ID from the Ad / Creative Flight Map Endpoint. It's not the ID from the Create Creatives endpoint.

- **Id**  
  `int32`  
  required  
  ID of the Creative Flight Map / Ad

- **CampaignID**  
  `int32`  
  ID of the Campaign
  
- **IsActive**  
  `boolean`  
  required  
  If Ad is active or not

- **IsDeleted**  
  `boolean`  
  required  
  If Ad is deleted or not

- **Iframe**  
  `boolean`  
  Whether Creative should use iFrame

- **DistributionType**  
  `int32`  
  Determines how the Ad is distributed within the flight

- **RtbCustomFields**  
  `string`  
  Required for RTB ads only. JSON Object in a String. It's JSON data provided by the RTB partner

- **AttributionSettings**  
  `object`  
  AttributionSettingsobject

### Example: A minimally viable ad update:

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

```json
{
  "Id": 12345,
  "CampaignId": 123,
  "FlightId": 1234,
  "ZoneId": 1234,
  "SiteId": 12345,
  "Iframe": false,
  "PublisherAccountId": 0,
  "Impressions": 0,
  "Percentage": 0,
  "DistributionType": 1,
  "IsDeleted": false,
  "IsActive": false,
  "Creative": {
    "Id": 123456,
    "Title": "Adzerk Blue Creative",
    "ImageName": "",
    "Url": "https://adzerk.com",
    "Body": "",
    "AdvertiserId": 1234,
    "IsActive": true,
    "AdTypeId": 5,
    "Alt": "Adzerk - Native Ads",
    "IsDeleted": false,
    "IsSync": false,
    "IsHTMLJS": true,
    "ScriptBody": "Flight Creative Map",
    "Metadata": null,
    "ImageLink": "httpss://static.adzerk.net/Advertisers/",
    "IsNoTrack": true,
    "IsNetworkAd": false
  },
  "CustomTargeting": "$keywords contains \"dean\"",
  "FreqCap": 5,
  "FreqCapDuration": 1,
  "FreqCapType": 2,
  "StartDate": null,
  "EndDate": null,
  "GoalType": 1,
  "Goal": 20000,
  "Price": 1,
  "IsGoalOverride": true,
  "IsStartEndDateOverride": true,
  "ActiveKeywords": [
    "kittens",
    "cats"
  ],
  "RtbCustomFields": null
}
```
