Skip to content

Geofences

The Geofence Management API enables creation, retrieval, updates, and deletion of geofences. Access levels vary between standard users (restricted to assigned devices/groups) and admins/managers (broader access).

Data Schema

Field Type Description
id integer Unique geofence identifier
name string Geofence name
description string Geofence description
area string Geofence area definition
calendarId integer Associated calendar identifier
attributes object Additional geofence attributes

Fetch Geofences

Retrieves geofences based on specified filters and access levels.

🛠 Endpoint:

GET /geofences

Authorization:

  • Requires Basic Authentication (basicAuth)

Query Parameters:

Parameter Type Description
all boolean (Admin/Manager only) Fetch all geofences
userId integer Filter by user ID (restricted for standard users)
deviceId integer Filter by device ID (restricted for standard users)
groupId integer Filter by group ID (restricted for standard users)
refresh boolean Force data refresh

Example Request:

# Using Basic Auth
curl -X GET 'http://localhost:8082/api/geofences' \
  -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='
# Using Cookie Auth
curl -X GET 'http://localhost:8082/api/geofences' \
  -H 'Cookie: JSESSIONID=your_session_id'
200 OK - Response Body
[
  {
    "id": 0,
    "name": "string",
    "description": "string",
    "area": "string",
    "calendarId": 0,
    "attributes": {}
  }
]

Create Geofence

Creates a new geofence entry.

🛠 Endpoint:

POST /geofences

Authorization:

  • Requires Basic Authentication (basicAuth)

Example Request:

# Using Basic Auth
curl -X POST 'http://localhost:8082/api/geofences' \
  -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Office Area",
    "description": "Company office geofence",
    "area": "CIRCLE (30.123 -97.456, 100)",
    "calendarId": 1,
    "attributes": {
      "color": "red",
      "category": "work"
    }
  }'
# Using Cookie Auth
curl -X POST 'http://localhost:8082/api/geofences' \
  -H 'Cookie: JSESSIONID=your_session_id' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Office Area",
    "description": "Company office geofence",
    "area": "CIRCLE (30.123 -97.456, 100)",
    "calendarId": 1,
    "attributes": {
      "color": "red",
      "category": "work"
    }
  }'

Request Body:

{
  "id": 0,
  "name": "string",
  "description": "string",
  "area": "string",
  "calendarId": 0,
  "attributes": {}
}
200 OK - Response Body
{
  "id": 0,
  "name": "string",
  "description": "string",
  "area": "string",
  "calendarId": 0,
  "attributes": {}
}

Update Geofence

Updates an existing geofence by ID.

🛠 Endpoint:

PUT /geofences/{id}

Authorization:

  • Requires Basic Authentication (basicAuth)

Path Parameters:

Parameter Type Description
id integer ID of geofence to update

Example Request:

# Using Basic Auth
curl -X PUT 'http://localhost:8082/api/geofences/1' \
  -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Updated Office Area",
    "description": "Updated company office geofence",
    "area": "CIRCLE (30.123 -97.456, 150)",
    "calendarId": 1,
    "attributes": {
      "color": "blue",
      "category": "work"
    }
  }'
# Using Cookie Auth
curl -X PUT 'http://localhost:8082/api/geofences/1' \
  -H 'Cookie: JSESSIONID=your_session_id' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Updated Office Area",
    "description": "Updated company office geofence",
    "area": "CIRCLE (30.123 -97.456, 150)",
    "calendarId": 1,
    "attributes": {
      "color": "blue",
      "category": "work"
    }
  }'

Request Body:

{
  "id": 0,
  "name": "string",
  "description": "string",
  "area": "string",
  "calendarId": 0,
  "attributes": {}
}
200 OK - Response Body
{
  "id": 0,
  "name": "string",
  "description": "string",
  "area": "string",
  "calendarId": 0,
  "attributes": {}
}

Delete Geofence

Removes a geofence by ID.

🛠 Endpoint:

DELETE /geofences/{id}

Authorization:

  • Requires Basic Authentication (basicAuth)

Path Parameters:

Parameter Type Description
id integer ID of geofence to delete

Example Request:

# Using Basic Auth
curl -X DELETE 'http://localhost:8082/api/geofences/1' \
  -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ='
# Using Cookie Auth
curl -X DELETE 'http://localhost:8082/api/geofences/1' \
  -H 'Cookie: JSESSIONID=your_session_id'
204 No Content