Skip to main content
POST
/
cases
/
upload
Upload File
curl --request POST \
  --url https://api.example.com/cases/upload \
  --header 'Content-Type: application/json' \
  --data '{
  "case_id": 123
}'
{
  "message": "<string>",
  "file": {
    "file.file_id": "<string>",
    "file.case_id": 123,
    "file.file_name": "<string>",
    "file.file_type": "<string>",
    "file.file_size": 123,
    "file.file_url": "<string>",
    "file.uploaded_at": "<string>"
  },
  "404 Not Found": {},
  "400 Bad Request": {},
  "500 Internal Server Error": {}
}

Authentication

This endpoint requires authentication. The user_id is automatically retrieved from the authenticated session.

Request Body

This endpoint accepts multipart/form-data for file upload.
case_id
integer
required
The ID of the case to which the file should be attached
file
file
required
The file to upload (PDF, image, or other medical document)

Response

message
string
Success message indicating the file was uploaded
file
object
The uploaded file object with metadata
file.file_id
string
Unique identifier for the uploaded file
file.case_id
integer
ID of the case the file is attached to
file.file_name
string
Original filename
file.file_type
string
MIME type of the file
file.file_size
integer
File size in bytes
file.file_url
string
URL path to access the file
file.uploaded_at
string
Timestamp when the file was uploaded

Example Request

curl -X POST "https://api.medmitra.com/cases/upload" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "case_id=12345" \
  -F "file=@/path/to/document.pdf"

Example Response

{
  "message": "File uploaded successfully",
  "file": {
    "file_id": "f9e8d7c6-5432-10fe-dcba-0987654321ab",
    "case_id": 12345,
    "file_name": "document.pdf",
    "file_type": "application/pdf",
    "file_size": 1234567,
    "file_url": "/files/12345/document.pdf",
    "uploaded_at": "2026-03-04T14:30:00Z"
  }
}

Error Responses

404 Not Found
error
Case with the specified ID was not found or does not belong to the user
{
  "detail": "Case not found"
}
400 Bad Request
error
Invalid request data or file upload error
{
  "detail": "Error message describing the issue"
}
500 Internal Server Error
error
Server error during file upload
{
  "detail": "Internal server error: {error details}"
}

Supported File Types

The following file types are commonly supported:
  • Documents: PDF (.pdf), Word (.doc, .docx), Text (.txt)
  • Images: JPEG (.jpg, .jpeg), PNG (.png), DICOM (.dcm)
  • Medical Reports: Lab reports, radiology reports, prescriptions

Notes

  • Files are stored in cloud storage (Supabase Storage)
  • The endpoint verifies that the case exists and belongs to the authenticated user before allowing upload
  • Maximum file size limits may apply (check your server configuration)
  • File metadata is stored in the database for quick retrieval
  • Uploaded files can be retrieved using the Get Files endpoint

Build docs developers (and LLMs) love