Skip to content

Devices

This document outlines the available API routes for managing device relevant actions

Base URL

  • Bas path /api2/devices.

Authorization

  • Requires Cookie: JSESSIONID=session_id

Get All Devices

🛠 Endpoint:

GET /

Example Request:

curl -X GET "https://api.trackongps.com/api2/devices" \
  -H "Cookie: JSESSIONID=your_session_id"

Description:

Fetches all devices associated with the authenticated user extending the installation information.

200 OK - Example Response
[
  {
    "id": "12345",
    "name": "Device Name",
    "installation": "2024-08-30T12:00:00.000Z"
  }
]

Get Drivers List

🛠 Endpoint:

GET /drivers

Example Request:

curl -X GET "https://api.trackongps.com/api2/devices/drivers" \
  -H "Cookie: JSESSIONID=your_session_id"

Description:

Fetch driver id with its drivers list.

200 OK - Example Response
{
"driverId": 12,
"drivers": [
    {
    "id": "12345",
    "name": "Driver 123",
    "attributes": {}
    }
  ]
}

Add New Device

🛠 Endpoint:

POST /

Description:

Adds a new device to the system with its installation record. New device is added into existing trackon db and installation information in Secondary db.

Request Body Parameters:

Field Type Required Description
name string Yes Name of the device
uniqueId string Yes Unique identifier for the device (e.g., IMEI)
phone string Yes Contact number associated with the device
contact string Yes Contact person for the device
category string No Category of the device
model string No Model of the device
groupId string No Group identifier for the device
attributes object No Additional attributes (e.g., mileage, etc.)
Important

This endpoint automatically sets a 1-year expiration period for all new devices. Manual modifications to expiration dates are not permitted to maintain system integrity.

Example Request:

curl -X POST "https://api.trackongps.com/api2/devices" \
  -H "Cookie: JSESSIONID=your_session_id" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Device Name",
    "category": "Device Category",
    "model": "Device Model",
    "uniqueId": "Unique Identifier",
    "groupId": 0,
    "phone": "Contact Number",
    "contact": "Contact Person",
    "attributes": {
      "mileage": 10
    }
  }'

Request Body:

{
  "name": "Device Name",
  "category": "Device Category",
  "model": "Device Model",
  "uniqueId": "Unique Identifier",
  "groupId": 0,
  "phone": "Contact Number",
  "contact": "Contact Person",
  "attributes": {
    "mileage": 10
  }
}
201 Created - Example Response
{

"id": "12345",
"name": "Device Name",
"installation": "2024-08-30T12:00:00.000Z",
"message": "Device added successfully."
}

Update a Device

🛠 Endpoint:

PUT /:deviceId

Description:

Updates an existing device's details. This endpoint helps to prevent expiration date from being edited.

URL Parameters:

Parameter Type Description
deviceId string Unique identifier for the device

Request Body Parameters:

Field Type Required Description
name string Yes Name of the device
uniqueId string Yes Unique identifier for the device (e.g., IMEI)
phone string Yes Contact number associated with the device
contact string Yes Contact person for the device
category string No Category of the device
model string No Model of the device
groupId string No Group identifier for the device
attributes object No Additional attributes (e.g., mileage, etc.)
Important

This endpoint ensures device expiration dates remain unchanged during updates, maintaining system security and data integrity. Only system administrators can modify expiration dates through dedicated processes.

Example Request:

curl -X PUT "https://api.trackongps.com/api2/devices/12345" \
  -H "Cookie: JSESSIONID=your_session_id" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Device Name",
    "category": "Updated Category"
  }'

Request Body:

{
  "name": "Updated Device Name",
  "category": "Updated Category"
}
200 OK - Example Response
{
"id": "12345",
"name": "Updated Device Name",
"category": "Updated Category"
}

Remove Device from V2 DB

🛠 Endpoint:

DELETE /:deviceId
Important

To remove the device from the system use api v1 and use this for clearing data from v2 database only which includes data like installation info and so on.

Example Request:

curl -X DELETE "https://api.trackongps.com/api2/devices/12345" \
  -H "Cookie: JSESSIONID=your_session_id"

Description:

Removes a device's installation data from secondary system.

URL Parameters:

Parameter Type Description
deviceId string Unique identifier for the device
204 No Content

IMEI Check

Description: Check if the IMEI number is already taken by other devices or not.

GET /check-imei/:imei_number

URL Parameters:

Parameter Type Description
imei string Unique imei identifier for the device

Example Request:

curl -X GET "https://api.trackongps.com/api2/devices/check-imei/<imei_number>" \
  -H "Cookie: JSESSIONID=your_session_id"
200 OK - Example Response
{
"message": "IMEI not used"
}
400 OK - Example Response
{
"message": "IMEI already used"
}