Files API
The Files API is used to retrieve and delete uploaded files associated with entities such as patients, doctors, appointments, and other records.
Backend folder:
app/file/
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /static/{file_path} | Retrieve file |
| DELETE | /static/delete_file/{file_id} | Delete file |
File Object
A file object represents an uploaded file associated with a system entity.
Example
{
"id": "019ec9e8-d2b4-77ff-be43-525f928a5de3",
"type": "document",
"mime_type": ".png",
"entity_id": "019ec9e7-70fc-70e1-9be7-039fdb5efc3e",
"url": "https://api-core.aayutech.dev/static/019ec9e7-70fc-70e1-9be7-039fdb5efc3e/019ec9e8-d2b4-77ff-be43-525f928a5de3.png"
}
Field Notes
| Field | Type | Description |
|---|---|---|
id | UUID | Unique file identifier |
type | string | File category |
mime_type | string | File extension |
entity_id | UUID | ID of the entity that owns the file |
url | string | Public URL used to access the file |
Retrieve File
GET /static/{file_path}
Returns the requested file.
This endpoint is typically used to access profile images, reports, prescriptions, scanned documents, and other uploaded files.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
file_path | string | File storage path |
Example Request
GET /static/019ec9e7-70fc-70e1-9be7-039fdb5efc3e/019ec9e8-d2b4-77ff-be43-525f928a5de3.png
Example URL
https://api-core.aayutech.dev/static/019ec9e7-70fc-70e1-9be7-039fdb5efc3e/019ec9e8-d2b4-77ff-be43-525f928a5de3.png
Response
Returns the file content directly.
Example file types:
image/png
image/jpeg
application/pdf
application/msword
application/vnd.openxmlformats-officedocument.wordprocessingml.document
Successful Response
Binary file response
Delete File
DELETE /static/delete_file/{file_id}
Deletes a file from the system.
Once deleted, the file will no longer be accessible through the file URL.
Path Parameter
| Parameter | Type | Description |
|---|---|---|
file_id | UUID | File ID |
Example Request
DELETE /static/delete_file/019ec9e8-d2b4-77ff-be43-525f928a5de3
Response Example
"File deleted successfully"
File Usage Example
Files are commonly returned in entity responses.
Example Patient Response
{
"id": "019ec9e7-70fc-70e1-9be7-039fdb5efc3e",
"reg_number": "PAT-001",
"first_name": "John",
"last_name": "Doe",
"files": [
{
"id": "019ec9e8-d2b4-77ff-be43-525f928a5de3",
"type": "document",
"mime_type": ".png",
"entity_id": "019ec9e7-70fc-70e1-9be7-039fdb5efc3e",
"url": "https://api-core.aayutech.dev/static/019ec9e7-70fc-70e1-9be7-039fdb5efc3e/019ec9e8-d2b4-77ff-be43-525f928a5de3.png"
},
{
"id": "019ec9ea-f0d9-7336-9b1b-90fecb506c38",
"type": "document",
"mime_type": ".png",
"entity_id": "019ec9e7-70fc-70e1-9be7-039fdb5efc3e",
"url": "https://api-core.aayutech.dev/static/019ec9e7-70fc-70e1-9be7-039fdb5efc3e/019ec9ea-f0d9-7336-9b1b-90fecb506c38.png"
}
]
}
Display Image
<img src="FILE_URL" alt="Patient File" />
Open File
<a href="FILE_URL" target="_blank">
View File
</a>
Download File
<a href="FILE_URL" download>
Download File
</a>
Possible Responses
| Status Code | Meaning |
|---|---|
| 200 | Request successful |
| 401 | Not authenticated |
| 403 | Permission denied |
| 404 | File not found |
| 422 | Validation error |
Validation Error
{
"detail": [
{
"loc": [
"path",
"file_id"
],
"msg": "Input should be a valid UUID",
"type": "uuid_parsing"
}
]
}
Notes
- Files can be associated with patients, doctors, appointments, and other entities.
- The
urlfield provides direct access to the file. - The file endpoint returns the actual file content rather than JSON metadata.
- Deleted files cannot be accessed after successful deletion.
- Multiple files can be associated with a single entity.
- File URLs can be used directly by web, mobile, and desktop applications.