iotoms Docs

Assign users to a vehicle

PUT
/api/v1/ops/vehicles/{vehicleId}/assign

Assigns one or more users to an active vehicle, given as a map of role to user id in assignedUsers. Fails if the vehicle is inactive or no assignee is supplied.

How to use it

  1. Pick an ACTIVE vehicle from List vehicles and users from List users assignable to vehicles.
  2. Send assignedUsers as a map of role to user id, e.g. {"DRIVER": 42}; roles are stored in upper case.
  3. Each role's previous holder on this vehicle is replaced, and each user's earlier assignment in the same role on another vehicle ends.

Authorization

BearerAuth
headerAuthorizationBearer <JWT>

Path Parameters

vehicleId*string

Vehicle identifier of an ACTIVE vehicle, from List vehicles.

Formatuuid

Header Parameters

Request Body

application/json
  1. body
assignedUsers*

Map of assignment role to user id, e.g. {"DRIVER": 42}. User ids come from List users assignable to vehicles. At least one entry is required.

Response Body

OK

*/*
  1. response
status*string

Outcome of the call: SUCCESS when the request was handled, ERROR otherwise.

message*string

Short human-readable message describing the outcome, e.g. which record was fetched or saved.

data?

The vehicle and the users now assigned to it.

Example Request
curl -X PUT 'https://beta.iotoms.com/api/v1/ops/vehicles/497f6eca-6276-4993-bfeb-53cbbbba6f08/assign' \  -H 'Content-Type: application/json' \  -d '{  "assignedUsers": {    "property1": 0,    "property2": 0  }}'
Example Response
{  "status": "string",  "message": "string",  "data": {    "vehicle": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "vehicleNumber": "string",      "vehicleLabel": "string",      "vehicleType": "VAN",      "status": "ACTIVE",      "lastOdometerKm": 0,      "notes": "string",      "assignment": {        "property1": {          "assignmentId": "dbf5135c-beb7-4185-80db-2e980c77381b",          "userId": 0,          "username": "string",          "assignmentRole": "string",          "assignedAt": "2019-08-24T14:15:22Z",          "assignedBy": "string",          "isActive": true        },        "property2": {          "assignmentId": "dbf5135c-beb7-4185-80db-2e980c77381b",          "userId": 0,          "username": "string",          "assignmentRole": "string",          "assignedAt": "2019-08-24T14:15:22Z",          "assignedBy": "string",          "isActive": true        }      }    },    "assignedUsers": {      "property1": {        "assignmentId": "dbf5135c-beb7-4185-80db-2e980c77381b",        "userId": 0,        "username": "string",        "assignmentRole": "string",        "assignedAt": "2019-08-24T14:15:22Z",        "assignedBy": "string",        "isActive": true      },      "property2": {        "assignmentId": "dbf5135c-beb7-4185-80db-2e980c77381b",        "userId": 0,        "username": "string",        "assignmentRole": "string",        "assignedAt": "2019-08-24T14:15:22Z",        "assignedBy": "string",        "isActive": true      }    }  }}