Clinia
API Reference

REST API

Complete HTTP API reference for patient management, VFS access, data ingestion, and pipeline inspection.

REST API

Base URL

https://api.<workspace-id>.clinia.cloud

Replace <workspace-id> with your workspace identifier.

All patient-scoped routes are prefixed with /patients/{patientId}.

The MCP tools (browse_patient, read_patient, search_patient, get_patient_info) are not part of this spec. See MCP Tools for those.

Authentication

All requests require an API key header:

X-Clinia-API-Key: <clinia-api-key>

Patients

Patient registry management. A patient is created implicitly on first ingest and is identified by a registry key chosen by the caller.

List all patients

GET /patients

Returns all patients currently loaded in the server registry. An empty array is returned if no patients have been ingested yet.

Response 200

Array of PatientRegistryEntry objects.

curl "https://api.<workspace-id>.clinia.cloud/patients" \
  -H "X-Clinia-API-Key: <clinia-api-key>"
[
  {
    "registryKey": "jane-smith",
    "patient": {
      "id": "p-001",
      "name": "Jane Smith",
      "birthDate": "1968-04-12",
      "gender": "female"
    },
    "ready": true,
    "stats": { "entities": 18, "events": 11, "relationships": 22, "warnings": 1, "loadMs": 840 }
  }
]

Get patient

GET /patients/{patientId}

Returns demographics and pipeline statistics for a single registered patient.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Response 200 (PatientDetail)

Response 404 (ErrorResponse, patient not found or no data ingested yet)

curl "https://api.<workspace-id>.clinia.cloud/patients/{patientId}" \
  -H "X-Clinia-API-Key: <clinia-api-key>"
{
  "id": "p-001",
  "name": "Jane Smith",
  "birthDate": "1968-04-12",
  "gender": "female",
  "stats": { "entities": 18, "events": 11, "relationships": 22, "warnings": 1, "loadMs": 840 }
}

Delete patient

DELETE /patients/{patientId}

Removes all in-memory state for the patient including the resolved graph, event store, and search index. Does not delete cache files on disk. Use Reset patient to also clear the cache. Safe to call on a patient that does not exist (existed will be false).

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Response 200

FieldTypeDescription
okbooleanAlways true when the request processed without error
existedbooleantrue if the patient was present and removed; false if the key was not found
curl -X DELETE "https://api.<workspace-id>.clinia.cloud/patients/{patientId}" \
  -H "X-Clinia-API-Key: <clinia-api-key>"
{ "ok": true, "existed": true }

VFS

Browse and read the resolved patient graph through a path-based filesystem metaphor. Content is materialized lazily on each request from the live graph. Nothing is stored as pre-rendered files.

Slugs in path segments are derived from entity display names: lowercased, spaces and special characters replaced with underscores.

Browse VFS

GET /patients/{patientId}/vfs

Returns a directory listing with one-line previews for each entry, or file content if the path resolves to a leaf file. Omit the path parameter to browse the patient root.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Query parameters

ParameterTypeDefaultDescription
pathstring/VFS path relative to the patient root (e.g. /conditions/active)

Supported path schema

PathReturns
/Patient root: top-level category directories
/conditions/active/ and resolved/ subdirectories
/conditions/{active|resolved}/List of condition slugs
/conditions/{active|resolved}/{slug}/_story.md and _raw.json entries
/medications/current/ and discontinued/ subdirectories
/medications/{current|discontinued}/{slug}Medication detail entries
/labs/latestMost recent value per LOINC code
/labs/trends/{loinc-slug}Time series for a specific lab
/timeline/List of years with events
/timeline/{year}/Events in a given year
/allergies/List of allergy slugs
/family_history/List of family history slugs
/sources/List of source document slugs
/sources/{doc-slug}Document metadata and narrative sections
/memory/Agent-accumulated facts and insights

Response 200 (BrowseResult)

Response 404 (ErrorResponse, path not found)

