Skip to content

Upload File

Upload a file to cloud storage and receive a URL. Use this as the first step before saving a document record — pass the returned file_url and bucket_name to that endpoint.

Endpoint

POST /apis/v1/file/upload/unsigned

Content-Type: multipart/form-data

Form Parameters

Parameter Type Required Description
file file Yes The file to upload
bucket_name string Yes Storage bucket name (e.g., us-phy-uploads)
file_path string Yes Folder path within the bucket (e.g., patients/1172416/documents)
file_name string Yes File name to store in the bucket (e.g., insurance-card.pdf)

Request

curl --location '{base_url}/apis/v1/file/upload/unsigned' \
  --header 'Authorization: Bearer JWT_TOKEN' \
  --form 'file=@"/path/to/insurance-card.pdf"' \
  --form 'bucket_name="us-phy-uploads"' \
  --form 'file_path="patients/1172416/documents"' \
  --form 'file_name="insurance-card.pdf"'

Response

Success Response

Code: 200 OK

{
  "code": 2000,
  "data": {
    "file_url": "https://storage.googleapis.com/us-phy-uploads/patients/1172416/documents/insurance-card.pdf",
    "bucket_name": "us-phy-uploads",
    "file_name": "insurance-card.pdf",
    "size_bytes": 204800
  },
  "message": "Success"
}

Response Fields

Field Type Description
file_url string Publicly accessible URL of the uploaded file; pass this as document_url when saving the document record
bucket_name string Bucket where the file was stored; pass this as bucket_name when saving the document record
file_name string Stored file name
size_bytes integer File size in bytes

Error Response

Code: 400 Bad Request

{
  "code": 4000,
  "message": "Error uploading file",
  "data": null
}

Notes

  • After uploading, call Save Document with the returned file_url and bucket_name to create the document record linked to a patient.
  • The file_path should be organized by patient: patients/{patient_id}/documents is a common convention.