Overview
The Pets API allows you to manage pet registrations for residents in the Happy Habitat system. All endpoints require authentication via bearer token. Base URL:/api/pets
Authentication: Required (Bearer token)
Get All Pets
Retrieves all pets in the system.
Response
Array of pet objects
Example Response
Get Pet by ID
Retrieves a specific pet by its unique identifier.
Path Parameters
The unique identifier of the pet
Response
Returns a single pet object with the same structure as described above.Status Codes
- 200 OK - Pet found and returned
- 404 Not Found - Pet with the specified ID does not exist
Example Response
Get Pets by Resident
Retrieves all pets belonging to a specific resident.
Path Parameters
The unique identifier of the resident
Response
Returns an array of pet objects associated with the specified resident.Example Response
Create Pet
Creates a new pet registration.
Request Body
ID of the resident who owns the pet
Pet’s name
Pet species (e.g., Dog, Cat, Bird, Fish)
Pet breed or type
Pet’s age in years
Pet’s color or distinctive markings
Example Request
Response
Returns the created pet object with a generatedid and createdAt field.
Status Codes
- 201 Created - Pet successfully registered
- 400 Bad Request - Invalid input data
Example Response
Update Pet
Updates an existing pet’s information.
Path Parameters
The unique identifier of the pet to update
Request Body
ID of the resident who owns the pet
Pet’s name
Pet species
Pet breed
Pet’s age in years
Pet’s color or markings
Example Request
Response
Returns the updated pet object.Status Codes
- 200 OK - Pet successfully updated
- 404 Not Found - Pet with the specified ID does not exist
- 400 Bad Request - Invalid input data
Example Response
Delete Pet
Deletes a pet from the system.
Path Parameters
The unique identifier of the pet to delete
Response
No content returned on successful deletion.Status Codes
- 204 No Content - Pet successfully deleted
- 404 Not Found - Pet 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 pet operations require proper authentication
- The resident must exist before registering a pet
- Age is stored in years; use 0 for pets less than one year old
- Consider community pet policies when registering pets
- Multiple pets can be registered per resident
- The
createdAttimestamp is automatically generated upon creation