curl "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/vfs?path=/conditions/active" \
  -H "X-Clinia-API-Key: <clinia-api-key>"
{
  "path": "/patient/jane-smith/conditions/active",
  "type": "directory",
  "children": [
    { "name": "type_2_diabetes_mellitus", "type": "directory", "preview": "active since 2016" },
    {
      "name": "chronic_kidney_disease_stage_3",
      "type": "directory",
      "preview": "active since 2019"
    }
  ]
}

Read VFS path

GET /patients/{patientId}/read

Returns the rendered content of a specific VFS file. The format parameter controls output verbosity.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Query parameters

ParameterTypeDefaultDescription
pathstring(required)VFS file path relative to the patient root (e.g. /conditions/active/type_2_diabetes_mellitus/_story.md)
formatnarrative | structured | compactnarrativeOutput verbosity level (see below)
token_budgetintegernoneApproximate upper bound on output length in tokens (1 token ≈ 4 characters). Truncates output to fit.

Format values

ValueOutputApprox. tokensBest for
narrativeProse Markdown with full clinical context300–800Agent reasoning over the complete picture
structuredJSON with all entity fields, codes, provenance, and relationships200–500Programmatic field access
compactKey facts in minimal prose50–150Scanning many entities quickly

Notable file paths

PathDescription
/conditions/{status}/{slug}/_story.mdFull longitudinal condition narrative: onset, active medications with dosage, monitoring labs with trend, complications, comorbidities, and timeline. Highest-value path for multi-hop clinical questions.
/conditions/{status}/{slug}/_raw.jsonRaw ClinicalEntity JSON plus all typed relationships to and from this entity
/labs/latestMost recent lab value per LOINC code across all lab entities
/labs/trends/{loinc-slug}Full chronological time series for a single LOINC code with computed trend direction

Response 200

FieldTypeDescription
contentstringRendered content in the requested format

Response 404 (ErrorResponse, path not found)

curl "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/read?path=/conditions/active/type_2_diabetes_mellitus/_story.md" \
  -H "X-Clinia-API-Key: <clinia-api-key>"

Ingest

Submit clinical data for entity resolution. The resolution pipeline runs synchronously after each ingest call. Data is immediately queryable when the response returns. Calling an ingest endpoint multiple times on the same patient accumulates sources; each call re-runs the full resolution pipeline over all accumulated data.

Batch ingest

POST /patients/{patientId}/ingest

Submits FHIR, CDA, and/or document metadata in a single call. More efficient than three separate calls because the resolution pipeline runs only once. At least one of fhir, cda, or documents must be present.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key (created on first ingest)

Request body: BatchIngestRequest

Response 200 (IngestResult)

curl -X POST "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/ingest" \
  -H "X-Clinia-API-Key: <clinia-api-key>" \
  -H "Content-Type: application/json" \
  -d '{ "fhir": [{ "resourceType": "Bundle", "entry": [] }], "cda": ["<ClinicalDocument>...</ClinicalDocument>"] }'

Ingest FHIR

POST /patients/{patientId}/ingest/fhir

Accepts a FHIR R4 Bundle or a single FHIR resource. If a Bundle is passed, all entries in bundle.entry[].resource are processed. Single resources are wrapped in a synthetic bundle internally.

Supported resource types: Patient, Condition, MedicationStatement, Observation, Encounter, AllergyIntolerance, Coverage, Procedure, Immunization, FamilyMemberHistory, DocumentReference, DiagnosticReport.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Request body: A FHIR R4 Bundle or any supported single FHIR resource (JSON). Additional FHIR properties are passed through without validation. The FHIR connector handles structural parsing and emits warnings for unrecognised fields.

Response 200 (IngestResult)

curl -X POST "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/ingest/fhir" \
  -H "X-Clinia-API-Key: <clinia-api-key>" \
  -H "Content-Type: application/json" \
  -d @bundle.json

Ingest CDA

POST /patients/{patientId}/ingest/cda

Accepts a CDA or C-CDA XML document as a raw string. Sections are identified by LOINC code. Sections with narrative text but no structured entries are extracted as NarrativeSection objects and stored for source browsing.

