Skip to content

SunCharts EHR API

Workflows and automation

EHR API as of 26.11.11.41 31 operations openapi.json ↓

# List governed connector action invocations

GET /api/v1/automation/action-invocations

Staff-only tenant worklist of at most 100 invocations. List responses omit action input and its digest. Sensitive clinical writes, communications and charges never auto-retry.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
status query any

Responses

200 Governed invocation metadata
403 Staff role required

Example call

curl "$EHR_URL/api/v1/automation/action-invocations" -H "Authorization: Bearer $ACCESS_TOKEN"

# Open one governed connector action invocation

GET /api/v1/automation/action-invocations/{id}

Staff-only, tenant-scoped and audited. Returns invocation metadata, result evidence and immutable execution/review history; action input and its digest are not returned by this boundary.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Invocation detail and immutable events
403 Staff role required
404 Invocation not found in tenant

Example call

curl "$EHR_URL/api/v1/automation/action-invocations/{id}" -H "Authorization: Bearer $ACCESS_TOKEN"

# Approve, reject or cancel a governed connector action

POST /api/v1/automation/action-invocations/{id}/actions

Versioned human-review gate. Approval follows the action policy and optional separation of duties. Owner authorization is required to cancel. Expired leases for clinical writes, communications and charges stop for reconciliation instead of retrying.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
If-Match required header string Quoted current resource version.

Request body application/json · required

Fields object · 2
Field Type Details
action required any one of approve, reject, cancel
reason required string length 1–1000
Example request body placeholder values
{
  "action": "approve",
  "reason": "string"
}

Responses

200 Updated invocation and review state
403 Approval policy, separation-of-duties or owner gate denied
409 Stale version or invalid transition
428 Current If-Match required

Example call

curl -X POST "$EHR_URL/api/v1/automation/action-invocations/{id}/actions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# List durable automation deliveries

GET /api/v1/automation/deliveries

Staff-only tenant worklist of at most 100 deliveries. Delivery is at-least-once with a stable event-and-subscription idempotency key; effectful work must enter the governed action boundary.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
status query any

Responses

200 Delivery metadata without lease tokens or worker identities
403 Staff role required

Example call

curl "$EHR_URL/api/v1/automation/deliveries" -H "Authorization: Bearer $ACCESS_TOKEN"

# Cancel or safely replay an automation delivery

POST /api/v1/automation/deliveries/{id}/actions

Owner-only. Cancel applies to pending or dead-letter deliveries. Replay applies only to cancelled or dead-letter deliveries while evidence is retained and the subscription is active. Replay preserves the original event-and-subscription idempotency identity; repeating an intended effect requires a new source event.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Request body application/json · required

Fields object · 2
Field Type Details
action required any one of cancel, replay
reason required string length 1–1000
Example request body placeholder values
{
  "action": "cancel",
  "reason": "string"
}

Responses

200 Cancelled delivery or new pending replay record
403 Owner role required
409 Invalid state, expired evidence or inactive subscription

Example call

curl -X POST "$EHR_URL/api/v1/automation/deliveries/{id}/actions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# List durable automation event metadata

GET /api/v1/automation/events

Staff-only, tenant-scoped list of at most 100 events. List responses omit event payload, tenant ID and deduplication key. PHI payloads are erased after their bounded retention period while digest and audit metadata remain.

Access OAuth 2.0 access tokenclinical.read

Responses

200 Event metadata ordered newest first
403 Staff role required

Example call

curl "$EHR_URL/api/v1/automation/events" -H "Authorization: Bearer $ACCESS_TOKEN"

# Open one automation event and its deliveries

GET /api/v1/automation/events/{id}

Staff-only, tenant-scoped and audited. Returns retained payload plus delivery metadata; erased PHI payloads are represented without recoverable content.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Event detail and related deliveries
403 Staff role required
404 Event not found in tenant

Example call

curl "$EHR_URL/api/v1/automation/events/{id}" -H "Authorization: Bearer $ACCESS_TOKEN"

# List exact automation trigger subscriptions

GET /api/v1/automation/subscriptions

Staff-only, tenant-scoped list of at most 100 subscriptions. Configuration and secrets are never returned.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
status query any

Responses

200 Subscription metadata
403 Staff role required

Example call

curl "$EHR_URL/api/v1/automation/subscriptions" -H "Authorization: Bearer $ACCESS_TOKEN"

# Subscribe to an enabled connector trigger

POST /api/v1/automation/subscriptions

Owner-only. event_type and transport are derived from the enabled current connector manifest; callers cannot supply arbitrary transport, configuration or credentials.

Access OAuth 2.0 access tokenclinical.read

Request body application/json · required

