added
Driver ↔️ Vehicle Assignments
about 4 years ago by Tyler Freckmann
There are two new API endpoints that allow you to retrieve the driver(s) of each vehicle for a given time period and vice versa.:
- GET /fleet/drivers/vehicle-assignments returns the list of vehicles for each driver over a given time range
- GET /fleet/vehicles/driver-assignments returns the list of drivers for each vehicle over a given time range:
See below for sample code for each endpoint:
GET /fleet/drivers/vehicle-assignments
GET /fleet/drivers/vehicle-assignments
curl --request GET 'https://api.samsara.com/fleet/drivers/vehicle-assignments' \
-d startTime='2020-11-01T08:00:00Z' \
-d endTime='2020-11-02T08:00:00Z' \
-G \
--header 'Authorization: Bearer <<token>>'
{
"data": [
{
"id": "1654973",
"name": "Tyler Freckmann",
"driverActivationStatus": "active",
"externalIds": {
"payrollSys1": "[email protected]"
},
"vehicleAssignments": [
{
"isPassenger": false,
"vehicle": {
"id": "281474977075805",
"name": "Little Red",
"externalIds": {
"samsara.serial": "G9MTH7CNKZ",
"samsara.vin": "JTMBK32V895081147"
}
},
"startTime": "2020-11-01T18:16:17.152Z",
"endTime": "2020-11-01T18:54:07.996Z",
"assignmentType": "driverApp"
}
]
}
],
"pagination": {
"endCursor": "",
"hasNextPage": false
}
}
GET /fleet/vehicles/driver-assignments
GET /fleet/vehicles/driver-assignments
curl --request GET 'https://api.samsara.com/fleet/vehicles/driver-assignments' \
-d startTime='2020-11-01T08:00:00Z' \
-d endTime='2020-11-02T08:00:00Z' \
-G \
--header 'Authorization: Bearer <<token>>'
{
"data": [
{
"id": "281474977075805",
"name": "Little Red",
"externalIds": {
"samsara.serial": "G9MTH7CNKZ",
"samsara.vin": "JTMBK32V895081147"
},
"driverAssignments": [
{
"isPassenger": false,
"driver": {
"id": "1654973",
"name": "Tyler Freckmann",
"externalIds": {
"payrollSys1": "[email protected]"
}
},
"startTime": "2020-11-01T18:16:17.152Z",
"endTime": "2020-11-01T18:54:07.996Z",
"assignmentType": "driverApp"
}
]
}
],
"pagination": {
"endCursor": "",
"hasNextPage": false
}
}