Geofencing API

post
Create Geofence API

https://api.geospark.co/v3/api/geofence/
The create Geofence API is responsible for creating geofences for projects.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Body Parameters
coordinates
required
array
Mandatory for creating the geofence. E.g.- [ -72.28122, 42.926042 ]
metadata
optional
array
An optional set of custom key-value pairs for the geofence.
geometry_type
required
string
Defines the type of geometry. E.g.- circle
geometry_radius
required
integer
Defines the radius of circular geofence in meters. Range 50m to 1000m. (Required only for geometry_type circle. Field value ignored if sent when geometry_type is a polygon.) E.g.- 50m to 1000m max
color_code
optional
string
Defines the color of Geofence and how it is displayed on the dashboard. Type: Hex Code for CSS colors. Note: Pass the code without '#'. E.g.- ffffff
tag
optional
string
Tag the GeoFences for future reference and filtering. E.g.- hotel
description
optional
string
Optional description for the geofence. E.g.- This is just a 5 star cool hotel where you can stay.
is_enabled
optional
boolean
Enable/Disable 'event_trigger' for Geofences. By default event trigger are disabled. E.g.- true or false
Response
200: OK
{
"status": true,
"msg": "Geofence Added successfully.",
"code": 201,
"data": {
"id": "5f73326ce5fc231ba4b253eb",
"account_id": "5bda16a2ea00845b3b419160",
"project_id": "5bda16edea00845b3b419163",
"geometry_type": "circle",
"geometry_radius": 177,
"geometry_center": {
"type": "Point",
"coordinates": [
-72.28122,
42.926042
]
},
"is_enabled": true,
"is_deleted": false,
"created_at": "2020-09-29T13:11:08.702",
"updated_at": "2020-09-29T13:11:08.702"
}
}

Sample Request

curl --location --request POST 'https://api.geospark.co/v3/api/geofence/' \
--header 'Api-Key: e566c098cc6b441a9c3453b6fcf76e88' \
--header 'Content-Type: application/json' \
--data-raw '{
"geometry_type": "circle",
"coordinates": [ -72.28122, 42.926042 ] ,
"geometry_radius": 177,
"is_enabled": true
}'

put
Update Geofence API

https://api.geospark.co/v3/api/geofence/
Use this API to update details for an existing geofence of any specific project using Update Geofence API.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Body Parameters
geofence_id
required
integer
geofence_id which need to be updated E.g.- 5bd2aee1eec1a50d8faf1293
metadata
optional
array
An optional set of custom key-value pairs for the geofence.
color_code
optional
string
Defines the color of Geofence and how it is displayed on the dashboard. Type: Hex Code for CSS colors. Note: Pass the code without '#'. E.g.- ffffff
tag
optional
string
Tag the GeoFences for future reference and filtering. E.g.- hotel
description
optional
string
Optional description for the geofence. E.g.- This is just a 5 star cool hotel where you can stay.
is_enabled
optional
boolean
Enable/Disable 'event_trigger' for Geofences. By default event trigger are disabled. E.g.- true or false
Response
200: OK
{
"status": true,
"msg": "Geofence updated successfully.",
"code": 200,
"data": {
"id": "5f73326ce5fc231ba4b253eb",
"account_id": "5bda16a2ea00845b3b419160",
"project_id": "5bda16edea00845b3b419163",
"geometry_type": "circle",
"geometry_radius": 177,
"geometry_center": {
"type": "Point",
"coordinates": [
-72.28122,
42.926042
]
},
"is_enabled": true,
"description": "testing geofence",
"color_code": "ffff",
"tag": "border code",
"is_deleted": false,
"created_at": "2020-09-29T13:11:08.702",
"updated_at": "2020-09-29T13:13:43.890"
}
}

Sample Request

curl --location --request PUT 'https://api.geospark.co/v3/api/geofence/' \
--header 'Api-Key: e566c098cc6b441a9c3453b6fcf76e88' \
--header 'Content-Type: application/json' \
--data-raw '{
"geofence_id": "5f73326ce5fc231ba4b253eb",
"is_enabled": true,
"description": "testing geofence",
"tag": "border code",
"color_code": "ffff"
}'

get
GET Geofence API

https://api.geospark.co/v3/api/geofence/
This API gives you the filtered list of geofences.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Query Parameters
page_number
optional
integer
This field can be used for getting 10 entries at a time. If the response returns an empty list in data field, it is safe to assume the pages are exhausted. E.g.-1
start_date
required
string
Date from when the geofences created to be fetched. E.g.- 2020-09-28
end_date
required
string
Date till when the data need to be returned. E.g.- 2020-09-29
geofence_id
optional
string
Get the details of one geofence. E.g.- 5f73326ce5fc231ba4b253eb
Response
200: OK
{
"status": true,
"msg": "Success.",
"code": 200,
"data": {
"next_page": null,
"pages": 1,
"prev_page": null,
"account_id": "5bda16a2ea00845b3b419160",
"project_id": "5bda16edea00845b3b419163",
"geofences": [
{
"counts": {
"events": 0,
"users": 0
},
"id": "5f73326ce5fc231ba4b253eb",
"geometry_type": "circle",
"geometry_radius": 177,
"geometry_center": {
"type": "Point",
"coordinates": [
-72.28122,
42.926042
]
},
"is_enabled": true,
"description": "testing geofence",
"color_code": "ffff",
"tag": "border code",
"is_deleted": false,
"created_at": "2020-09-29T13:11:08.702",
"updated_at": "2020-09-29T13:13:43.890"
}
]
}
}

Sample Request

curl --location --request GET 'https://test.api.geospark.co/v3/api/geofence/?start_date=2020-09-28&end_date=2020-09-29&count=True' \
--header 'Api-Key: e566c098cc6b441a9c3453b6fcf76e88'

delete
Delete Geofence API

https://api.geospark.co/v3/api/geofence
Delete Geofence API allows you to delete already existing geofences for a project
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.-33223kjhdcscijhb5sdbsdmjsdcbj5f
Query Parameters
geofence_id
optional
string
Delete geofence for this id. E.g.- 5f73326ce5fc231ba4b253eb
Response
200: OK
{
"status": true,
"msg": "Geofence deleted successfully.",
"code": 200,
"data": {}
}

Sample Request

curl --location --request DELETE 'https://api.geospark.co/v3/api/geofence/?geofence_id=5f73326ce5fc231ba4b253eb' \
--header 'Api-Key: e566c098cc6b441a9c3453b6fcf76e88' \
--header 'Content-Type: application/json'