Supported section types: Problems, Medications, Allergies, Results, Vitals, Encounters, Procedures, Payers, Advance Directives.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Request body: CDA or C-CDA XML document as a raw string. Content-Type: text/xml or text/plain.

Response 200 (IngestResult)

curl -X POST "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/ingest/cda" \
  -H "X-Clinia-API-Key: <clinia-api-key>" \
  -H "Content-Type: text/xml" \
  --data-binary @summary.xml

Ingest document

POST /patients/{patientId}/ingest/document

Registers a PDF, image, or other unstructured file by metadata only (no file bytes are uploaded). Creates a DocumentNode indexed in the full-text search store, making the document discoverable in the VFS at /sources/ even though its content is not parsed. Useful for maintaining provenance references to documents that exist outside the system.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Request body: DocumentMetadata

Response 200 (IngestResult)

curl -X POST "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/ingest/document" \
  -H "X-Clinia-API-Key: <clinia-api-key>" \
  -H "Content-Type: application/json" \
  -d '{ "name": "scan_20230801.pdf", "mimeType": "application/pdf" }'

Reset patient

POST /patients/{patientId}/ingest/reset

Removes all ingested data, the resolved graph, the event store, the search index, and any cached pipeline output files on disk. Also removes the patient registry entry. Equivalent to DELETE /patients/{patientId} plus cache file deletion. Use before re-ingesting a corrected data set from scratch.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Response 200

FieldTypeDescription
okbooleanAlways true when the reset completed without error
curl -X POST "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/ingest/reset" \
  -H "X-Clinia-API-Key: <clinia-api-key>"

Get ingest status

GET /patients/{patientId}/ingest/status

Returns whether data has been ingested and the pipeline has run, current pipeline statistics, and all ExtractionWarning objects emitted during the most recent ingest. Use this to diagnose missing entities. Warnings indicate why a resource was not extracted.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Response 200 (IngestStatus)

curl "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/ingest/status" \
  -H "X-Clinia-API-Key: <clinia-api-key>"
{
  "ready": true,
  "sources": [
    {
      "label": "FHIR Bundle",
      "stats": { "itemsScanned": 42, "entitiesExtracted": 12, "eventsExtracted": 8 }
    },
    {
      "label": "Summary_20230907.xml",
      "stats": { "itemsScanned": 28, "entitiesExtracted": 9, "eventsExtracted": 4 }
    }
  ],
  "patient": { "id": "p-001", "name": "Jane Smith" },
  "loadStats": { "entitiesExtracted": 18, "eventsExtracted": 11, "relationshipsExtracted": 22 },
  "loadMs": 840
}

Pipeline

Read-only access to resolution and reconciliation reports produced by the consolidation pipeline. Use these to audit merge decisions, debug unexpected entity behaviour, and review post-processing actions.

Get resolution report

GET /patients/{patientId}/resolution

Returns every entity in the resolved graph with its complete ProvenanceTrace: which sources contributed, what field-level conflicts existed, how each conflict was resolved, and which resolution layer (1–4) made the final merge or no-merge decision.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Response 200 (ResolutionReport)

curl "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/resolution" \
  -H "X-Clinia-API-Key: <clinia-api-key>"

See Audit Entity Resolution for a guide to reading this report.


Get reconciliation summary

GET /patients/{patientId}/reconciliation

Returns a summary of what the consolidation pipeline did: merge statistics, the full list of inferred relationships added by the relationship resolver, and all post-processing actions applied by the condition post-processor.

Path parameters

ParameterTypeDescription
patientIdstringPatient registry key

Query parameters

ParameterTypeDefaultDescription
formatmarkdown | jsonmarkdownmarkdown returns a human-readable report; json returns a structured ReconciliationReport

Response 200 (ReconciliationReport or Markdown string)

curl "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/reconciliation" \
  -H "X-Clinia-API-Key: <clinia-api-key>"
curl "https://api.<workspace-id>.clinia.cloud/patients/{patientId}/reconciliation?format=json" \
  -H "X-Clinia-API-Key: <clinia-api-key>"