Fields CreateAutomationSubscription · 3
Field Type Details
connector_key required string length 2–160
reason required string length 1–1000
trigger_key required string length 2–160
Example request body placeholder values
{
  "connector_key": "string",
  "reason": "string",
  "trigger_key": "string"
}

Responses

200 Configured subscription
400 Invalid exact connector or trigger identity
403 Owner role required
409 Enabled connector trigger not found or invalid

Example call

curl -X POST "$EHR_URL/api/v1/automation/subscriptions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Activate or deactivate an exact trigger subscription

POST /api/v1/automation/subscriptions/{id}/actions

Owner-only and versioned. Activation requires the referenced connector installation to remain enabled.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
If-Match required header string Quoted current resource version.

Request body application/json · required

Fields AutomationLifecycleAction · 2
Field Type Details
action required any one of activate, deactivate
reason required string length 1–1000
Example request body placeholder values
{
  "action": "activate",
  "reason": "string"
}

Responses

200 Updated subscription
403 Owner role required
409 Stale version, disabled connector or invalid transition
428 Current If-Match required

Example call

curl -X POST "$EHR_URL/api/v1/automation/subscriptions/{id}/actions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# List care pathway definitions

GET /api/v1/care-pathways/definitions

Access OAuth 2.0 access tokenclinical.read

Responses

200 Tenant care-pathway definitions

Example call

curl "$EHR_URL/api/v1/care-pathways/definitions" -H "Authorization: Bearer $ACCESS_TOKEN"

# Create a configurable visual care-pathway draft

POST /api/v1/care-pathways/definitions

Owner-only. Columns are ordered display lanes rather than fixed clinical phases; node dependencies and conditions remain the executable graph. request_id provides idempotency.

Access OAuth 2.0 access tokenclinical.read

Request body application/json · required

Fields CreateCarePathwayDefinition · 34
Field Type Details
definition required CarePathwayDefinition A versioned directed acyclic workflow graph. Column order changes presentation; depends_on, condition and manual_approval control execution. Column keys and step keys must be unique, and at least one column must remain visible.
steps required array of CarePathwayStepDefinition items 1–100
key required string Stable node identity used by dependency edges. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
kind required any one of patient_form, staff_task, eligibility_query, payment_request, document_signature, notification, clinical_template, order, referral, human_approval, availability_query, slot_hold, appointment_booking, appointment_reschedule, appointment_cancel, intake_request, communication_send, ai_extract_draft, ai_response_draft
title required string length 1–200
ai CarePathwayAiConfiguration or null
assigned_role string or null one of owner, clinician, nurse, medical_assistant, front_desk, null
condition CarePathwayCondition or null
depends_on array of string Directed incoming edges. The complete definition must remain acyclic. items ≤ 20
due_after_minutes integer or null value 1–525600
editor_position object or null Optional finite canvas coordinates stored in the immutable definition revision. Presentation only; phase, dependencies and approvals retain their runtime meaning.
escalation_role string or null one of owner, clinician, nurse, medical_assistant, front_desk, null
form_fields array of CarePathwayFormField Allowed for patient_form and clinical_template nodes. Patient-form fields issue a real immutable intake packet; clinical-template completion uses its separate native resource binding. items ≤ 30
field_type required any one of short_text, long_text, date, choice, checkbox, number
key required string pattern ^[a-z0-9][a-z0-9_-]{0,62}$
label required string length 1–120
chart_target string or null Optional mapping for short_text, long_text or choice fields; each target must be unique within the form. Patient-form packets pin this mapping to the run revision. Explicit staff review and selected-answer promotion are required; no automatic chart write. one of demographics.preferred_name, demographics.pronouns, demographics.language, demographics.administrative_gender, demographics.phone, demographics.email, null
options array of string Allowed only for choice fields. items ≤ 20
required boolean default false
manual_approval boolean AI nodes require true. The human_approval kind is always an approval gate, including legacy saved definitions. default false
native object or null Optional native evidence binding; allowed resources depend on node kind. Completion and approval require current tenant-, patient- and encounter-bound evidence. Clinical-template nodes require a supported binding to complete.
phase string or null Column key used for visual placement; legacy definitions may omit it. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
required boolean default false
columns array of CarePathwayColumnDefinition Ordered, clinic-configurable visual lanes. Omission on a legacy definition applies the four standard journey columns. items 1–12
key required string Stable lane identity retained when its title or order changes. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
title required string length 1–120
description string default length ≤ 500
hidden boolean Hides the visual lane without changing node or dependency execution. default false
name required string length 1–200
reason required string length 1–1000
request_id required string (uuid)
slug required string pattern ^[a-z0-9][a-z0-9_-]{0,62}$
trigger_type required any one of inquiry_received, referral_received, referral_status_changed, call_received, sms_received, fax_received, email_received, external_booking_received, appointment_created, appointment_rescheduled, appointment_cancelled, eligibility_returned, patient_checked_in, visit_signed, order_placed
description string default length ≤ 2000
Example request body placeholder values
{
  "definition": {
    "steps": [
      {
        "key": "string",
        "kind": "patient_form",
        "title": "string",
        "ai": {
          "instruction": null,
          "integration_id": null,
          "source_field": null,
          "privacy": null
        },
        "assigned_role": "owner",
        "condition": {
          "field": null,
          "operator": "equals",
          "value": null
        },
        "depends_on": [],
        "due_after_minutes": 1
      }
    ],
    "columns": [
      {
        "key": "string",
        "title": "string",
        "description": "",
        "hidden": false
      }
    ]
  },
  "name": "string",
  "reason": "string",
  "request_id": "00000000-0000-4000-8000-000000000000",
  "slug": "string",
  "trigger_type": "inquiry_received",
  "description": ""
}

