Heidi API
Sessions
Context

Context

You can provide context for a session by updating the clinician_notes field on the session object, linking previous sessions for a patient or upload attachments to a session.

This field accepts an array of strings. Context can be used to provide additional information about the session, such as the patient's allergies, medications, or other information that may be relevant to the session.

Context provided through the clinician_notes field is freetext, it can be formatted using Markdown.

You can also upload attachments to a session, which will be used as context.


Updated the clinician_notes field

Request

PATCH /sessions/1234567890
Authorization: Bearer <your_token>
Content-Type: application/json
 
{
  "clinician_notes": [
    "Medication history: paracetamol",
    "Allergies: penicillin"
  ],
}

Response

{
  "session": {
    "clinician_notes": [
      "Medication history: paracetamol",
      "Allergies: penicillin"
    ]
  }
}

Link previous sessions

You can link existing sessions for a patient to include that session's consult note as context for your session.

Request

PATCH /sessions/1234567890
Authorization: Bearer <your_token>
Content-Type: application/json
 
{
  "linked_sessions_for_context": [
    "1234567891",
    "1234567892"
  ]
}

Response

{
  "session": {
    "linked_sessions_for_context": [
      "1234567891",
      "1234567892"
    ]
  }
}

Context attachments

You can upload attachments to a session, which will be used as context. Attachments can be .pdf, .jpg, .png, .docx or .doc files.

Upload an attachment

Method: POST

Path: /sessions/{session_id}/context-documents

Description: Add a new attachment to a session's context

Request
POST /sessions/1234567890/context-documents
Authorization: Bearer <your_token>
Content-Type: multipart/form-data

Data to include in the request:

FieldDescription
context_documentsThe binary content of the file
meta_dataA JSON string

The meta_data field should be a JSON string with the following format:

{
  "name": "<file_name>",
  "date": "<current_date_string>",
  "additional_context": "<string to describe the document, or empty>",
  "unstructured": "<true if the document is complex (hand writing, tables, etc), otherwise false>"
}
Response
[
  {
    "id": "6915a524503557f8ea6a08ae",
    "user_id": "68c0df531871d4edd735b629",
    "session_id": "1234567890",
    "name": "file.pdf",
    "date": "2025-02-11T11:01:01",
    "type": null,
    "content": null,
    "status": "PARSING",
    "additional_context": "",
    "unstructured": null
  }
]

List all attachments for a session

Method: GET

Path: /sessions/{session_id}/context-documents

Description: Get a list of all attachments for a session

Request
GET /sessions/1234567890/context-documents
Authorization: Bearer <your_token>
Response
[
  {
    "id": "6915a524503557f8ea6a08ae",
    "user_id": "68c0df531871d4edd735b629",
    "session_id": "1234567890",
    "name": "file.pdf",
    "date": "2025-02-11T11:01:01",
    "type": null,
    "content": null,
    "status": "READY",
    "additional_context": "",
    "unstructured": null
  }
]

Delete an attachment

Method: DELETE

Path: /sessions/{session_id}/context-documents

Description: Delete an attachment from a session

Request
DELETE /sessions/1234567890/context-documents
Authorization: Bearer <your_token>
Content-Type: application/json
{
  "ids": [
    "document_id_1",
    "document_id_2"
  ]
}
Response
{
  "success": true
}