Soft delete a vehicle from the fleet
DELETE/company/vehicles/:id
Marks a vehicle as deleted (soft delete) from the company's fleet.
Objective
Enable companies to remove vehicles from active use while maintaining audit trail and historical data integrity.
Use Cases
- Remove sold or decommissioned vehicles from active fleet
- Archive old vehicles while preserving historical records
- Clean up vehicle list without losing data
Soft Delete Behavior
This endpoint performs a soft delete using the mongoose-delete plugin:
- The vehicle is NOT permanently deleted from the database
- The field
deletedis set totrue - The field
deletedAtis set to the current timestamp - The vehicle is removed from the company's vehicles array
- Data remains in the database for audit and recovery purposes
IMPORTANT: This is NOT a permanent deletion. The vehicle can potentially be recovered by database administrators if needed.
Side Effects
- Updates the company model to remove the vehicle reference from the vehicles array
- The vehicle will no longer appear in fleet listings
Note: Currently, there is no ownership validation in this endpoint. Any authenticated user can delete any vehicle if they know the ID. This may be a security concern.
Request
Responses
- 200
- 401
- 404
Vehicle deleted successfully (soft delete)
Response Headers
Cannot delete vehicle or general error
Company or vehicle not found