Responses

200 Created draft definition
400 Invalid columns, nodes, dependency graph or trigger
403 Owner role required
409 Slug or request identity conflict

Example call

curl -X POST "$EHR_URL/api/v1/care-pathways/definitions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Read care pathway definition

GET /api/v1/care-pathways/definitions/{id}

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Definition

Example call

curl "$EHR_URL/api/v1/care-pathways/definitions/{id}" -H "Authorization: Bearer $ACCESS_TOKEN"

# Replace a care-pathway draft

PUT /api/v1/care-pathways/definitions/{id}

Owner-only and versioned. Published revisions remain immutable. Empty columns may be removed after their nodes are reassigned; at least one visible column is required.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
If-Match required header string

Request body application/json · required

Fields UpdateCarePathwayDefinition · 32
Field Type Details
definition required CarePathwayDefinition A versioned directed acyclic workflow graph. Column order changes presentation; depends_on, condition and manual_approval control execution. Column keys and step keys must be unique, and at least one column must remain visible.
steps required array of CarePathwayStepDefinition items 1–100
key required string Stable node identity used by dependency edges. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
kind required any one of patient_form, staff_task, eligibility_query, payment_request, document_signature, notification, clinical_template, order, referral, human_approval, availability_query, slot_hold, appointment_booking, appointment_reschedule, appointment_cancel, intake_request, communication_send, ai_extract_draft, ai_response_draft
title required string length 1–200
ai CarePathwayAiConfiguration or null
assigned_role string or null one of owner, clinician, nurse, medical_assistant, front_desk, null
condition CarePathwayCondition or null
depends_on array of string Directed incoming edges. The complete definition must remain acyclic. items ≤ 20
due_after_minutes integer or null value 1–525600
editor_position object or null Optional finite canvas coordinates stored in the immutable definition revision. Presentation only; phase, dependencies and approvals retain their runtime meaning.
escalation_role string or null one of owner, clinician, nurse, medical_assistant, front_desk, null
form_fields array of CarePathwayFormField Allowed for patient_form and clinical_template nodes. Patient-form fields issue a real immutable intake packet; clinical-template completion uses its separate native resource binding. items ≤ 30
field_type required any one of short_text, long_text, date, choice, checkbox, number
key required string pattern ^[a-z0-9][a-z0-9_-]{0,62}$
label required string length 1–120
chart_target string or null Optional mapping for short_text, long_text or choice fields; each target must be unique within the form. Patient-form packets pin this mapping to the run revision. Explicit staff review and selected-answer promotion are required; no automatic chart write. one of demographics.preferred_name, demographics.pronouns, demographics.language, demographics.administrative_gender, demographics.phone, demographics.email, null
options array of string Allowed only for choice fields. items ≤ 20
required boolean default false
manual_approval boolean AI nodes require true. The human_approval kind is always an approval gate, including legacy saved definitions. default false
native object or null Optional native evidence binding; allowed resources depend on node kind. Completion and approval require current tenant-, patient- and encounter-bound evidence. Clinical-template nodes require a supported binding to complete.
phase string or null Column key used for visual placement; legacy definitions may omit it. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
required boolean default false
columns array of CarePathwayColumnDefinition Ordered, clinic-configurable visual lanes. Omission on a legacy definition applies the four standard journey columns. items 1–12
key required string Stable lane identity retained when its title or order changes. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
title required string length 1–120
description string default length ≤ 500
hidden boolean Hides the visual lane without changing node or dependency execution. default false
name required string length 1–200
reason required string length 1–1000
trigger_type required any one of inquiry_received, referral_received, referral_status_changed, call_received, sms_received, fax_received, email_received, external_booking_received, appointment_created, appointment_rescheduled, appointment_cancelled, eligibility_returned, patient_checked_in, visit_signed, order_placed
description string default length ≤ 2000
Example request body placeholder values
{
  "definition": {
    "steps": [
      {
        "key": "string",
        "kind": "patient_form",
        "title": "string",
        "ai": {
          "instruction": null,
          "integration_id": null,
          "source_field": null,
          "privacy": null
        },
        "assigned_role": "owner",
        "condition": {
          "field": null,
          "operator": "equals",
          "value": null
        },
        "depends_on": [],
        "due_after_minutes": 1
      }
    ],
    "columns": [
      {
        "key": "string",
        "title": "string",
        "description": "",
        "hidden": false
      }
    ]
  },
  "name": "string",
  "reason": "string",
  "trigger_type": "inquiry_received",
  "description": ""
}

