Scan a QR code and review event data
Scanning a QR code on documents and goods allows users to pair metadata with the event's time and location, and can be configured to include a video or snapshot. This feature supports workflows in external applications by scanning items such as health certifications, proof of delivery, approvals, and other documentation.
The rest of this guide shows you how to use the Surfsight API to enable and scan a QR code, and review the associated event data following these steps:
- Authenticate yourself.
- Enable the QR code event
- Scan a QR code
- Retrieve QR code scan event information
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 the QR code event
Enable the QR code event with the following calls:
PUT /devices/{imei}/event-config
for an individual devicePUT /devices/event-config
for bulk configurationsPOST /organizations/{orgId}/event-settings
for default settings for devices in an organization
Once the QR code event is enabled, a QR code icon appears on the device screen.
curl --request PUT 'https://api-prod.surfsight.net/v2/devices/{imei}/event-config
--header 'Content-Type: application/json'
--header 'Authorization: Bearer {token}'
--data-raw '{
"vehicleType": "Private",
"events":
{
"eventType": "qrCode",
"dataType": "none",
"visualAlert": true,
"audioAlert": true
}
}'
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. | Yes | 357660101000198 |
vehicleType | The type of vehicle associated with the device. The type of vehicle affects the sensitivity of the device's motion sensor. Private is the most sensitive to movements, and trailer is the least sensitive. | optional | Private |
eventType | The type of event. | Yes | qrCode |
dataType | The type of data that is attached to an event when the event is generated. | Yes | none |
visualAlert | Whether or not a visual alert is shown on the device screen when an event occurs. | optional | true |
audioAlert | Whether or not an audio alert is played when an event occurs. | optional | true |
Returned response:
{
"requestId": {"requestId"}
}
3. Scan a QR code
- Press the QR code icon at the top left of the device screen. The device beeps for ten seconds or until a QR code is scanned.
- Within ten seconds, scan the QR code using the in-cab lens. An event is triggered and sent to the cloud, with the QR code as metadata. A success message is displayed on the device screen.
4. Retrieve QR code scan event information
Event data can be retrieved with the GET devices/{imei}/events
call. Information from the QR code scan is available in the metadata of the event. Event data also includes a timestamp, and video or snapshot, if configured.
curl --request GET 'https://api-prod.surfsight.net/v2/devices/{imei}/events'
--header 'Authorization: Bearer {token}'
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. | Yes | 357660101000198 |
The returned response:
{
"id": 247195378,
"eventType": "qrCode",
"metadata": "{\"code\":\"Shipment delivered id_4081337\"}",
"lat": 32.98581475,
"lon": 35.14809606,
"time": "2022-01-05T07:06:19.000Z",
"files": [
{
"cameraId": 1,
"fileId": "1641366379",
"fileType": "video"
}
]
}
Parameter | Description | Example |
---|---|---|
id | The ID assigned to the event. | 247195231 |
eventType | The type of event. | qrCode |
metadata | The metadata uploaded from the QR code | |
lat | The GPS longitude. | 32.17380468 |
lon | The GPS latitude. | 34.91901649 |
time | The time, in UTC format. | 2022-01-05T07:06:19.000Z |
cameraId | The ID of the camera. 1 - road-facing camera; 2 - in-cabin-facing camera; 50+ - auxiliary cameras. | 1 |
fileId | The ID of the file. | 1641366379 |
fileType | The file type. | video |