Overview
The Residents API allows you to manage resident profiles within the Happy Habitat system. All endpoints require authentication via bearer token with ADMIN_COMPANY or SYSTEM_ADMIN roles. Base URL:/api/Residents
Authentication: Required (Bearer token)
Required Roles: ADMIN_COMPANY, SYSTEM_ADMIN
Get All Residents
Retrieves all residents in the system. Supports optional pagination.
Query Parameters
Page number (1-based). Must be greater than 0. Both page and pageSize must be provided together for pagination.
Number of items per page. Must be greater than 0. Both page and pageSize must be provided together for pagination.
Response
Without pagination - Returns an array of resident objects:Array of resident objects
Array of resident objects (same structure as above)
Total number of residents across all pages
Current page number (1-based)
Number of items per page
Total number of pages available
Example Response
Status Codes
- 200 OK - Residents retrieved successfully
- 401 Unauthorized - Missing or invalid authentication token
- 403 Forbidden - User does not have required role
Get Resident by ID
Retrieves a specific resident by their unique identifier.
Path Parameters
The unique identifier of the resident
Response
Returns a single resident object with the same structure as described in “Get All Residents”.Example Response
Status Codes
- 200 OK - Resident found and returned
- 404 Not Found - Resident with the specified ID does not exist
- 401 Unauthorized - Missing or invalid authentication token
- 403 Forbidden - User does not have required role
Get Residents by Community
Retrieves all residents belonging to a specific community. Supports optional pagination.
Path Parameters
The unique identifier of the community
Query Parameters
Page number (1-based). Must be greater than 0. Both page and pageSize must be provided together for pagination.
Number of items per page. Must be greater than 0. Both page and pageSize must be provided together for pagination.
Response
Returns an array of residents (without pagination) or a paginated result (with pagination). Same structure as “Get All Residents” endpoint.Example Request
Status Codes
- 200 OK - Residents retrieved successfully
- 401 Unauthorized - Missing or invalid authentication token
- 403 Forbidden - User does not have required role
Get Residents by Multiple Communities
Retrieves residents from multiple communities. Returns unique residents by user (no duplicates). Supports optional pagination.
Query Parameters
Array of community IDs. Pass multiple times:
?communityIds=guid1&communityIds=guid2. Returns empty result if not provided.Page number (1-based). Must be greater than 0. Both page and pageSize must be provided together for pagination.
Number of items per page. Must be greater than 0. Both page and pageSize must be provided together for pagination.
Response
Returns an array of unique residents (without pagination) or a paginated result (with pagination). Residents are deduplicated by user ID.Example Request
Status Codes
- 200 OK - Residents retrieved successfully
- 401 Unauthorized - Missing or invalid authentication token
- 403 Forbidden - User does not have required role
Create Resident
Creates a new resident profile. The user ID must exist and not already have an associated resident.
Request Body
Reference to the user account. Must exist and not already have a resident profile.
Reference to the community the resident belongs to (optional)
Full name of the resident. Maximum 200 characters.
Email address. Must be valid email format. Maximum 256 characters.
Phone number. Maximum 50 characters.
Unit or apartment number. Maximum 50 characters.
Physical address. Maximum 500 characters.
Example Request
Response
Returns the created resident object with a generatedid field.
Status Codes
- 201 Created - Resident successfully created (includes Location header with the new resource URL)
- 400 Bad Request - Invalid input data, user doesn’t exist, user already has a resident profile, or invalid community
- 401 Unauthorized - Missing or invalid authentication token
- 403 Forbidden - User does not have required role
Error Response
Update Resident
Updates an existing resident’s information. All fields in the request body are optional.
Path Parameters
The unique identifier of the resident to update
Request Body
All fields are optional. Only include fields you want to update.Update community assignment. Must be valid if provided.
Update full name. Maximum 200 characters.
Update email address. Must be valid email format. Maximum 256 characters.
Update phone number. Maximum 50 characters.
Update unit or apartment number. Maximum 50 characters.
Update physical address. Maximum 500 characters.
Example Request
Response
Returns the updated resident object.Example Response
Status Codes
- 200 OK - Resident successfully updated
- 404 Not Found - Resident with the specified ID does not exist
- 400 Bad Request - Invalid input data
- 401 Unauthorized - Missing or invalid authentication token
- 403 Forbidden - User does not have required role
Delete Resident
Deletes a resident by their unique identifier.
Path Parameters
The unique identifier of the resident to delete
Response
No content returned on successful deletion.Status Codes
- 204 No Content - Resident successfully deleted
- 404 Not Found - Resident with the specified ID does not exist
- 401 Unauthorized - Missing or invalid authentication token
- 403 Forbidden - User does not have required role
Example Request
Error Responses
All endpoints may return the following error responses:401 Unauthorized
The request lacks valid authentication credentials.403 Forbidden
The authenticated user does not have the required role (ADMIN_COMPANY or SYSTEM_ADMIN).400 Bad Request
The request body is invalid or missing required fields.404 Not Found
The requested resource does not exist.Best Practices
Pagination
- Always use pagination for large datasets to improve performance
- Recommended page size: 20-50 items
- Both
pageandpageSizemust be provided together and must be greater than 0
Creating Residents
- Verify the user exists before creating a resident
- Ensure the user doesn’t already have a resident profile
- Validate email format and required fields before submission
- CommunityId is optional but should be provided when known
Updating Residents
- Only include fields you want to update in the request body
- All fields in UpdateResidentDto are optional
- Validate data before submission to avoid bad request errors
Multi-Community Queries
- Use the
/by-communitiesendpoint when managing multiple communities - Returns unique residents (deduplicated by user)
- Ideal for management companies with multiple properties
Error Handling
- Always check response status codes
- Handle 404 errors gracefully (resident not found)
- Parse validation errors from 400 responses to display user-friendly messages
Related Endpoints
- Resident Visits - Manage visitor registrations for residents
- Vehicles - Manage resident vehicles
- Pets - Manage resident pets