LatLong

Geofence API

Create, manage, and query virtual geographic boundaries. Check if a point is inside a geofence for delivery zones, restricted areas, and location-based alerts.

Try in Playground →

Authentication

All geofence endpoints require your API token:

X-Authorization-Token: your_token_here

Endpoints

POST/v4/geofence/create.json

Create Geofence

Create a new virtual geographic boundary by providing a polygon geometry.

Parameters

NameTypeRequiredDescription
namestringOptionalOptional name for the geofence
geometryobjectRequiredGeoJSON Polygon with coordinates array

Code Examples

curl -X POST "https://apihub.latlong.ai/v4/geofence/create.json" \
  -H "X-Authorization-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "coordinates": [
    [
      77.59,
      12.97
    ],
    [
      77.6,
      12.98
    ]
  ]
}'

Response

JSON200 OK
{
  "status": "success",
  "geofence_id": "gf_abc123",
  "message": "Geofence created successfully"
}
GET/v4/geofence/contains.json

Contains (Point in Geofence)

Check if a given latitude/longitude point falls inside any of your geofences.

Parameters

NameTypeRequiredDescription
latitudenumberRequiredLatitude of the point to check
longitudenumberRequiredLongitude of the point to check
geofence_idstringOptionalCheck against a specific geofence (optional — checks all if omitted)

Code Examples

curl "https://apihub.latlong.ai/v4/geofence/contains.json?latitude=VALUE&longitude=VALUE" \
  -H "X-Authorization-Token: YOUR_TOKEN"

Response

JSON200 OK
{
  "status": "success",
  "code": 1001,
  "data": {
    "inside": true,
    "geofence_id": "gf_abc123",
    "geofence_name": "Office Zone"
  }
}
GET/v4/geofence/list.json

List Geofences

Retrieve a list of all geofences created under your account.

Code Examples

curl "https://apihub.latlong.ai/v4/geofence/list.json" \
  -H "X-Authorization-Token: YOUR_TOKEN"

Response

JSON200 OK
{
  "status": "success",
  "code": 1001,
  "data": [
    { "geofence_id": "gf_abc123", "name": "Office Zone", "created_at": "2025-01-15" },
    { "geofence_id": "gf_def456", "name": "Warehouse", "created_at": "2025-02-10" }
  ]
}
GET/v4/geofence/details.json

Geofence Details

Get the full details and geometry of a specific geofence by its ID.

Parameters

NameTypeRequiredDescription
geofence_idstringRequiredThe ID of the geofence to retrieve

Code Examples

curl "https://apihub.latlong.ai/v4/geofence/details.json?geofence_id=VALUE" \
  -H "X-Authorization-Token: YOUR_TOKEN"

Response

JSON200 OK
{
  "status": "success",
  "code": 1001,
  "data": {
    "geofence_id": "gf_abc123",
    "name": "Office Zone",
    "geometry": {
      "type": "Polygon",
      "coordinates": [[[77.59,12.97],[77.60,12.97],[77.60,12.98],[77.59,12.98],[77.59,12.97]]]
    },
    "created_at": "2025-01-15"
  }
}
POST/v4/geofence/update.json

Update Geofence

Update the geometry or name of an existing geofence.

Parameters

NameTypeRequiredDescription
geofence_idstringRequiredThe ID of the geofence to update
namestringOptionalNew name for the geofence
geometryobjectRequiredUpdated GeoJSON Polygon coordinates

Code Examples

curl -X POST "https://apihub.latlong.ai/v4/geofence/update.json" \
  -H "X-Authorization-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "coordinates": [
    [
      77.59,
      12.97
    ],
    [
      77.6,
      12.98
    ]
  ]
}'

Response

JSON200 OK
{
  "status": "success",
  "message": "Geofence updated successfully"
}

Ready to try it?

Draw polygons and test geofence APIs interactively.

Open Playground →