Skip to main content

Overview

The SampleHC API is a RESTful API that allows you to interact with workflows. It is used to start, stop, and manage workflows, as well as to retrieve workflow data.

Client

Workflows created before the client was released may not have the client installed. Please refer to the latest template to see how the client is set up.
If any methods are different/missing from the SDK, you may need to update the SDK version in requirements.txt to the latest version.
A Python SDK is available for ease of calling the SampleHC API. By default, a client manager is included in the new workflow template in src/client_manager.py that automatically configures the client with the correct backend URL and API key. Here is a minimal example of how to use the client manager to initiate a client and call the API in a workflow.

Common Operations

The sections below cover the API operations that come up most often in workflows. Refer to the SampleHC API Reference for the full list of endpoints and parameters.

Extracting Data from Documents

The extract method runs a structured extraction over one or more documents. You provide a prompt and a JSON schema describing the output you want, and the extraction runs asynchronously — so pair it with suspend and resume:
When the workflow resumes, ctx.resume_data contains the extraction output matching your response_json_schema. Optional parameters:
  • model: The extraction model to use.
  • reasoning_effort: "low", "medium", or "high" — controls how much reasoning the extraction applies.
  • priority: "interactive" (default) or "non-interactive". Use "non-interactive" for scheduled or bulk extractions where no user is waiting, so interactive workflows are processed first. The same option is available on classify.
extract is the recommended method for new workflows. It supersedes the legacy.reason and legacy.extract methods you may see in older examples.

Generating Documents from Templates

Document templates (managed in the Sample dashboard) let workflows produce consistent letters and forms. A common flow is to render the template to editable content, let a user review it in a screen, and then generate the final PDF:
On resume, ctx.resume_data["document"] contains the generated document’s id and file name, ready to attach to an email or combine with other documents. To generate directly from template variables without a review step, pass variables to generate_document_async instead of document_body.

Working with Documents

Documents are referenced throughout the API by their file metadata ID (the id field, e.g. fmd_...) together with a fileName. Common utilities:
Other useful utilities:
  • retrieve_metadata(document_id): Get a document’s file name and MIME type.
  • formats.create_pdf(document_id, file_name, mime_type): Convert an image document (PNG, JPEG) to a PDF.
  • transform_json_to_html(json): Render a JSON object as HTML — useful for displaying extraction results in screens or emails.

Sending Communications

Workflows can send emails, faxes, and physical letters. Attachments reference documents by ID:
Use enable_encryption=True on emails that contain protected health information.

Querying Connected Systems

Integrations configured in the Sample dashboard are addressed by their integration slug:
See Integrations for how to connect these systems to your organization.

Running SQL

Use sql_execute to read and write your Sample database from workflow steps:
See the database guide for placeholders, error handling, and the table editor.

Gotchas

Our API generally uses camelCase for parameter names. However, for ease of use, the SDK also converts parameters to snake_case when calling the API. This means ** BOTH ** camelCase and snake_case are supported for parameter names when using the samplehc library. For example, the document metadata endpoint has a parameter called fileName which is converted to file_name in the SDK.
Refer to the SampleHC API Reference for more details on the available endpoints, required parameters, and the expected responses from the SDK.