Responses

200 Updated draft definition
400 Invalid columns, nodes or dependency graph
403 Owner role required
428 Current If-Match required

Example call

curl -X PUT "$EHR_URL/api/v1/care-pathways/definitions/{id}" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Act on care pathway definition

POST /api/v1/care-pathways/definitions/{id}/actions

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
If-Match required header string

Responses

200 Definition activated or archived

Example call

curl -X POST "$EHR_URL/api/v1/care-pathways/definitions/{id}/actions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# List care pathway definition revisions

GET /api/v1/care-pathways/definitions/{id}/revisions

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Immutable definition revisions

Example call

curl "$EHR_URL/api/v1/care-pathways/definitions/{id}/revisions" -H "Authorization: Bearer $ACCESS_TOKEN"

# List care pathway instances

GET /api/v1/care-pathways/instances

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
patient_id query string (uuid)
status query string

Responses

200 Tenant pathway worklist

Example call

curl "$EHR_URL/api/v1/care-pathways/instances" -H "Authorization: Bearer $ACCESS_TOKEN"

# Read care pathway instance

GET /api/v1/care-pathways/instances/{id}

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Pathway instance

Example call

curl "$EHR_URL/api/v1/care-pathways/instances/{id}" -H "Authorization: Bearer $ACCESS_TOKEN"

# Act on care pathway instance

POST /api/v1/care-pathways/instances/{id}/actions

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
If-Match required header string

Responses

200 Pathway cancelled or resumed
428 Current If-Match required

Example call

curl -X POST "$EHR_URL/api/v1/care-pathways/instances/{id}/actions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# List care pathway events

GET /api/v1/care-pathways/instances/{id}/events

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Immutable attributed pathway event history

Example call

curl "$EHR_URL/api/v1/care-pathways/instances/{id}/events" -H "Authorization: Bearer $ACCESS_TOKEN"

# Read care pathway native readiness

GET /api/v1/care-pathways/instances/{id}/readiness

Authenticated staff readiness from the immutable workflow definition and tenant-bound native records. Per-resource native/custom/OAuth read permissions are enforced; denied sections contain no record identifiers. Readiness is not completion and is rechecked atomically on complete/approve. Multiple matching records require selection from returned candidates. Payment evidence is currently test mode; eligibility response completion does not establish active benefits or credentialing.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 No-store response with instance_id, definition_version, observed_at, steps and progress. Each step includes resource, ready, status (manual, missing, pending, ambiguous, unconfigured, forbidden, verified), reason, and permitted native action hints. Candidate/resource IDs are scoped to the run; no patient names or clinical text are returned.
401 Authentication required
403 Workflow access denied
404 Tenant-scoped run not found

Example call

curl "$EHR_URL/api/v1/care-pathways/instances/{id}/readiness" -H "Authorization: Bearer $ACCESS_TOKEN"

# Act on care pathway step

POST /api/v1/care-pathways/instances/{id}/steps/{step}/actions

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
step required path string
If-Match required header string

Responses

200 Updated pathway instance
428 Current If-Match required

Example call

curl -X POST "$EHR_URL/api/v1/care-pathways/instances/{id}/steps/{step}/actions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Issue the saved run revision patient form as a bound intake packet

POST /api/v1/care-pathways/instances/{id}/steps/{step}/intake-packet

Requires an active patient_form step with fields and a linked patient/appointment. If-Match is the step version. A retry returns the same packet ID; its secret URL appears only on first issuance. No message is sent and the step is not completed.

Access OAuth 2.0 access tokenclinical.writescheduling.write

Parameters

Name In Type Details
id required path string (uuid)
step required path string
If-Match required header string

Request body application/json · required

Fields object · 1
Field Type Details
reason required string length 1–1000
Example request body placeholder values
{
  "reason": "string"
}

Responses

