Files Service
Overview
Files represent attachments linked to entities (customers or suppliers). They support document storage, file metadata management, and categorization.
Files are used for:
- document attachments
- image storage
- contract and agreement files
- any entity-related resources
All file operations are tenant-aware and scoped to the current tenant.
Endpoints
GET
/api/v1/Files/{id}
Returns a single file by its numeric identifier.
Path parameters:
id(long, required) - file identifier
Behavior:
- Looks up file by ID
- Returns
404if the file does not exist
Authorization:
- Anonymous access allowed (requires valid domain in request headers)
GET
/api/v1/Files/entity/{entityId}
Returns all files for a specific entity.
Path parameters:
entityId(long, required) - entity identifier
Behavior:
- Returns all files linked to the entity
- Returns
404if no files exist for the entity
Authorization:
- Anonymous access allowed (requires valid domain in request headers)
POST
/api/v1/Files
Creates a new file record.
Request body:
EntityId(long, required) - associated entityFileName(string, required) - file nameDescription(string, optional) - file descriptionFileURL(string, optional) - URL or path to the fileFileType(long, optional) - file type identifier
Behavior:
- Validation is handled in the service layer
CreatedAtis set automatically- Successful creation writes an audit log entry
Errors:
- Returns
400if validation fails
Authorization:
- Requires Bearer Token
PUT
/api/v1/Files/{id}
Updates an existing file record.
Request:
- File ID is taken from the route
- Body must include:
EntityId(long, required)FileName(string, required)
- Optional:
Description(string)FileURL(string)FileType(long)
Behavior:
UpdatedAtis set automatically- Successful update writes an audit log entry
Errors:
- Returns
400if validation fails or file does not exist
Authorization:
- Requires Bearer Token
DELETE
/api/v1/Files/{id}
Deletes a file record by its identifier.
Behavior:
- Performs a hard delete
- Record is permanently removed from the database
- Does not delete the actual file from storage
- Successful deletion writes an audit log entry
Errors:
- Returns
400if file does not exist
Authorization:
- Requires Bearer Token
Notes
- Files are linked to entities via
EntityId - File storage is managed externally; this API manages metadata only
- Validation is enforced in the service layer
- All state-changing operations are audited
- Internal errors are logged but not exposed to clients