Skip to content

Vehicle Lifecycle API⚓︎

Vehicle Lifecycle API

API Reference

API Changelog

The Vehicle Lifecycle API allows you to add or remove vehicles from your fleet.

Prerequisites⚓︎

The table below gives you an overview about the data of your vehicle or telematics unit which you need for this process. Some of the data points are mandatory, while others are optional. You can add or update the additonal/optional data later using the Vehicle Management API.

Information Description Example
telematics_brand Brand of the telematics unit. NIU
telematics_unit_id ID for the telematics unit that was assigned by the manufacturer. NBSG4C7B40647G5M as a NIU device serial number
vehicle_model_id ID of the vehicle’s vehicle_model. See vehicle models for more details. 01F4XW6QHWKT4HMSFDZ9CCQH1G references the model “NIU N1”
credentials_id (only for telematics units using shared credentials) ID of the credentials for the third-party API. See credentials for more details. 01F62857KMPG2NE2GK1W2N3QYS references your NIU Client ID and Client Secret
password (only for telematics units using individual credentials) The password that is necessary to communicate with the telematics unit. 12345
master_data (optional) This can range from VIN or license plate to the fuel type of the vehicle. See master data for more details. "vin": "R1NBDNB16J1000135"
custom_fields (optional) This can be any additional information as key-value pairs. See custom fields for more details. "seats": 4
tags (optional) Tags can be used to group vehicles together. See tags for more details. ["in_maintenance", "demo_night"]
operation_status (optional) The initial value for the operation_status of the vehicle (default is OPERATING). See operation status for more details. GARAGE

How to add vehicles to your fleet⚓︎

Important

You only need to integrate this API if you would like to add vehicles to your fleet using your booking software or some other automated script or application. The “adding vehicle assistant” within FleetControl provides you with a user interface for this API, which is sufficient for most use cases, and also faster and easier to use.

Adding a single vehicle⚓︎

If you want to add a single vehicle to your fleet, you can use the endpoint POST /vehicles of the Vehicle Lifecycle API (see documentation). Your request will be processed synchronously and the response contains the newly created vehicle.

The following example shows the API call to add a single vehicle:

curl -X POST \
  https://api.invers.com/vehicles \
  -H 'Authorization: Bearer ❰access_token❱' \ # (1)!
  -H 'Content-Type: application/json' \
  -d '{
        "telematics_unit": {
          "id": "NBSG7D2A50742X0F",
          "brand": "NIU",
          "setup": {
            "vehicle_model_id": "01F4XW6QHWKT4HMSFDZ9CCQH1G"
          },
          "authentication": {
            "credentials_id": "01F62857KMPG2NE2GK1W2N3QYS"
          }
        },
        "master_data": {
          "vin": "R1NBDNB16J1000135",
          "license_plate": "RKL-832",
          "brand": "NIU",
          "model": "N1",
          "custom_name": "MyNiuN1",
          "fuel_type": "ELECTRIC",
          "year_of_production": "2020",
          "transmission": "AUTOMATIC",
          "vehicle_type": "MOPED",
          "remark": "Our customers like that scooter very much."
        },
        "custom_fields": {
          "seats": "2",
          "color": "black"
        }
      }'
  1. Don’t forget to fill in your access token.

If the request has been successful, HTTP status code 201 will be returned. Here is an example of what the response payload might look like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{
  "id": "JQ7RP",
  "fleet_id": "F48XD",
  "created_at": "2021-01-19T13:13:09.952Z",
  "master_data": {
    "modified_at": "2021-01-19T13:13:09.952Z",
    "vin": "R1NBDNB16J1000135",
    "license_plate": "RKL-832",
    "brand": "NIU",
    "model": "N1",
    "custom_name": "MyNiuN1",
    "fuel_type": "ELECTRIC",
    "year_of_production": 2020,
    "transmission": "AUTOMATIC",
    "vehicle_type": "MOPED",
    "remark": "Our customers like that scooter very much."
  },
  "capabilities": {
    "commands": [
      "DISABLE_DRIVING",
      "DRAW_ATTENTION",
      "ENABLE_DRIVING",
      "UNLOCK_BATTERY_COMPARTMENT"
    ],
    "vehicle_state": [
      "DRIVING_ENABLED",
      "POSITION",
      "STATE_OF_CHARGE_OR_FUEL_LEVEL_IN_PERCENT"
    ]
  },
  "telematics_unit": {
    "id": "NBSG7D2A50742X0F",
    "attached_at": "2021-01-19T13:13:09.952Z",
    "manufacturer": "NIU",
    "brand": "NIU",
    "type": "EX_FACTORY"
  },
  "life_status": {
    "value": "OFFLINE",
    "modified_at": "2021-01-19T13:13:09.952Z"
  },
  "operation_status": {
    "value": "OPERATING",
    "modified_at": "2021-01-19T13:13:09.952Z"
  },
  "custom_fields_modified_at": "2021-01-19T13:13:09.952Z",
  "custom_fields": {
    "seats": "2",
    "color": "black"
  }
}

How to change the model of an existing vehicle⚓︎

Usually, once a vehicle has been created, the associated vehicle model will not change. However, you may need to change it if you have selected the wrong model during vehicle creation. The Vehicle Lifecycle API provides the PUT /vehicles/:id/telematics-unit/setup endpoint to allow just that. All you need is the ID of the correct vehicle model you would like to use.

Example: Change vehicle model

curl -X PUT \
  'https://api.invers.com/vehicles/JQ7RP/telematics-unit/setup' \
  -H 'Authorization: Bearer ❰access_token❱' \ # (1)!
  -H 'Content-Type: application/json' \
  -d '{
        "vehicle_model_id": "01F4XW6QHWKT4HMSFDZ9CCQH1G"
      }' # (2)!
  1. Don’t forget to fill in your access token.
  2. The body is exactly the same as the object you would use in telematics_unit.setup when creating a vehicle with this model. Hence the name “setup”.

