## Why Create Geo-Targeting?

This API endpoint enables you to target a flight to a geographical area, either inclusively (only show the flight in this area) or exclusively (show the flight everywhere except this area). To add multiple geo-targeting locations, make multiple requests to the endpoint. Each will get their own `LocationId`.

> 📘
>
> ### Note
>
> Use Kevel's List Geo Endpoints to receive the most current and up-to-date Countries/Regions/MetroCodes.

## API Syntax

When using the Create Get-Targeting API endpoint, 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/{FlightID}/geotargeting`

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.
- `geotargeting` - the object used to create geo-targeting for the flight.

### Parameters

| Parameter    | Type     | Description                                                                 |
|--------------|----------|-----------------------------------------------------------------------------|
| FlightID    | int32    | required ID of the Flight                                                  |
| CountryCode | string   | The 2-3 character string that denotes the country you want to target      |
| Region      | string   | The 2-3 character string that denotes the region (or state) that you want to target |
| MetroCode   | int32    | The 3 digit number that denotes the metropolitan area you want to target. US only. |
| IsExclude    | boolean  | Defaults to false. If left blank, this will default to `false/null` and target the country. If you want to exclude it instead, use `true`.

### Example Response

```json
{
  "LocationId": 76543,
  "FlightId": 12345,
  "CountryCode": "US",
  "Region": "NC",
  "MetroCode": 560,
  "IsExclude": false
}
```

### Example cURL Command

```bash
curl -X POST -H 'X-Adzerk-ApiKey:<APIKEY>' -H "Content-Type:application/json" "https://api.kevel.co/v1/flight/12345/geotargeting" --data-binary '{"FlightId":12345,"CountryCode":"US","Region":"NC","MetroCode":560, "IsExclude":false}'
```

Updated 9 months ago.
