All vehicle endpoints are protected. Requests must include a valid JWT and the authenticated user must have the
admin role.Endpoints that accept file uploads (
POST /api/admin/vehicles and PUT /api/admin/vehicles/:id) must use multipart/form-data encoding. All other endpoints accept application/json.List vehicles
GET /api/admin/vehicles
Returns all vehicles ordered by creation date (newest first). Use the optional fleetId query parameter to filter by fleet.
Query parameters
Filter results to vehicles belonging to this fleet ID.
Response
Errors
| Status | Description |
|---|---|
401 | Missing or invalid JWT. |
403 | Authenticated user does not have the admin role. |
500 | Internal server error. |
Create vehicle
POST /api/admin/vehicles
Creates a new vehicle. Send the request as multipart/form-data to optionally attach document files.
Request body
Vehicle manufacturer.
Vehicle model name.
License plate number. Stored in uppercase.
ID of the fleet this vehicle belongs to.
Model year (e.g.,
2023).License status. One of
active or expired.Odometer unit. One of
km or mi.Distance between scheduled maintenance events.
Insurance expiry date. Accepted formats:
YYYY-MM-DD or DD-MM-YYYY.Insurance document file upload (multipart field name:
insurance_doc).Registration document file upload (multipart field name:
registration_doc).Response
Returns201 Created with the new vehicle object.
The created vehicle with all fields as described in List vehicles.
Errors
| Status | Description |
|---|---|
400 | Validation failed — required fields missing or invalid values. |
401 | Missing or invalid JWT. |
403 | Authenticated user does not have the admin role. |
500 | Internal server error. |
Get vehicle
GET /api/admin/vehicles/:id
Returns a single vehicle by ID along with its current maintenance status.
Path parameters
The vehicle ID.
Response
Vehicle object with the same shape as described in List vehicles.
Errors
| Status | Description |
|---|---|
401 | Missing or invalid JWT. |
403 | Authenticated user does not have the admin role. |
404 | Vehicle not found. |
500 | Internal server error. |
Update vehicle
PUT /api/admin/vehicles/:id
Updates an existing vehicle. Send as multipart/form-data when uploading new document files.
File fields are optional on update. If a file field is omitted, the existing stored URL is preserved. Pass an explicit empty string for insuranceDocUrl or registrationDocUrl in the body to clear the stored URL without uploading a new file.
Path parameters
The vehicle ID.
Request body
Accepts the same fields as Create vehicle. All fields are optional on update.Response
Returns200 OK with the updated vehicle object.
Updated vehicle object.
Errors
| Status | Description |
|---|---|
400 | Validation failed. |
401 | Missing or invalid JWT. |
403 | Authenticated user does not have the admin role. |
404 | Vehicle not found. |
500 | Internal server error. |
Delete vehicle
DELETE /api/admin/vehicles/:id
Permanently deletes a vehicle.
Path parameters
The vehicle ID.
Response
Returns204 No Content on success with an empty body.
Errors
| Status | Description |
|---|---|
401 | Missing or invalid JWT. |
403 | Authenticated user does not have the admin role. |
404 | Vehicle not found. |
500 | Internal server error. |