Skip to main content

Uploading Files

Some APIs accept file attachments, such as lab test reports. Instead of sending the file inside the request, you first upload it to the Inspectorio File Service and then reference it by its fileId.

How it works​

1. Create an upload session​

Use the Create File Upload Session endpoint with your API key. The file name must be unique for your organization.

curl --request POST \
--url "https://sight.inspectorio.com/api/v1/file-upload-session" \
--header "apiKey: <YOUR_API_KEY>" \
--header "Content-Type: application/json" \
--data '{"fileName": "lab-report-2026-001.pdf"}'

The response contains the upload URL and the time until which it is valid:

{
"data": {
"uploadSession": "<UPLOAD_URL>",
"expiryTime": "2026-09-25T10:03:00.183881+00:00"
}
}

2. Upload the file​

Upload the file with the Upload File endpoint of the File Service before the session expires. Send it as multipart/form-data in a field named file.

curl --request POST \
--url "<UPLOAD_URL>" \

A successful upload returns 201 with the file details, including the fileId:

{
"data": {
"fileId": "<FILE_ID>",
"fileName": "lab-report-2026-001.pdf",
"contentType": "application/pdf",
"fileSize": 184320
}
}

3. Reference the file​

Use the fileId in the request that needs the attachment. For example:

See Lab Tests - Create or Update a Test for the full flow.

Tips​

  • Create a new upload session for each file.
  • If the session has expired, create a new one.
  • The File Service has its own host. See Environments and Base URLs.