Skip to main content

About

This guide provides complete implementation details and best practices for integrating the Lab Reports API into your applications. For detailed API specifications and data types, refer to the API Reference.
Authentication: The code examples in this guide focus on the lab report analysis functionality. For authentication implementation details, see the Authentication documentation. You’ll need to add Bearer token into the Authorization header to all API requests.

API Endpoints

The Lab Reports API provides three main endpoints for managing lab reports:

Document Preparation

For optimal document capture guidelines, see the Document Guidelines in the API overview.

POST Request Body

Processing Modes

The processing mode is controlled by the wait_on_process parameter. The API supports two processing modes, each suited for a different use case:

Asynchronous Processing

Returns immediately and processes the document in the background. Ideal for user-facing applications where immediate feedback is important. See the Asynchronous Processing guide for complete implementation details, webhook configuration, and code examples.

Synchronous Processing

Waits for complete analysis before responding. Best for batch processing, server-to-server integrations, or when you can handle longer response times: Request:
Response:

Response Body

Processing Status

Analysis of the lab report progresses through these states:
  • pending — analysis has been queued
  • processing — an AI model is actively analyzing the document
  • completed — analysis finished successfully with results
  • failed — processing failed due to unreadable content or technical issues
REST API responses and webhook notifications will always include the status field.
Webhook notifications can have status field with values completed or failed only. Always handle different response statuses in your application logic.

Error Scenarios

Processing Failures

These occur when the API successfully receives your request but the AI analysis fails. The response will have HTTP 200 status with "status": "failed". When status is failed, check the parsing_error field for specific details:
  • Document not a lab report — a document contains nonmedical content
  • Poor document quality — blurry, dark, or low-resolution images/scans
  • Unreadable text — OCR could not extract reliable text
  • AI processing timeouts — although AI providers typically have fast Response Times, processing may occasionally take longer than expected due to reasons that cannot be foreseen. To manage this, the upload process will time out if synchronous processing takes longer than 3 minutes and asynchronous processing takes longer than 5 minutes.

Request Errors

These occur when there’s an issue with the request itself, returning non-200 HTTP status codes before analysis begins.
  • Decoding File Error — if the file is corrupted or improperly encoded, and therefore cannot be decoded, then HTTP 400 will be returned.
  • Invalid File Format — Lab Reports supports JPEG, PNG, GIF, WebP, and PDF formats. When a file format is not supported, HTTP status code 400 will be returned.
For HTTP status code errors (400, 401, 422, etc.) and general API error handling, see the Error Handling documentation.

Retrieving Results

Getting Results

For asynchronous processing, use webhooks for real-time notifications. See the Asynchronous Processing Guide for complete webhook implementation details. If webhooks are not yet available, you can check status using the GET /lab_reports/{lab_report_id} endpoint. Retrospectively, a list of all uploaded lab reports can be retrieved using the GET /lab_reports endpoint by providing the time range.

Best Practices

1. Choose the Right Processing Mode

  • Asynchronous — for user-facing applications, mobile apps, and when you want immediate feedback
  • Synchronous — for batch processing, server-to-server integrations, and when you can handle longer response times

2. Implement Proper Error Handling

  • Handle network errors gracefully
  • Provide meaningful error messages to users
  • Implement retry logic for transient failures

3. Optimize Document Upload

  • Use high-resolution scans (300+ DPI) for better OCR results
  • Validate document size and format before upload
  • Show upload progress for large documents

Code Examples

Here are complete implementation examples in multiple programming languages:
For complete API specification, data types, and additional parameters, see the POST /lab_reports API Reference.