Overview
The Vehicles API allows you to manage vehicle registrations for residents in the Happy Habitat system. All endpoints require authentication via bearer token. Base URL:/api/vehicles
Authentication: Required (Bearer token)
Get All Vehicles
Retrieves all vehicles in the system.
Response
Array of vehicle objects
Example Response
Get Vehicle by ID
Retrieves a specific vehicle by its unique identifier.
Path Parameters
The unique identifier of the vehicle
Response
Returns a single vehicle object with the same structure as described above.Status Codes
- 200 OK - Vehicle found and returned
- 404 Not Found - Vehicle with the specified ID does not exist
Example Response
Get Vehicles by Resident
Retrieves all vehicles belonging to a specific resident.
Path Parameters
The unique identifier of the resident
Response
Returns an array of vehicle objects associated with the specified resident.Example Response
Create Vehicle
Creates a new vehicle registration.
Request Body
ID of the resident who owns the vehicle
Vehicle manufacturer brand
ID of the vehicle type
Vehicle model name
Manufacturing year
Vehicle color
License plate number (must be unique)
Example Request
Response
Returns the created vehicle object with a generatedid and createdAt field.
Status Codes
- 201 Created - Vehicle successfully created
- 400 Bad Request - Invalid input data or duplicate license plate
Example Response
Update Vehicle
Updates an existing vehicle’s information.
Path Parameters
The unique identifier of the vehicle to update
Request Body
ID of the resident who owns the vehicle
Vehicle manufacturer brand
ID of the vehicle type
Vehicle model name
Manufacturing year
Vehicle color
License plate number
Example Request
Response
Returns the updated vehicle object.Status Codes
- 200 OK - Vehicle successfully updated
- 404 Not Found - Vehicle with the specified ID does not exist
- 400 Bad Request - Invalid input data
Example Response
Delete Vehicle
Deletes a vehicle from the system.
Path Parameters
The unique identifier of the vehicle to delete
Response
No content returned on successful deletion.Status Codes
- 204 No Content - Vehicle successfully deleted
- 404 Not Found - Vehicle with the specified ID does not exist
Error Responses
All endpoints may return the following error responses:401 Unauthorized
400 Bad Request
404 Not Found
Notes
- All vehicle operations require proper authentication
- License plates must be unique across the system
- Vehicle types must exist in the system before creating a vehicle
- The resident must exist before registering a vehicle
- The
createdAttimestamp is automatically generated upon creation