200 Existing bound packet, with intake_url null and secret_shown_once false.
201 Created packet: packet_id, one-time intake_url, secret_shown_once, workflow_instance_id, workflow_step_key, workflow_definition_version.
403 Native role, downstream scope or custom policy denied.
409 Inactive workflow, mismatched appointment, blocked step or stale version.

Example call

curl -X POST "$EHR_URL/api/v1/care-pathways/instances/{id}/steps/{step}/intake-packet" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Submit a workflow node for explicit native-operation review

POST /api/v1/care-pathways/instances/{instance}/steps/{step}/dispatch

Creates a tenant-scoped, idempotent work item only when the active pathway step is ready, integration-aware, and configured for manual approval. The step moves to awaiting_approval. No native scheduling mutation, provider transmission or model call occurs until a separate authorized reviewer approves this dispatch. Communication nodes and Claude/Erebine nodes create downstream drafts only; those drafts retain their own approval/send gates. Empty input on a configured AI node resolves only its explicit source_field from this run’s immutable definition and context. Original AI input stays local and is omitted from dispatch responses; an authorized reviewer must prepare and approve a privacy preview before execution. Eligibility and payment nodes use the configured native provider paths. A payment request creates test-mode checkout and waits for processor-confirmed payment plus ledger evidence; eligibility completion does not approve benefits. Patient-form issuance also has a direct versioned intake-packet endpoint.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
instance required path string (uuid)
step required path string

Request body application/json · required

Fields object · 3
Field Type Details
input required object Kind-specific native-operation input, limited to 262,144 serialized bytes. intake_request accepts optional appointment_id and form_step_key (an exact patient_form in this run). payment_request requires account_id, expected_version and amount_cents. eligibility_query requires coverage_id and the structured native eligibility request object; the dispatch supplies its request_id.
reason required string length 1–1000
request_id required string (uuid)
Example request body placeholder values
{
  "input": {
    "clinician_id": "00000000-0000-4000-8000-000000000202",
    "ends_at": "2026-11-09T15:30:00Z",
    "facility": "Synthetic clinic",
    "room": "Room 1",
    "starts_at": "2026-11-09T15:00:00Z"
  },
  "reason": "Review the requested synthetic appointment window.",
  "request_id": "00000000-0000-4000-8000-000000000201"
}

Responses

200 New pending-review dispatch or identical idempotent replay
400 Invalid or over-broad kind-specific input
403 Read-only or assigned-role restriction
409 Step not ready/manual-review enabled or request_id reused with different input

Example call

curl -X POST "$EHR_URL/api/v1/care-pathways/instances/{instance}/steps/{step}/dispatch" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Idempotently instantiate active definitions for a tenant event

POST /api/v1/care-pathways/trigger

Staff-only. Starts matching published revisions and evaluates graph conditions; display-column placement does not alter dependency execution.

Access OAuth 2.0 access tokenclinical.read

Request body application/json · required

Fields TriggerCarePathway · 10
Field Type Details
reason required string length 1–1000
request_id required string (uuid)
trigger_key required string length 1–300
trigger_type required any one of inquiry_received, referral_received, referral_status_changed, call_received, sms_received, fax_received, email_received, external_booking_received, appointment_created, appointment_rescheduled, appointment_cancelled, eligibility_returned, patient_checked_in, visit_signed, order_placed
appointment_id string or null
context object Bounded event context evaluated by node conditions and retained with the pathway instance. default {}
definition_id string or null
expected_definition_version integer or null Optional published-version constraint. A mismatched or no-longer-published definition does not start a run. value ≥ 1
patient_id string or null
visit_id string or null
Example request body placeholder values
{
  "reason": "string",
  "request_id": "00000000-0000-4000-8000-000000000000",
  "trigger_key": "string",
  "trigger_type": "inquiry_received",
  "appointment_id": "00000000-0000-4000-8000-000000000000",
  "context": {},
  "definition_id": "00000000-0000-4000-8000-000000000000",
  "expected_definition_version": 1
}

Responses

200 Matching pathway instances
400 Invalid trigger identity or context
403 Staff role required

Example call

curl -X POST "$EHR_URL/api/v1/care-pathways/trigger" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Read permitted local practice counts for Sun

GET /api/v1/sun/context

Authenticated staff only, including read-only staff; patients are denied. Trusted tenant scope comes from authentication. No query parameters, caller-supplied tenant, patient selection, filters or model-selected SQL are accepted. Fixed native tools read aggregate counts in one REPEATABLE READ transaction and return only after the read audit commits. No names, record identifiers, chart text, prompts, credentials or external provider calls are included. OAuth requires clinical.read; appointment counts additionally require scheduling.read. Without scheduling.read, appointments and its capability are omitted and unavailable explains why; expired or revoked authentication fails the entire request. This whole-practice observation is not authority to perform an action, and any later AI use still requires the separate privacy preview and approval flow.