See Review the Reconciliation Summary for a guide to reading this report.


Schemas

PatientInfo

Demographics extracted from ingested source data. Populated from the FHIR Patient resource or equivalent CDA patient header.

FieldTypeRequiredDescription
idstringyesClinical patient identifier from the source data. May differ from the registry key.
namestringyesPatient's full display name as extracted from the source
birthDatestring (date)noDate of birth in ISO 8601 format (YYYY-MM-DD)
genderstringnoGender as recorded in the source (not normalized)

PipelineStats

Counts produced by the entity resolution pipeline after the most recent ingest call.

FieldTypeDescription
entitiesintegerNumber of deduplicated ClinicalEntity nodes in the resolved graph
eventsintegerNumber of ClinicalEvent entries in the timeline store (encounters, lab results, procedures). Not deduplicated (each occurrence is preserved).
relationshipsintegerNumber of typed edges, including both explicit and inferred relationships
warningsintegerTotal ExtractionWarning count. Non-zero does not prevent querying.
loadMsintegerWall-clock time in milliseconds for the most recent full pipeline execution

PatientRegistryEntry

A single entry in the patient registry, as returned by GET /patients.

FieldTypeRequiredDescription
registryKeystringyesCaller-assigned identifier used as patientId in all endpoints
patientPatientInfonoDemographics. Absent if no Patient resource was ingested.
readybooleanyestrue if at least one ingest has completed and the pipeline has run
statsPipelineStatsnoPipeline statistics from the most recent ingest run. Absent when ready is false.

PatientDetail

Full patient detail returned by GET /patients/{patientId}. Combines PatientInfo fields with pipeline statistics.

FieldTypeRequiredDescription
idstringyesClinical patient identifier from the source
namestringyesPatient's full display name
birthDatestringnoDate of birth in ISO 8601 format
genderstringnoGender as recorded in the source
statsPipelineStatsyesPipeline statistics from the most recent ingest run

VfsEntry

A single entry in a VFS directory listing.

FieldTypeRequiredDescription
namestringyesDirectory entry name or file name (slug or literal file name like _story.md)
typedirectory | fileyesWhether this entry is navigable (directory) or readable (file)
previewstringnoOne-line summary of the entry's content

BrowseResult

The result of a VFS browse operation.

FieldTypeRequiredDescription
pathstringyesFully-qualified VFS path that was resolved, including the /patient/{id} prefix
typedirectory | fileyesWhether the resolved path is a directory or a file
childrenVfsEntry[]noEntries in this directory. Present only when type is directory.
contentstringnoInline file content. Present only when type is file.

DocumentMetadata

Metadata for registering an unstructured document without uploading file bytes.

FieldTypeRequiredDescription
namestringyesFile name including extension (e.g. scan_20230801.pdf). Used to derive document type and attempt date extraction from an embedded YYYYMMDD sequence.
mimeTypestringnoMIME type (e.g. application/pdf, image/jpeg). If omitted, inferred from extension.

BatchIngestRequest

Request body for batch ingest. At least one of fhir, cda, or documents must be present.

FieldTypeDescription
fhirobject[]One or more FHIR R4 Bundles or single resources. See Ingest FHIR.
cdastring[]One or more CDA or C-CDA XML documents as raw strings. See Ingest CDA.
documentsDocumentMetadata[]One or more unstructured document metadata entries to register.

ConnectorStats

Extraction statistics produced by a single connector run.

FieldTypeDescription
itemsScannedintegerTotal source items inspected by the connector, including skipped items
entitiesExtractedintegerClinicalEntity objects successfully produced and passed to the resolution pipeline
eventsExtractedintegerClinicalEvent objects (encounters, lab results, procedures) added to the timeline store

ExtractionWarning

A warning emitted when a source item could be partially parsed but not fully extracted. Warnings do not halt ingestion.

