Skip to main content

Create and Modify Drivers

Contents

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 and Drive Name are required to be unique within the fleet account.

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.

Names and Ids can only include the following characters: A-Za-z0-9-_=+*#! .,()`~?.

Request

Authorization: bearer {token}

NameDescriptionData Type
driverIdExternal driver identifier—must be unique within the fleet account
Alphanumeric
NameExternal driver name—must be unique within the fleet account
Alphanumeric

Response

NameDescriptionData Type
IdUnique, system-generated identifier for unique driver
Int
NameDriver Name that was added into the fleet account
Alphanumeric
driverIdDriver Id that was added into the fleet account
Alphanumeric
ModifiedOnIndicates the last time the vehicle was modified
DateTime

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. The Name must be unique within the fleet.

Request

Authorization: bearer {token}

NameDescriptionData Type
driverIdExternal Driver Identifier
Alphanumeric
NameExternal Driver Name
Alphanumeric

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 request
Alphanumeric
limitPagination parameter indicating the number of results to return in the response for this request
Int
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 URL
string
offsetPagination parameter indicating the cursor position at which the response begins
Int
limitPagination parameter indicating the number of results in the response
Int
sizePagination parameter indicating the total number of pages that are available in the response
Int
firstPagination parameter with a link to get the first page of the results in the response
string
nextPagination parameter with a link to get the next page of the results in the response
string
previousPagination parameter with a link to get the previous page of the results in the response
string
lastPagination parameter with a link to get the last page of the results in the response
string
idUnique system generated identifier for unique vehicle
Int
nameName of the driver
string
driverIdDriver Id of the driver
Int
modifiedOnIndicates the last time the driver record was modified
DateTime

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

Query Parameter

Delete a driver using their driverID.

Request

Authorization: bearer {token}

Query Parameter

NameDescriptionData Type
driverIdDriver ID of the driver
Int

Response

NameDescriptionData Type
messageText indicating the result of deleting a driver
string

Sample Request

https://fleets.trimblemaps.com/api/assets/v1/drivers?driverId=1234

Sample Response

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

Error Codes

MessageDescription
No driver found with Id: {}The driverId passed in the request to delete was not found in the account.
Last updated June 13, 2023.
Contents