Access OAuth 2.0 access tokenclinical.read

Responses

200 Audited local database snapshot; appointment facts may be omitted by scope application/json

Headers: Cache-Control

Fields object · 37
Field Type Details
capabilities required array of string Stable IDs of the native tools whose facts are included items ≤ 3
facts required object
patients required object
definition required string Human-readable explanation of the count boundary
scope required constant always all_local_patient_records
total required integer All patient rows stored in this tenant, including registered and imported records regardless of legacy source status flags. Not an active-patient or deduplicated-person count; independent of browser pagination. value ≥ 0
workflows required object All saved workflow runs, including completed and cancelled runs. Step counts include active runs only and are not unique-patient or unique-run counts.
awaiting_approval_steps required integer value ≥ 0
by_status required object
active required integer value ≥ 0
cancelled required integer value ≥ 0
completed required integer value ≥ 0
other required integer value ≥ 0
definition required string
ready_steps required integer value ≥ 0
scope required constant always all_local_workflow_instances
total required integer value ≥ 0
appointments object Native appointments starting on the practice-local date, including completed, cancelled, no-show and imported appointments converted to native records. Historical-only records and schedule blocks are excluded. A prior-day appointment overlapping this date is excluded. Omitted when scheduling.read is unavailable.
by_status required object
booked required integer value ≥ 0
cancelled required integer value ≥ 0
checked_in required integer value ≥ 0
completed required integer value ≥ 0
in_progress required integer value ≥ 0
no_show required integer value ≥ 0
other required integer value ≥ 0
date required string (date) Local date at observed_at in practice_timezone
definition required string
scope required constant always appointments_starting_on_local_date
total required integer value ≥ 0
observed_at required string (date-time) UTC database transaction timestamp for this repeatable-read observation; not a continuously live count
practice_timezone required string Saved practice booking timezone, or UTC when no booking profile exists
source required constant always native_local_database
timezone_source required string one of practice_booking_settings, UTC_default
unavailable required array of object Tools omitted for this request; missing facts must not be interpreted as zero items ≤ 3
reason required string
tool required string one of patients.count, appointments.today.count, workflows.count
Example response placeholder values
{
  "capabilities": [
    "patients.count"
  ],
  "facts": {
    "patients": {
      "definition": "string",
      "scope": "all_local_patient_records",
      "total": 0
    },
    "workflows": {
      "awaiting_approval_steps": 0,
      "by_status": {
        "active": 0,
        "cancelled": 0,
        "completed": 0,
        "other": 0
      },
      "definition": "string",
      "ready_steps": 0,
      "scope": "all_local_workflow_instances",
      "total": 0
    },
    "appointments": {
      "by_status": {
        "booked": 0,
        "cancelled": 0,
        "checked_in": 0,
        "completed": 0,
        "in_progress": 0,
        "no_show": 0,
        "other": 0
      },
      "date": "2026-01-15",
      "definition": "string",
      "scope": "appointments_starting_on_local_date",
      "total": 0
    }
  },
  "observed_at": "2026-01-15T15:30:00Z",
  "practice_timezone": "string",
  "source": "native_local_database",
  "timezone_source": "practice_booking_settings",
  "unavailable": [
    {
      "reason": "string",
      "tool": "patients.count"
    }
  ]
}
400 Query parameters are not accepted
401 Authentication required, expired or revoked
403 Patient role or clinical.read scope denied
404 Native local database is unavailable
500 Database or audit failure; no facts are returned

Example call

curl "$EHR_URL/api/v1/sun/context" -H "Authorization: Bearer $ACCESS_TOKEN"

# Validate a reviewed Sun workflow design draft without applying it

POST /api/v1/sun/workflow-proposals/validate

Owner-only, including delegated management actors mapped to Owner. Loads the tenant-scoped stored output of a completed workflow_design AI draft with persisted privacy approval; caller-supplied proposal text is not accepted. Reuses native name, trigger, column, step, form and acyclic-dependency validation, rejects unknown fields and arbitrary integration mappings, requires manual approval on all nodes except staff_task and patient_form, and verifies configured AI nodes reference enabled purpose-capable tenant connections. Missing AI configuration is returned as a warning. Validation does not verify live source-field availability or create integration mappings. A valid proposal may be applied only to an unsaved Studio draft after a separate human diff review; normal versioned save and publish permissions remain in force. No definition, live workflow or clinical record is mutated. Audit must commit before the proposal is returned.

Access OAuth 2.0 access tokenclinical.write

Request body application/json · required

