Get All Documents
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:29ADMIN_COMPANY or SYSTEM_ADMIN role
Response: Array of DocumentDto objects
Get Documents by Community
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:39The community’s unique identifier. If omitted, returns documents with no community association.
ADMIN_COMPANY or SYSTEM_ADMIN role
Response: Array of DocumentDto objects
Get Document by ID
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:49The document’s unique identifier
ADMIN_COMPANY or SYSTEM_ADMIN role
Response: DocumentDto object
Status Codes
200 OK: Document found404 Not Found: Document does not exist
Download Document
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:62The document’s unique identifier
- Requires
ADMIN_COMPANYorSYSTEM_ADMINrole - User must be either:
- A company admin for the document’s community
- The user who uploaded the document
Content-Type header
Status Codes
200 OK: File download successful302 Found: Redirect to external URL or static file location400 Bad Request: Document has no file path401 Unauthorized: User not authenticated403 Forbidden: User lacks permission to download404 Not Found: Document does not exist
- If the file exists on the filesystem, it’s served directly
- If the file is not found but
UrlDocis an absolute URL (http/https), redirects to that URL - Otherwise, constructs and redirects to a static file URL
Create Document
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:128CreateDocumentDto
The community to associate the document with
Document title (max 200 characters)
Document description (max 2000 characters)
Document date
Name or identifier of the user who created it (max 200 characters)
Original file name (max 500 characters)
URL or relative path to the document file (max 1000 characters). Typically the
relativePath from the upload response.The
userId field is automatically set from the authenticated user and should not be provided in the request.ADMIN_COMPANY or SYSTEM_ADMIN role
Response: DocumentDto object with 201 Created status
Status Codes
201 Created: Document successfully created400 Bad Request: Invalid request data or validation error
Update Document
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:148The document’s unique identifier
UpdateDocumentDto
The community to associate the document with
Document title (max 200 characters)
Document description (max 2000 characters)
Document date
Name or identifier of the user who created it (max 200 characters)
Original file name (max 500 characters)
URL or relative path to the document file (max 1000 characters)
ADMIN_COMPANY or SYSTEM_ADMIN role
Response: DocumentDto object
Status Codes
200 OK: Document successfully updated400 Bad Request: Invalid request data or validation error404 Not Found: Document does not exist
Delete Document
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:168The document’s unique identifier
ADMIN_COMPANY or SYSTEM_ADMIN role
Response: No content
Status Codes
204 No Content: Document successfully deleted404 Not Found: Document does not exist
Upload Document File
Source:
HappyHabitat.API/Controllers/DocumentsController.cs:185The file to upload (max 20 MB)
The community’s unique identifier
The resident’s unique identifier. Defaults to “general” if not provided.
Document category (e.g., “contracts”, “reports”, “invoices”). Defaults to “general” if not provided. Only alphanumeric characters, hyphens, and underscores are allowed.
ADMIN_COMPANY or SYSTEM_ADMIN role
Response: DocumentUploadResponse object
The relative path where the file was saved. Use this value for
Document.UrlDoc when creating the document record.The original file name as sent by the client
File size in bytes
200 OK: File uploaded successfully400 Bad Request: No file provided, empty file, or invalid file name500 Internal Server Error: File system error during upload
After uploading a file, use the returned
relativePath as the urlDoc value when creating a document record via POST /api/Documents.Upload Generic File
Source:
HappyHabitat.API/Controllers/FileController.cs:24The file to upload (max 20 MB)
Relative path where the file should be saved (e.g., “uploads/tickets/guid/image.jpg”). Path traversal is not allowed.
DocumentUploadResponse object
The relative path where the file was saved
The original file name as sent by the client
File size in bytes
200 OK: File uploaded successfully400 Bad Request: No file provided, empty file, missing path, or invalid path (path traversal detected)500 Internal Server Error: File system error during upload
- Path traversal attempts are blocked
- The resolved path must be under the application’s content root path
- Paths are normalized to prevent directory traversal attacks
Data Models
DocumentDto
Response model for document operations.CreateDocumentDto
Request model for creating documents.Do not include
userId in the request. It is automatically set from the authenticated user.