---
updatedAt: 2025-09-18T22:00:25.000Z
agentTools:
  projectIndex: https://dev.kevel.com/llms.txt
---

# Create Distance Targeting Geometry

## Why Create Distance Targeting Geometry?

Occasionally, you may wish to create very specific targeting for a flight using a predetermined distance from a street address. For example, if you want to target a certain locale where ads will be served within a narrow area, you can pinpoint an exact distance for your targeting by creating a distance targeting geometry object using `Latitude`, `Longitude`, and `StreetAddress` body parameters. The Kevel API enables you to create this object, which can then be used in your geo-targeting.

## API Syntax

When using the Create Distance Targeting Geometry 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}/distance`

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.
* `distance` - the distance targeting geometry object that contains the `Distance`, `Latitude`, `Longitude`, and `StreetAddress` body parameters used for distance targeting.

# 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}/distance": {
      "post": {
        "summary": "Create Distance Targeting Geometry",
        "description": "",
        "operationId": "create-geodistance-targeting-geometry",
        "parameters": [
          {
            "name": "FlightID",
            "in": "path",
            "description": "The ID of the flight",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "Distance": {
                    "type": "number",
                    "description": "The radius of the Distance geometry in kilometers. Min: 0.01, Max: 500. Optional on networks with user-specified radius features enabled; omit for user-specified radius.",
                    "format": "float"
                  },
                  "Latitude": {
                    "type": "number",
                    "description": "The latitude of the Distance point. Saved up to 7 decimal places. Cannot be used with `StreetAddress`.",
                    "format": "float"
                  },
                  "Longitude": {
                    "type": "number",
                    "description": "The longitude of the Distance point. Saved up to 7 decimal places. Cannot be used with `StreetAddress`.",
                    "format": "float"
                  },
                  "StreetAddress": {
                    "type": "string",
                    "description": "The street address of the Distance point. This will be resolved to latitude and longitude. Cannot be used with `Latitude` and `Longitude` params."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"Distance\": 42,\n  \"StreetAddress\": \"1 Kevel Boulevard, Keveltown NC 27701\",\n  \"FlightId\": 12345,\n  \"Latitude\": 35.9950488,\n  \"Longitude\": -78.9081815,\n  \"Id\": 123\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "Distance": {
                      "type": "integer",
                      "example": 42,
                      "default": 0
                    },
                    "StreetAddress": {
                      "type": "string",
                      "example": "1 Kevel Boulevard, Keveltown NC 27701"
                    },
                    "FlightId": {
                      "type": "integer",
                      "example": 12345,
                      "default": 0
                    },
                    "Latitude": {
                      "type": "number",
                      "example": 35.9950488,
                      "default": 0
                    },
                    "Longitude": {
                      "type": "number",
                      "example": -78.9081815,
                      "default": 0
                    },
                    "Id": {
                      "type": "integer",
                      "example": 123,
                      "default": 0
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Unresolvable address": {
                    "value": "{\n  \"Errors\": [\n    {\n      \"message\": \"Address cannot be resolved\",\n      \"values\": {\n        \"Distance\": 42,\n        \"StreetAddress\": \"bad address\",\n        \"FlightId\": 12345\n      }\n    }\n  ]\n}"
                  },
                  "Validation errors": {
                    "value": "{\n  \"Errors\": [\n    {\n      \"path\": [\n        \"Latitude\"\n      ],\n      \"value\": 200,\n      \"message\": \"Value '200' at '[\\\"Latitude\\\"]' Decimal value must be <= 90.0.\"\n    },\n    {\n      \"path\": [\n        \"Longitude\"\n      ],\n      \"value\": 200,\n      \"message\": \"Value '200' at '[\\\"Longitude\\\"]' Decimal value must be <= 180.0.\"\n    },\n    {\n      \"path\": [\n        \"Distance\"\n      ],\n      \"value\": 700,\n      \"message\": \"Value '700' at '[\\\"Distance\\\"]' Decimal value must be <= 500.\"\n    }\n  ]\n}"
                  },
                  "Max geometries reached": {
                    "value": "{\n  \"Errors\": [\n    {\n      \"message\": \"Error inserting Geometry\",\n      \"values\": {\n        \"Distance\": 42,\n        \"Latitude\": 35.9950488,\n        \"Longitude\": -78.9081815,\n        \"FlightId\": 12345,\n        \"StreetAddress\": \"1 Adzerk Boulevard, Adzerktown NC 27701\"\n      }\n    }\n  ]\n}"
                  },
                  "Bad JSON": {
                    "value": "{\n  \"Errors\": \"Invalid JSON payload\"\n}"
                  }
                },
                "schema": {
                  "oneOf": [
                    {
                      "title": "Unresolvable address",
                      "type": "object",
                      "properties": {
                        "Errors": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string",
                                "example": "Address cannot be resolved"
                              },
                              "values": {
                                "type": "object",
                                "properties": {
                                  "Distance": {
                                    "type": "integer",
                                    "example": 42,
                                    "default": 0
                                  },
                                  "StreetAddress": {
                                    "type": "string",
                                    "example": "bad address"
                                  },
                                  "FlightId": {
                                    "type": "integer",
                                    "example": 12345,
                                    "default": 0
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    {
                      "title": "Validation errors",
                      "type": "object",
                      "properties": {
                        "Errors": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "path": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "example": "Latitude"
                                }
                              },
                              "value": {
                                "type": "integer",
                                "example": 200,
                                "default": 0
                              },
                              "message": {
                                "type": "string",
                                "example": "Value '200' at '[\"Latitude\"]' Decimal value must be <= 90.0."
                              }
                            }
                          }
                        }
                      }
                    },
                    {
                      "title": "Max geometries reached",
                      "type": "object",
                      "properties": {
                        "Errors": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string",
                                "example": "Error inserting Geometry"
                              },
                              "values": {
                                "type": "object",
                                "properties": {
                                  "Distance": {
                                    "type": "integer",
                                    "example": 42,
                                    "default": 0
                                  },
                                  "Latitude": {
                                    "type": "number",
                                    "example": 35.9950488,
                                    "default": 0
                                  },
                                  "Longitude": {
                                    "type": "number",
                                    "example": -78.9081815,
                                    "default": 0
                                  },
                                  "FlightId": {
                                    "type": "integer",
                                    "example": 12345,
                                    "default": 0
                                  },
                                  "StreetAddress": {
                                    "type": "string",
                                    "example": "1 Adzerk Boulevard, Adzerktown NC 27701"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    {
                      "title": "Bad JSON",
                      "type": "object",
                      "properties": {
                        "Errors": {
                          "type": "string",
                          "example": "Invalid JSON payload"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "503",
            "content": {
              "application/json": {
                "examples": {
                  "Geocoding unavailable": {
                    "value": "{\n  \"Errors\": [\n    {\n      \"message\": \"Geocoding service unavailable\"\n    }\n  ]\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "Errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "message": {
                            "type": "string",
                            "example": "Geocoding service unavailable"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "## Using street address \n\ncurl -X POST -H \"X-Adzerk-ApiKey:$ADZERK_API_KEY\" -H \"Content-Type:application/json\" https://api.kevel.co/v1/flight/12345/distance --data-binary '{\"Distance\":42.0,\"StreetAddress\":\"1 Kevel Boulevard, Keveltown NC 27701\"}'\n\n## Using longitude and latitude\n\ncurl -X POST -H \"X-Adzerk-ApiKey:$ADZERK_API_KEY\" -H \"Content-Type:application/json\" https://api.kevel.co/v1/flight/12345/distance --data-binary '{\"Distance\":42.0,\"Latitude\":35.9950488,\"Longitude\":-78.9081815}'",
              "name": "cURL"
            },
            {
              "language": "javascript",
              "code": "const Adzerk = require('@adzerk/management-sdk');\nconst apiKey = process.env.ADZERK_API_KEY;\n\n// Using street address\n\nasync function createDistanceTargeting() {\n  let specifications = await Adzerk.fetchSpecifications();\n  let client = await Adzerk.buildClient({apiKey, specifications, logger});\n\n  let distanceTargeting = await client.run('distanceTargeting', 'create', {\n    flightId: 12345,\n    distance: 42,\n    streetAddress: \"1 Kevel Boulevard, Keveltown NC 27701\"\n  });\n\n  console.log(distanceTargeting);\n}\ncreateDistanceTargeting()\n\n// Using longitude and latitude\n\nasync function createDistanceTargeting() {\n  let specifications = await Adzerk.fetchSpecifications();\n  let client = await Adzerk.buildClient({apiKey, specifications, logger});\n\n  let distanceTargeting = await client.run('distanceTargeting', 'create', {\n    flightId: 12345,\n    distance: 42,\n    latitude: 35.9950488,\n    longitude: -78.9081815\n  });\n\n  console.log(distanceTargeting);\n}\ncreateDistanceTargeting()"
            },
            {
              "language": "ruby",
              "code": "require \"adzerk\"\n\n# Using street address\n\ndef create_distance_targeting()\n    client = Adzerk::Client.new(ENV[\"ADZERK_API_KEY\"])\n    flight_id = 12345\n    data = {\n        distance: 42,\n        street_address: \"1 Kevel Boulevard, Keveltown NC 27701\"\n    }\n    pp client.distance_targetings.create(flight_id, data)\nend\ncreate_distance_targeting()\n\n# Using longitude and latitude\n\ndef create_distance_targeting()\n    client = Adzerk::Client.new(ENV[\"ADZERK_API_KEY\"])\n    flight_id = 12345\n    data = {\n        distance: 42,\n        latitude: 35.9950488,\n      \tlongitude: -78.9081815,\n    }\n    pp client.distance_targetings.create(flight_id, data)\nend\ncreate_distance_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
}
```