FieldTypeRequiredDescription
sourcefhir | cda | documentyesThe connector that emitted this warning
pathstringnoResource path within the source (e.g. Condition/abc123, Problems section / entry 3)
messagestringyesHuman-readable description of what was missing or unparseable
severitylow | medium | highyeslow: minor data degradation. medium: entity extracted with reduced fidelity. high: item skipped entirely.

IngestResult

The result of a completed ingest operation. Returned after the connector and resolution pipeline have both completed.

FieldTypeRequiredDescription
okbooleanyestrue if ingest and pipeline completed without a fatal error. Can be true even when warnings > 0.
sourcestringyesThe connector used: fhir, cda, document, or batch
statsConnectorStatsyesExtraction statistics. For batch ingest, combined totals across all connectors.
warningsintegeryesTotal ExtractionWarning count. Check GET /ingest/status for the full list.
patientPatientInfonoDemographics extracted from the source. Absent for document-only ingest.

IngestStatus

Current state of a patient in the registry.

FieldTypeRequiredDescription
readybooleanyestrue if at least one ingest has completed and the pipeline has run
sourcesSourceStat[]yesOne entry per ingested source, each with a label and per-connector stats
patientPatientInfonoDemographics. Absent if no Patient resource was ingested.
loadStatsLoadStatsnoAggregate post-resolution counts. Absent when ready is false.
loadMsintegeryesTotal pipeline duration in milliseconds

SourceStat

FieldTypeDescription
labelstringHuman-readable label for the source
statsConnectorStatsExtraction statistics for this source

LoadStats

FieldTypeDescription
entitiesExtractedintegerTotal deduplicated entities in the resolved graph
eventsExtractedintegerTotal clinical events in the timeline store
relationshipsExtractedintegerTotal typed relationship edges in the graph

SourceRef

A reference to a single source that contributed to a merged entity.

FieldTypeRequiredDescription
typefhir | cda | documentyesConnector type that produced this source reference
originstringyesHuman-readable label for the source document (e.g. FHIR Bundle, Summary_20230907.xml)
reliabilitynumber (0–1)yesWeight given to this source when resolving conflicts. FHIR sources typically score 0.85; CDA 0.80.
refstringnoOriginal resource reference within the source (e.g. Condition/abc123)

ConflictRecord

A field-level conflict between two or more sources during entity resolution.

FieldTypeRequiredDescription
fieldstringyesThe entity field with conflicting values (e.g. status, dosageText)
valuesstring[]yesThe conflicting values, one per contributing source, in the same order as sources
resolutionstringyesWhich value was selected as canonical and why

ProvenanceTrace

The complete audit record attached to every merged ClinicalEntity.

FieldTypeRequiredDescription
sourcesSourceRef[]yesAll source records merged into this entity. A single-element array means the entity appeared in only one source.
conflictsConflictRecord[]yesField-level conflicts. Empty array means all sources agreed.
resolvedBystringyesThe resolution layer that made the final decision (see table below)
reasoningstringnoLLM's natural-language rationale. Only present when resolvedBy is llm-adjudication.
confidencenumber (0–1)yesOverall confidence combining source reliability and resolution layer confidence

resolvedBy values

ValueLayerWhat happened
deterministic-code1Entities share a standard code (SNOMED, RxNorm, ICD-10, LOINC)
nlp-normalization2Same concept with different display text or minor variation
embedding-similarity3Semantically similar with no shared code
llm-adjudication4Ambiguous case escalated to LLM for clinical judgment
no-mergenoneEntity was not merged (treated as unique)

ClinicalCode

A single clinical code from a standardized coding system.

