Skip to main content
An assignment links a technician to a vehicle for a period of active field work. The system tracks assignment status so you always know which vehicles and technicians are currently deployed.

What an assignment is

An assignment record ties one technician (a user with the technician role) to one vehicle. It has two possible statuses:
StatusMeaning
activeThe technician is currently assigned to the vehicle
returnedThe assignment has been closed; the vehicle and technician are available again
The assignedDate is recorded automatically when the assignment is created.

Business rules

The system enforces two hard constraints when creating an assignment:

One active assignment per vehicle

A vehicle can only have one active assignment at a time. Attempting to assign a vehicle that already has an active assignment returns a 409 Conflict error.

One active assignment per technician

A technician can only have one active vehicle assignment at a time. Attempting to assign a technician who is already assigned to another vehicle returns a 409 Conflict error.
Both constraints are lifted as soon as the existing assignment is returned.

Creating an assignment

Assignments are created via the backend API. Send a POST request to the assignments endpoint with the following body:
{
  "vehicleId": 12,
  "technicianId": 5
}
The backend validates that:
  • The vehicle exists.
  • The user exists and has the technician role.
  • Neither the vehicle nor the technician has an existing active assignment.
On success, the API responds with 201 Created and the new assignment object, with status set to "active".
The assignment endpoint is protected by admin authentication. Ensure your request includes a valid Bearer token obtained from the login endpoint.

Returning an assignment

To close an active assignment, send a PATCH request to the return endpoint:
PATCH /api/admin/assignments/:id/return
The backend sets the assignment’s status to "returned". The vehicle and technician are now free to be assigned again. If the assignment is already in returned status, the request is idempotent — the record is returned unchanged with no error.
Returning an assignment does not delete the record. The full assignment history is preserved and remains queryable.

Filtering assignments by status

The list endpoint supports filtering by status via a query parameter:
GET /api/admin/assignments?status=active
Returns all assignments where the technician is currently deployed with a vehicle.
Each assignment record in the response includes the full vehicle object and the technician’s id, name, and email.

Dashboard visibility

The number of currently active assignments is shown on the backend dashboard endpoint under summary.activeAssignments. This count updates in real time as assignments are created and returned.

Build docs developers (and LLMs) love