Skip to main content

Authentication and roles

Both endpoints require a valid JWT. The POST endpoint additionally requires the technician or admin role. The GET endpoint applies role-based filtering automatically:
  • Admin — sees all inspections across every vehicle and technician.
  • Technician — sees only inspections they personally submitted, regardless of query parameters.

Create inspection


POST /api/inspections Submits a new vehicle inspection. The request must be sent as multipart/form-data because four vehicle photos are required.

Pre-conditions

This endpoint enforces two rules before creating the inspection record:
  1. Active assignment — a technician must have an active assignment for the target vehicle. Admins bypass this check.
  2. Mandatory maintenance — if any mandatory maintenance item is overdue (based on mileage), the inspection is blocked until maintenance is completed.
After a successful inspection, a PDF report is generated and emailed to the fleet admin.

Request body

vehicleId
number
required
ID of the vehicle being inspected.
mileage
number
required
Current odometer reading. Must be a non-negative integer.
photo_front
file
required
Front photo of the vehicle (multipart field name: photo_front).
photo_rear
file
required
Rear photo of the vehicle (multipart field name: photo_rear).
photo_left
file
required
Left-side photo of the vehicle (multipart field name: photo_left).
photo_right
file
required
Right-side photo of the vehicle (multipart field name: photo_right).
internalDamages
string
Description of any internal damage observed.
externalDamages
string
Description of any external damage observed.
nextMaintenanceDate
string
Suggested next maintenance date in ISO 8601 format (YYYY-MM-DD).

Response

Returns 201 Created with a summary of the created inspection and the URL of the generated PDF report.
message
string
Success message.
inspection
object

Errors

StatusDescription
400Validation failed — required fields or photos missing.
401Missing or invalid JWT.
403Technician does not have an active assignment for this vehicle.
404Vehicle not found.
409Vehicle has mandatory maintenance that requires attention before inspection. Returns maintenanceStatus in the response body.
500Internal server error.
curl --request POST \
  --url https://your-api.example.com/api/inspections \
  --header 'Authorization: Bearer <token>' \
  --form 'vehicleId=42' \
  --form 'mileage=15230' \
  --form 'internalDamages=Scratch on dashboard' \
  --form 'externalDamages=Minor dent on rear bumper' \
  --form 'nextMaintenanceDate=2024-07-01' \
  --form 'photo_front=@/path/to/front.jpg' \
  --form 'photo_rear=@/path/to/rear.jpg' \
  --form 'photo_left=@/path/to/left.jpg' \
  --form 'photo_right=@/path/to/right.jpg'

List inspections


GET /api/inspections Returns inspections ordered by creation date (newest first). Each inspection includes the associated vehicle (with fleet) and technician.
Technicians automatically see only their own inspections. The technicianId query parameter has no effect for technician-role requests.

Query parameters

vehicleId
number
Filter results to inspections for a specific vehicle.
technicianId
number
Filter results to inspections submitted by a specific technician. Ignored for technician-role requests (their own ID is always applied).

Response

inspections
object[]

Errors

StatusDescription
401Missing or invalid JWT.
500Internal server error.
curl --request GET \
  --url https://your-api.example.com/api/inspections \
  --header 'Authorization: Bearer <token>'

Build docs developers (and LLMs) love