Fields object · 1
Field Type Details
draft_id required string (uuid)
Example request body placeholder values
{
  "draft_id": "00000000-0000-4000-8000-000000000000"
}

Responses

200 Validated local proposal; Cache-Control: no-store application/json

Headers: Cache-Control

Fields object · 30
Field Type Details
application required constant always unsaved_studio_draft_only
draft_id required string (uuid)
proposal required object
definition required CarePathwayDefinition A versioned directed acyclic workflow graph. Column order changes presentation; depends_on, condition and manual_approval control execution. Column keys and step keys must be unique, and at least one column must remain visible.
steps required array of CarePathwayStepDefinition items 1–100
key required string Stable node identity used by dependency edges. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
kind required any one of patient_form, staff_task, eligibility_query, payment_request, document_signature, notification, clinical_template, order, referral, human_approval, availability_query, slot_hold, appointment_booking, appointment_reschedule, appointment_cancel, intake_request, communication_send, ai_extract_draft, ai_response_draft
title required string length 1–200
ai CarePathwayAiConfiguration or null
assigned_role string or null one of owner, clinician, nurse, medical_assistant, front_desk, null
condition CarePathwayCondition or null
depends_on array of string Directed incoming edges. The complete definition must remain acyclic. items ≤ 20
due_after_minutes integer or null value 1–525600
editor_position object or null Optional finite canvas coordinates stored in the immutable definition revision. Presentation only; phase, dependencies and approvals retain their runtime meaning.
escalation_role string or null one of owner, clinician, nurse, medical_assistant, front_desk, null
form_fields array of CarePathwayFormField Allowed for patient_form and clinical_template nodes. Patient-form fields issue a real immutable intake packet; clinical-template completion uses its separate native resource binding. items ≤ 30
manual_approval boolean AI nodes require true. The human_approval kind is always an approval gate, including legacy saved definitions. default false
native object or null Optional native evidence binding; allowed resources depend on node kind. Completion and approval require current tenant-, patient- and encounter-bound evidence. Clinical-template nodes require a supported binding to complete.
phase string or null Column key used for visual placement; legacy definitions may omit it. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
required boolean default false
columns array of CarePathwayColumnDefinition Ordered, clinic-configurable visual lanes. Omission on a legacy definition applies the four standard journey columns. items 1–12
key required string Stable lane identity retained when its title or order changes. pattern ^[a-z0-9][a-z0-9_-]{0,62}$
title required string length 1–120
description string default length ≤ 500
hidden boolean Hides the visual lane without changing node or dependency execution. default false
description required string length ≤ 2000
name required string length 1–200
trigger_type required any one of inquiry_received, referral_received, referral_status_changed, call_received, sms_received, fax_received, email_received, external_booking_received, appointment_created, appointment_rescheduled, appointment_cancelled, eligibility_returned, patient_checked_in, visit_signed, order_placed
valid required constant always true
warnings required array of string
Example response placeholder values
{
  "application": "unsaved_studio_draft_only",
  "draft_id": "00000000-0000-4000-8000-000000000000",
  "proposal": {
    "definition": {
      "steps": [
        {
          "key": null,
          "kind": "patient_form",
          "title": null,
          "ai": null,
          "assigned_role": "owner",
          "condition": null,
          "depends_on": null,
          "due_after_minutes": null
        }
      ],
      "columns": [
        {
          "key": null,
          "title": null,
          "description": "",
          "hidden": false
        }
      ]
    },
    "description": "string",
    "name": "string",
    "trigger_type": "inquiry_received"
  },
  "valid": true,
  "warnings": [
    "string"
  ]
}
400 Invalid proposal, native schema, dependency graph, form or required approval
401 Authentication required
403 Owner role or clinical.write scope required; read-only partner support is not an author
404 Draft not found in the trusted tenant
409 Draft is not a completed privacy-approved workflow proposal, or a referenced AI connection is unavailable or unauthorized
422 Invalid request body or unsupported request fields
500 Database or audit failure; no proposal is returned

Example call

curl -X POST "$EHR_URL/api/v1/sun/workflow-proposals/validate" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# List native workflow work items

GET /api/v1/workflow-dispatches

Staff-only, tenant-scoped worklist of at most 100 dispatches. List responses omit kind-specific input and input digests. AI dispatch metadata exposes privacy_review_required=true.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
status query any

Responses

200 Workflow dispatch metadata ordered newest first
403 Staff role required

Example call

curl "$EHR_URL/api/v1/workflow-dispatches" -H "Authorization: Bearer $ACCESS_TOKEN"

# Open one native workflow work item

GET /api/v1/workflow-dispatches/{id}

Returns the tenant-scoped dispatch input, result and immutable event history for review. Reading is audited. AI dispatches omit original input and expose privacy_review_required=true; use the reviewer-only privacy-preview endpoint to inspect the exact outbound request.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)

