Geofencing
Set up and manage geofences for your trackable devices with the AirPinpoint API.
Geofencing
The Geofencing endpoints allow you to create, manage, and monitor geofences for your trackable devices.
Create a Geofence
Create a new geofence for a specific trackable device.
Endpoint
POST /trackables/{trackable_id}/geofences
Example Request
curl -X POST "https://api.airpinpoint.com/trackables/tag_123456/geofences" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Home", "latitude": 37.7749, "longitude": -122.4194, "radius": 100, "notify_on_enter": true, "notify_on_exit": true}'
Example Response
{
"id": "geofence_789012",
"trackable_id": "tag_123456",
"name": "Home",
"latitude": 37.7749,
"longitude": -122.4194,
"radius": 100,
"notify_on_enter": true,
"notify_on_exit": true,
"created_at": "2023-06-15T17:00:00Z"
}
List Geofences
Retrieve a list of all geofences for a specific trackable device.
Endpoint
GET /trackables/{trackable_id}/geofences
Example Request
curl -X GET "https://api.airpinpoint.com/trackables/tag_123456/geofences" \
-H "Authorization: Bearer YOUR_API_KEY"
Example Response
{
"geofences": [
{
"id": "geofence_789012",
"name": "Home",
"latitude": 37.7749,
"longitude": -122.4194,
"radius": 100,
"notify_on_enter": true,
"notify_on_exit": true
},
{
"id": "geofence_345678",
"name": "Work",
"latitude": 37.7833,
"longitude": -122.4167,
"radius": 200,
"notify_on_enter": true,
"notify_on_exit": false
}
]
}
Update a Geofence
Update the details of an existing geofence.
Endpoint
PUT /trackables/{trackable_id}/geofences/{geofence_id}
Example Request
curl -X PUT "https://api.airpinpoint.com/trackables/tag_123456/geofences/geofence_789012" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "New Home", "radius": 150}'
Example Response
{
"id": "geofence_789012",
"trackable_id": "tag_123456",
"name": "New Home",
"latitude": 37.7749,
"longitude": -122.4194,
"radius": 150,
"notify_on_enter": true,
"notify_on_exit": true,
"updated_at": "2023-06-15T17:30:00Z"
}
Delete a Geofence
Remove a geofence from a trackable device.
Endpoint
DELETE /trackables/{trackable_id}/geofences/{geofence_id}
Example Request
curl -X DELETE "https://api.airpinpoint.com/trackables/tag_123456/geofences/geofence_789012" \
-H "Authorization: Bearer YOUR_API_KEY"
Example Response
{
"message": "Geofence successfully removed",
"removed_at": "2023-06-15T18:00:00Z"
}
Get Geofence Events
Retrieve a list of geofence entry and exit events for a specific trackable device.
Endpoint
GET /trackables/{trackable_id}/geofences/events
Query Parameters
start_time
: ISO 8601 formatted timestamp (required)end_time
: ISO 8601 formatted timestamp (required)limit
: Maximum number of results to return (optional, default: 50)
Example Request
curl -X GET "https://api.airpinpoint.com/trackables/tag_123456/geofences/events?start_time=2023-06-14T00:00:00Z&end_time=2023-06-15T23:59:59Z&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
Example Response
{
"events": [
{
"id": "event_123456",
"geofence_id": "geofence_789012",
"type": "enter",
"timestamp": "2023-06-15T08:00:00Z"
},
{
"id": "event_234567",
"geofence_id": "geofence_789012",
"type": "exit",
"timestamp": "2023-06-15T17:30:00Z"
}
// ... more events ...
],
"total_events": 10
}
For more details on geofencing, including advanced shapes and bulk operations, please refer to the API Reference.