Skip to main content

Overview

Download the medical document file associated with a specific appointment in MediSync. This endpoint retrieves the actual PDF file content and returns it with appropriate headers for download or viewing.
File Download: This endpoint returns the actual PDF file content, not just document metadata. Use the list endpoint to get document information first.

Authentication

curl -X GET \
  'https://app.medisync.me/api/documents/get/65f1a2b3c4d5e6f7g8h9i0j1' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  --output medical_document.pdf

Path Parameters

id
string
required
The appointment ID to download the document for

Response

Successful Download

Returns the PDF file as binary data with appropriate headers:
Content-Type
header
Set to application/pdf for PDF file downloads
Content-Disposition
header
Attachment header with the original filename (without appointment ID prefix)

Error Response (JSON)

When the document is not found or an error occurs:
success
boolean
Whether the request was successful (always false for errors)
error
string
Error message describing what went wrong

Response Examples

Successful Download Headers

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="lab_results.pdf"
Content-Length: 156789

[Binary PDF data]

Document Not Found Error

{
  "success": false,
  "error": "Document not found"
}

Storage Error

{
  "success": false,
  "error": "Failed to retrieve document content from storage"
}

Business Logic

  1. Appointment-Based Access: Documents are accessed using the appointment ID, not the document ID directly.
  2. File Streaming: Large PDF files are streamed efficiently to handle documents of various sizes.
  3. Original Filename: The downloaded file uses the original filename without the appointment ID prefix.
  4. Secure Storage: Files are retrieved from Telekom’s secure cloud storage with proper access controls.

Error Handling

  • 404 Not Found: Document does not exist for the specified appointment ID
  • 401 Unauthorized: Invalid or missing authentication token
  • 500 Internal Server Error: Storage retrieval error or empty file content

Notes

  • Only returns PDF files as stored in the system
  • Filename in Content-Disposition header is cleaned of the appointment ID prefix
  • Large files are handled efficiently through streaming
  • Document access is logged for audit purposes
  • Empty or corrupted files from storage will result in a 500 error