Responses

200 Dispatch detail and immutable events
404 Dispatch not found in tenant

Example call

curl "$EHR_URL/api/v1/workflow-dispatches/{id}" -H "Authorization: Bearer $ACCESS_TOKEN"

# Approve, reject or confirm a reviewed native workflow operation

POST /api/v1/workflow-dispatches/{id}/actions

Requires the current quoted dispatch version in If-Match. approve executes the bounded native scheduling/intake operation or creates a Gmail, RingCentral or Claude or Erebine downstream draft. It never auto-sends communication or auto-accepts AI output. reject returns the linked step to in-progress. confirm is valid only after the downstream Claude or Erebine draft is approved, Gmail draft is sent, or RingCentral draft is provider-accepted; it then completes the pathway step. Owner, clinician and delegated partner support may review. AI approval additionally requires privacy_preview_id and privacy_approved=true from the workflow privacy-preview endpoint. Invalid or expired previews fail before the execution transition. Active run, immutable definition revision and exact current step linkage are rechecked before provider execution. Provider output is restored locally and still requires downstream human review. Eligibility approval executes a configured native inquiry and leaves benefits review explicit. Payment approval requires the current posted account version and matching workflow patient/linked encounter; confirm requires processor-confirmed paid status, a ledger entry and no refund. All approve and confirm actions recheck the current run/step and downstream custom-policy/OAuth authority.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
If-Match required header string Quoted current workflow-dispatch version.

Request body application/json · required

Fields object · 4
Field Type Details
action required any one of approve, reject, confirm
reason required string length 1–1000
privacy_approved boolean Must be true for AI approval after reviewing exact sanitized instruction/source; omitted for other native operations. default false
privacy_preview_id string (uuid) Required for approve on AI dispatches; must be this reviewer’s current bound preview.
Example request body placeholder values
{
  "action": "approve",
  "reason": "Reviewed the synthetic workflow input and authorized the bounded operation."
}

Responses

200 Updated dispatch; one-time intake URL is returned only when an approved intake-request operation issues one
400 Missing explicit AI privacy-preview approval or invalid action input
403 Reviewer role required
409 Stale version, invalid transition or downstream gate incomplete
428 Current If-Match required

Example call

curl -X POST "$EHR_URL/api/v1/workflow-dispatches/{id}/actions" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json

# Prepare a reviewer-bound privacy preview for a Sun workflow dispatch

POST /api/v1/workflow-dispatches/{id}/privacy-preview

Owner, clinician or delegated partner support only. Requires a pending-review AI dispatch linked to an active run and its exact awaiting-approval step. Reads the immutable local input prepared from the run definition revision and trusted patient. Returns the sanitized request only; no original source or local mappings. The approving reviewer must create this preview; another reviewer must prepare a new one. No provider request occurs.

Access OAuth 2.0 access tokenclinical.read

Parameters

Name In Type Details
id required path string (uuid)
If-Match required header string Quoted current dispatch version; preview does not increment it.

Responses

200 Actor-bound sanitized request for explicit review; Cache-Control: no-store application/json
Fields AiPrivacyPreview · 13
Field Type Details
expires_at required string (date-time)
id required string (uuid)
identifier_types required array of string
instruction required string Exact sanitized instruction approved for the provider request.
integration_id required string (uuid)
model required string
patient_id required string or null Local review context only; not part of outbound provider content.
provider required any one of claude, erebine
purpose required any one of document_classification, structured_extraction, draft_summary, draft_response, workflow_design
redaction_count required integer value ≥ 0
requires_approval required constant always true
source_text required string Exact sanitized source text approved for the provider request. Supported clinical codes remain intact.
warnings required array of string
Example response placeholder values
{
  "expires_at": "2026-01-15T15:30:00Z",
  "id": "00000000-0000-4000-8000-000000000000",
  "identifier_types": [
    "string"
  ],
  "instruction": "string",
  "integration_id": "00000000-0000-4000-8000-000000000000",
  "model": "string",
  "patient_id": "00000000-0000-4000-8000-000000000000",
  "provider": "claude",
  "purpose": "document_classification",
  "redaction_count": 0,
  "requires_approval": true,
  "source_text": "string",
  "warnings": [
    "string"
  ]
}
400 Not an AI node or invalid local AI configuration
403 Reviewer role required
404 Dispatch or run not found in tenant
409 Stale version, nonpending dispatch, cancelled/completed run or changed step linkage
428 Current quoted dispatch If-Match required

Example call

curl -X POST "$EHR_URL/api/v1/workflow-dispatches/{id}/privacy-preview" -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" -d @body.json