FieldTypeRequiredDescription
systemstringyesURI of the coding system (e.g. http://snomed.info/sct, http://loinc.org)
codestringyesCode value within the system (e.g. 44054006, E11.9)
displaystringnoHuman-readable display name as it appeared in the source

ResolvedEntity

A single deduplicated clinical entity in the resolved graph.

FieldTypeRequiredDescription
idstringyesStable graph identifier derived from primary code (e.g. condition:snomed:44054006)
displaystringyesCanonical display name after normalization. Used to generate VFS path slugs.
typestringyesClinical category (see VFS Paths)
statusactive | resolved | inactive | stoppednoClinical status. Absent if the source did not provide one.
codesClinicalCode[]noAll clinical codes across contributing sources, deduplicated
confidencenumber (0–1)yesOverall confidence reflecting source reliability and resolution decision strength
provenanceProvenanceTraceyesComplete audit trail for this entity's resolution

ResolutionReport

The complete entity resolution report for a patient.

FieldTypeRequiredDescription
patientPatientInfoyesDemographics of the patient this report covers
entitiesResolvedEntity[]yesAll deduplicated entities in the resolved graph, ordered by type then display name

InferredRelationship

A typed directed edge inferred by the relationship resolver using the clinical knowledge base. Only created when no explicit edge of the same type already exists between the same pair.

FieldTypeRequiredDescription
fromIdstringyesGraph entity ID of the source node
fromDisplaystringnoDisplay name of the source entity
toIdstringyesGraph entity ID of the target node
toDisplaystringnoDisplay name of the target entity
typestringyesSemantic relationship type (see table below)
confidencenumber (0–1)yesDerived from knowledge base strength: 0.90 (strong), 0.75 (moderate), 0.60 (weak)

Relationship types

TypeSourceExample
prescribed_forknowledge_basemetformin → type_2_diabetes_mellitus
monitorsknowledge_basehba1c → type_2_diabetes_mellitus
complication_ofknowledge_basechronic_kidney_disease → type_2_diabetes_mellitus
manifestation_ofknowledge_baseperipheral_neuropathy → type_2_diabetes_mellitus
progression_ofknowledge_baseckd_stage_4 → ckd_stage_3
risk_factor_forknowledge_basehyperlipidemia → coronary_artery_disease
commonly_comorbidknowledge_basehypertension → type_2_diabetes_mellitus
same_disease_axisknowledge_basemicroalbuminuria → chronic_kidney_disease
occurred_duringtemporal_inferencechronic_kidney_disease → encounter_2023_05

PostProcessAction

A single action taken by the condition post-processor heuristic pass to fix a common EHR data quality issue.

FieldTypeRequiredDescription
typestringyesAction type (see table below)
entityIdstringyesGraph entity ID of the entity that was modified
entityDisplaystringnoDisplay name of the affected entity
descriptionstringnoPlain-language explanation of what was changed and why

Action types

TypeWhat it does
reclassify-to-family-historyConditions coded as "hx of X" or "family history of X" moved to the family history subgraph
reclassify-to-care-planItems better classified as care plan goals reclassified accordingly
infer-resolved-statusConditions with textual cues ("resolved", "in remission", "former") have status set accordingly
link-symptomNon-specific symptoms (fatigue, nausea) linked to likely parent conditions via clinical knowledge
compound-conditionRelated conditions combined into a compound clinical entity

ReconciliationReport

A summary of all consolidation pipeline activity for a patient.

FieldTypeRequiredDescription
patientPatientInfoyesDemographics of the patient this report covers
statsobjectyesAggregate counts (see table below)
inferredRelationshipsInferredRelationship[]yesComplete list of relationship edges inferred by the relationship resolver
postProcessActionsPostProcessAction[]yesComplete list of heuristic actions applied by the condition post-processor

stats fields

FieldTypeDescription
inputEntitiesintegerTotal ClinicalEntity objects produced by all connectors before deduplication
resolvedEntitiesintegerEntities remaining in the graph after deduplication (always ≤ inputEntities)
mergedGroupsintegerNumber of merge groups where two or more input entities collapsed into one
explicitRelationshipsintegerRelationship edges extracted directly from source data references
inferredRelationshipsintegerRelationship edges added by the relationship resolver
postProcessActionsintegerTotal heuristic post-processing actions applied

ErrorResponse

Standard error response for 4xx responses.

FieldTypeRequiredDescription
errorstringyesHuman-readable description of what went wrong
codestringnoMachine-readable error code (e.g. PATIENT_NOT_FOUND, VFS_PATH_NOT_FOUND)

On this page