Enable driver check-in and check-out

Driver identification actions allow drivers to check-in and check-out directly on a device via QR code, or with a five digit PIN code.

Once a driver checks in, all trips, recordings, events, and data are associated with the driver. The driver may check-out through the device, or be checked out through the API. If a new driver checks in while the device is associated with another driver, the previous driver is checked out.

A record of the driver is available in the Surfsight portal, and relevant information is recorded in the cloud and retrievable by API. This feature can be enabled through the Surfsight portal or API.

The rest of this guide shows you how to use the Surfsight API to manage driver identification capabilities and review the associated event data, following these steps:

  1. Authenticate yourself.
  2. Enable driver check-in
  3. Create driver 4Retrieve driving history
Note

For more information about the different API requests, take a look at our reference guide.

1. Authenticate yourself

Authenticate yourself before making any calls with the Surfsight API. For more details on authentication, see our authentication overview.

2. Enable driver check-in

Enable driver identification check-in with a five digit driver PIN code or QR code with the following calls:

  • PUT /devices/{imei}/event-config for an individual device
  • PUT /devices/device-config for bulk configurations
  • POST /organizations/{orgId}/event-settings for default settings for devices in an organization

Once driver check-in is enabled, a driver check-in icon appears on the device screen.

Copy
Copied
curl -i -X PUT \
https://api-prod.surfsight.net/v2/devices/:imei/device-config \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{ 
},
    "pinCodeDi": {
      "value": true
    },
    "qrDi": {
      "value": false
    },
    "driverIdentification": {
      "driverPrompt": true,
      "audioAlert": true,
      "driverPromptDurationSeconds": 30
    },
Parameter Description Required Example
imei The IMEI of the device. The IMEI number can be found on a sticker on the device itself or on the back of the device box. required 357660101000198
pinCodeDi Enable or disable driver identification (and assignment) through a unique code specific to that driver. Driver identification can be enabled either through this driver code or a QR code, but not both. required pinCodeDi
qrDi Enable or disable driver identification (and assignment) through a QR code specific to that driver (the same as the driver code, in QR code format). Driver identification can be enabled either through this QR code or a driver code, but not both. required qrDi
driverIdentification Driver identification when qrDi or pinCodeDi is enabled. optional none
driverPrompt Driver prompt on device for driver to check-in, unless the device is associated with a driver, in which case the prompt will not occur. If enabled, a driver is prompted to check in when the device exits standby mode. optional true
audioAlert Enable or disable audio beeps while driver prompt flashes on the device. This is only an option when driverPrompt is enabled. optional true
driverPromptDurationSeconds Driver prompt duration in seconds. Time intervals between 10 and 60 seconds can be customized. This is required when driverPrompt is enabled. optional 30

Returned response:

Copy
Copied
{
  "requestId": "requestId" 
}

3. Create driver

Create a driver with the POST /drivers call.

Copy
Copied
curl -i -X POST \
 'https://api-prod.surfsight.net/v2/drivers?organizationId=17' \
 -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
 -H 'Content-Type: application/json' \
 -d '{
  "data": [
    {
      "organizationId": 17,
      "driverThirdPartyId": "50729123",
      "drivingLicense": "10203040",
      "firstName": "John",
      "lastName": "Doe"
    }
  ]
},
Parameter Description Required Example
organizationId The ID of the organization. Obtain this from GET /organizations. required 17
driverThirdPartyId The third party ID of the driver in an organization. Retrieve this from GET /drivers. required 50729123
drivingLicense The driver's driver's license number. required 10203040
firstName The first name of the driver. required John
lastName The last name of the driver. required Doe

Returned response:

Copy
Copied
{
  "requestId": "requestId"
}

4. Retrieve driving history

Driving history can be retrieved with the GET /driving-history call. Information is available in the metadata of the event.

Copy
Copied
curl -i -X GET \
  'https://api-prod.surfsight.net/v2/driving-history?driverThirdPartyId=50729123&imei=12345678&start=2020-01-01T14%3A48%3A00.000Z&end=2020-01-01T14%3A48%3A00.000Z&sort=createdAt&order=asc&offset=1&limit=1' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
  
Parameter Description Example
driverThirdPartyId Filter by the driver's third party ID. Obtain this ID from GET /drivers. 50729123
imei The IMEI of the device. The IMEI number can be found on a sticker on the device itself or on the back of the device box. 357660101000198
start Filter by a start date and time, in ISO 8601 format. 2020-01-01T14:48:00.000Z
end Filter by an end date and time, in ISO 8601 format. 2020-01-01T14:50:00.000Z
sort Sort the driving history results. CreatedAt
order Set the order that pagination results appear in - ascending or descending order. asc
offset Set the number of results to skip over before receiving pagination results. 10
limit Set the maximum number of pagination results to receive. 10

The returned response:

Copy
Copied
{
"data": [
{
"driverHistory": [
{
"driver": {
"id": "qwerty12345",
"driverThirdPartyId": "50729123",
"drivingLicense": "10203040",
"firstName": "John",
"lastName": "Doe",
"driverCode": "12345",
"imei": "357660101000198",
"isActive": true
},
"startTime": "2021-12-14T12:42:04.323Z",
"endTime": "2021-12-14T14:09:53.876Z"
}
]
}
]
}
Parameter Description Example
id The ID assigned to the event. 247195231
driverThirdPartyId Filter by the driver's third party ID. Obtain this ID from GET /drivers. 50729123
drivingLicense The driver's driver's license number. 10203040
firstName The first name of the driver. John
lastName The last name of the driver. Doe
driverCode The unique 5-digit driver code that is used to assign the driver to a device (for check-in, for example) 12909
imei The IMEI of the device. The IMEI number can be found on a sticker on the device itself or on the back of the device box. 357660101000198
isActive Active or inactive state of the driver. Active
start Filter by a start date and time, in ISO 8601 format. 2020-01-01T14:48:00.000Z
end Filter by an end date and time, in ISO 8601 format. 2020-01-01T14:50:00.000Z