Create and Modify Drivers

Add Drivers

POST /drivers

Adds drivers to the fleet account. There is a limit of adding up to 50 drivers per API call.

Each driver has a Driver ID (identifier) and a Driver Name. Driver ID is required to be unique within the fleet account, whereas Driver Name is not required to be unique.

Note:

  • If a Driver ID and Driver Name combination already exists in the fleet account and
    • If the same Driver ID and Driver Name is sent in the request, then the request will be ignored with an appropriate message indicating that duplicate records were not added.
    • If the Driver ID is same but Driver Name is different, then in the response, an appropriate message is returned indicating that duplicate records were not added.
    • If Driver Name is the same but Driver ID is different, then a new record gets created with the new Driver ID and Driver Name.

Request

Authorization: bearer {token}

NameDescriptionData Type
driverIdExternal driver identifier—must be unique within the fleet accountAlphanumeric
NameExternal driver name—need not be unique within the fleet accountAlphanumeric

Response

NameDescriptionData Type
IdUnique, system-generated identifier for unique driverInt
NameDriver Name that was added into the fleet accountAlphanumeric
driverIdDriver Id that was added into the fleet accountAlphanumeric
ModifiedOnIndicates the last time the vehicle was modifiedDateTime

Sample Request

[
  {
    "driverId": "drv1",
    "Name": "driver 1"
  },
  {
    "driverId": "drv2",
    "Name": "driver 2"
  }
]

Sample Response

{
  "error": {
    "message": "The request finished without adding duplicate driverIds",
    "code": -12,
    "duplicate_ids": ["drv1"]
  },
  "data": [
    {
      "Id": 337318,
      "Name": "driver 2",
      "DriverId": "drv2",
      "ModifiedOn": "2019-03-29T14:19:17.34"
    }
  ]
}

Error Codes

MessageDescription
The request finished without adding duplicate driverIdsThis error is thrown when driverIds already exist within the account

Update Drivers

PUT /drivers

Updates a Driver Name that is associated with a specific Driver ID in the account.

Request

Authorization: bearer {token}

NameDescriptionData Type
driverIdExternal Driver IdentifierAlphanumeric
NameExternal Driver NameAlphanumeric

Response

NameDescriptionData Type
IdUnique system generated identifier for unique driver.Int
NameDriver Name that was updated.Alphanumeric
DriverIdDriver Id of the driver that was updated.Alphanumeric
ModifiedOnIndicates the last time the driver was modified.DateTime

Sample Request

[
  {
    "driverId": "drv1",
    "Name": "driver 1"
  },
  {
    "driverId": "drv3",
    "Name": "driver 3"
  }
]

Sample Response

{
  "error": {
    "message": "The request finished without updating non-existent drivers",
    "code": -11,
    "ids_not_found": ["drv3"]
  },
  "data": [
    {
      "Id": 337316,
      "Name": "driver 1",
      "DriverId": "drv1",
      "ModifiedOn": "2019-03-29T14:15:49.577"
    }
  ]
}

Error Codes

MessageDescription
The request finished without updating non-existent driversThis error is thrown when driversIds do not exist within the account.

Get a List of Drivers

GET /drivers

Gets a list of Driver IDs and Driver Names from an account. By default, the first 20 drivers in the account will be populated. Set the limit parameter to retrieve as many drivers as necessary.

Request

Authorization: bearer {token}

NameDescriptionData Type
offsetPagination parameter indicating the cursor position to begin with in the response for this requestAlphanumeric
limitPagination parameter indicating the number of results to return in the response for this requestInt
sortExpressionThe parameter based on which sorting should be performed. Pass either driverId or driverName.string
sortDirectionSort the results in ascending or descending order. Pass either ASC or DESC.string

Response

NameDescriptionData Type
hrefRequest URLstring
offsetPagination parameter indicating the cursor position at which the response beginsInt
limitPagination parameter indicating the number of results in the responseInt
sizePagination parameter indicating the total number of pages that are available in the responseInt
firstPagination parameter with a link to get the first page of the results in the responsestring
nextPagination parameter with a link to get the next page of the results in the responsestring
previousPagination parameter with a link to get the previous page of the results in the responsestring
lastPagination parameter with a link to get the last page of the results in the responsestring
idUnique system generated identifier for unique vehicleInt
nameName of the driverstring
driverIdDriver Id of the driverInt
modifiedOnIndicates the last time the driver record was modifiedDateTime

Sample Response

{
  "href": "https://fleets.trimblemaps.com/api/assets/v1/drivers",
  "offset": 50,
  "limit": 15,
  "size": 255,
  "first": {
    "href": "https://fleets.trimblemaps.com/api/assets/v1/drivers?offset=0&limit=15"
  },
  "previous": {
    "href": "https://fleets.trimblemaps.com/api/assets/v1/drivers?offset=35&limit=15"
  },
  "next": {
    "href": "https://fleets.trimblemaps.com/api/assets/v1/drivers?offset=65&limit=15"
  },
  "last": {
    "href": "https://fleets.trimblemaps.com/api/assets/v1/drivers?offset=240&limit=15"
  },
  "data": [
    {
      "id": 77864,
      "name": "Fred",
      "driverId": "did12345",
      "modifiedOn": "2017-09-12T17:59:04.453"
    },
    {
      "id": 3626,
      "name": "Tom",
      "driverId": "did48976",
      "modifiedOn": "2016-01-19T21:21:47.303"
    }
  ]
}

Delete a Driver

DELETE /drivers

Delete a driver using his or her driverID.

Request

Authorization: bearer {token}

NameDescriptionData Type
driverIdDriver ID of the driverInt

Response

NameDescriptionData Type
messageText indicating the result of deleting a driverstring

Sample Response

{
  "message": "Successfully deleted driver with Id: did48976"
}

Error Codes

MessageDescription
No driver found with Id: {}The driverId passed in the request to delete was not found in the account.
Last updated September 20, 2019.