How to remove a vehicle⚓︎

If you want to remove a single vehicle from your fleet, you can use the endpoint DELETE /vehicles/{id} of the Vehicle Lifecycle API (see documentation). Your request will be processed synchronously and the response contains the archived vehicle.

The following example shows the API call to remove a single vehicle:

curl -X DELETE \
  https://api.invers.com/vehicles/JQ7RP \
  -H 'Authorization: Bearer ❰access_token❱' # (1)!
  1. Don’t forget to fill in your access token.

If the request has been successful, HTTP status code 200 will be returned. Here is an example of what the response payload might look like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  "id" : "JQ7RP",
  "archived_at" : "2021-02-17T15:02:09.438Z",
  "snapshot":
  {
    "id": "JQ7RP",
    "fleet_id": "F48XD",
    "created_at": "2021-01-19T13:13:09.952Z",
    "master_data": {
      "modified_at": "2021-01-19T13:13:09.952Z",
      "vin": "R1NBDNB16J1000135",
      "license_plate": "RKL-832",
      "brand": "NIU",
      "model": "N1",
      "custom_name": "MyNiuN1",
      "fuel_type": "ELECTRIC",
      "year_of_production": 2020,
      "transmission": "AUTOMATIC",
      "vehicle_type": "MOPED",
      "remark": "Our customers like that scooter very much."
    },
    "capabilities": {
      "commands": [
        "DISABLE_DRIVING",
        "DRAW_ATTENTION",
        "ENABLE_DRIVING",
        "UNLOCK_BATTERY_COMPARTMENT"
      ],
      "vehicle_state": [
        "DRIVING_ENABLED",
        "POSITION",
        "STATE_OF_CHARGE_OR_FUEL_LEVEL_IN_PERCENT"
      ]
    },
    "telematics_unit": {
      "id": "NBSG7D2A50742X0F",
      "attached_at": "2021-01-19T13:13:09.952Z",
      "manufacturer": "NIU",
      "brand": "NIU",
      "type": "EX_FACTORY"
    },
    "life_status": {
      "value": "OFFLINE",
      "modified_at": "2021-01-19T13:13:09.952Z"
    },
    "operation_status": {
      "value": "OPERATING",
      "modified_at": "2021-01-19T13:13:09.952Z"
    },
    "custom_fields_modified_at": "2021-01-19T13:13:09.952Z",
    "custom_fields": {
      "seats": "2",
      "color": "black"
    }
  }
}

After that, it is still possible to receive information about the archived vehicle via the Vehicle Management API (see documentation). If you do not need the archived vehicle, you can also fully delete it manually. To delete an archived vehicle prematurely, you can use the endpoint DELETE /archived-vehicles/{id}.

Details⚓︎

Telematics units⚓︎

Typically, the telematics manufacturer will give you the ID of the telematics unit that is installed in the vehicle. Depending on the telematics brand, you can conveniently query which telematics units of that brand are available to add to your OneAPI fleet (/telematics-brands/{brand}/available-telematics-units).

Credentials⚓︎

For some of the telematics brands you can use with INVERS OneAPI, an authentication mechanism secures the telematics unit from being used by a malicious person. Usually, this authentication mechanism dictates that certain credentials should be passed along in a certain way in order to communicate with the telematics unit or decode data received from the telematics unit. The manufacturer of the telematics unit or vehicle will provide you with the required credentials or you are able to create and change those on your own (e.g., through the portal of the telematics manufacturer).

The INVERS OneAPI needs to store the credentials in order to communicate with the telematics units built into the vehicles that you plan to connect through OneAPI. For example, whenever a command is sent to a NIU vehicle using the Vehicle Commands API, this command has to be translated and sent to the appropriate endpoint(s) of the NIU API. The INVERS OneAPI has to authenticate at this endpoint using your NIU credentials (in this case, client_id and client_secret).

shared vs. individual credentials

shared credentials

The credentials for vehicles, that are connected through a cloud solution and therefore a third-party API, are typically shared by a group of vehicles. We call this kind of credentials shared credentials.

Storing your (shared) credentials for this third-party API is a necessary step before you can add a CloudConnect vehicle to your fleet.

individual credentials

In some cases, mostly when a direct connection to the telematics unit via TCP is needed, the telematics unit has an individual password. This password needs to be transmitted when communicating with the telematics unit in order for it to do anything. We call this kind of credentials individual credentials.

In this case you don’t need to store any credentials prior to adding your vehicle, but provide the password while adding it.

As stated above, you need to provide the necessary credentials before you add a vehicle to your fleet that is accessed via shared credentials. Please use the Credentials API or the credentials user interface within FleetControl for this. You can provide multiple different credentials for the same third-party API. This enables the use of vehicles that require different credentials for the third-party API in your fleet. For example, NIU vehicles that are part of different NIU fleets can therefore all be part of your single OneAPI fleet.

When storing shared credentials for a third-party API, an ID is generated for them. This ID has to be provided when you add the vehicles associated with those credentials (e.g., via the POST /vehicles endpoint).

Learn more about credentials

Vehicle models⚓︎

In order for the vehicle to behave like the real vehicle, for example like a NIU N1 scooter, you need to provide the brand and model of the vehicle you want to add to your fleet. This ensures that the vehicle has the correct capabilities.

You can view the different vehicle models of a specific telematics brand via GET /telematics-brands/{brand}/available-vehicle-models. Once you have found the right model, you can use its ID in the POST /vehicles request as described above.

Learn more about vehicle models