---
updatedAt: 2025-10-08T09:20:46.000Z
agentTools:
  projectIndex: https://dev.kevel.com/llms.txt
---

# Create Geo-Targeting

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

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "management-api-2",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.kevel.co"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "name": "X-Adzerk-ApiKey",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/flight/{FlightID}/geotargeting": {
      "post": {
        "summary": "Create Geo-Targeting",
        "description": "",
        "operationId": "create-geo-targeting",
        "parameters": [
          {
            "name": "FlightID",
            "in": "path",
            "description": "ID of the Flight",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "CountryCode": {
                    "type": "string",
                    "description": "The 2-3 character string that denotes the country you want to target"
                  },
                  "Region": {
                    "type": "string",
                    "description": "The 2-3 character string that denotes the region (or state) that you want to target"
                  },
                  "MetroCode": {
                    "type": "integer",
                    "description": "The 3 digit number that denotes the metropolitan area you want to target. US only.",
                    "format": "int32"
                  },
                  "City": {
                    "type": "string",
                    "description": "The name of the city you want to target"
                  },
                  "CityGeonameId": {
                    "type": "integer",
                    "description": "The numeric geoname ID that denotes the city you want to target. This is the value matched for city targeting. Retrieve valid IDs from the List Cities in Region endpoint.",
                    "format": "int32"
                  },
                  "IsExclude": {
                    "type": "boolean",
                    "description": "If leave blank, this will default to `false/null` and target the country. If you want to exclude it instead, use `true`",
                    "default": "false"
                  }
                }
              },
              "examples": {
                "JSON": {
                  "value": {
                    "FlightId": 12345,
                    "CountryCode": "US",
                    "Region": "NC",
                    "MetroCode": 560,
                    "City": "Durham",
                    "CityGeonameId": 4464368,
                    "IsExclude": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"LocationId\":76543,\n  \"FlightId\":12345,\n  \"CountryCode\":\"US\",\n  \"Region\":\"NC\",\n  \"MetroCode\":560,\n  \"City\":\"Durham\",\n  \"CityGeonameId\":4464368,\n  \"IsExclude\":false\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "LocationId": {
                      "type": "integer",
                      "example": 76543,
                      "default": 0
                    },
                    "FlightId": {
                      "type": "integer",
                      "example": 12345,
                      "default": 0
                    },
                    "CountryCode": {
                      "type": "string",
                      "example": "US"
                    },
                    "Region": {
                      "type": "string",
                      "example": "NC"
                    },
                    "MetroCode": {
                      "type": "integer",
                      "example": 560,
                      "default": 0
                    },
                    "City": {
                      "type": "string",
                      "example": "Durham"
                    },
                    "CityGeonameId": {
                      "type": "integer",
                      "example": 4464368,
                      "default": 0
                    },
                    "IsExclude": {
                      "type": "boolean",
                      "example": false,
                      "default": "false"
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "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}'"
            },
            {
              "language": "javascript",
              "code": "const Adzerk = require('@adzerk/management-sdk');\nconst apiKey = process.env.ADZERK_API_KEY;\n\nasync function createGeoTargeting() {\n  let specifications = await Adzerk.fetchSpecifications();\n  let client = await Adzerk.buildClient({apiKey, specifications});\n\n  let geoTargeting = await client.run(\"geoTargeting\", \"create\", {\n    flightId: 12345,\n    countryCode: \"US\",  // United States\n    region: \"NC\",       // North Carolina (optional)\n    metroCode: 560,     // Raleigh/Durham, NC (optional)\n    isExclude: false,   // target only this region, defaults to false\n  });\n\n  console.log(geoTargeting);\n}\n\ncreateGeoTargeting();"
            },
            {
              "language": "ruby",
              "code": "require \"adzerk\"\n\ndef create_geo_targeting()\n    client = Adzerk::Client.new(ENV[\"ADZERK_API_KEY\"])\n    flight_id = 12345\n    data = {\n        country_code: \"US\", \n        region: \"NC\",      \n        is_exclude: false,\n    }\n    pp client.geotargetings.create(flight_id, data)\nend\ncreate_geo_targeting()"
            }
          ],
          "samples-languages": [
            "curl",
            "javascript",
            "ruby"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [
      {
        "key": "X-Adzerk-Sdk-Version",
        "value": "Readme.io:ManagementAPI2"
      }
    ],
    "explorer-enabled": false,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true
}
```