API Reference Partner contract v1.7

The clinical record is yours, and it is addressable.

TrueEval is the licensed medical group and clinical operating platform behind healthcare brands. The platform underneath it exposes a real API: FHIR R4 resource endpoints, C-CDA 2.1 and full FHIR Bundle export, a versioned partner catalog contract, and HMAC-signed outbound webhooks with a written delivery guarantee. This page documents 15 endpoints — every one of them transcribed from the handler that serves it.

The base URL is issued with your API key. Paths below are shown relative to it.

Your record leaves in a standard format

The hardest question to answer honestly in this category is what happens to the clinical history if the relationship ends. TrueEval answers it with an endpoint rather than a clause. Patient records are addressable as FHIR R4, exportable as a complete FHIR Bundle, and exportable as C-CDA 2.1 XML — the format a receiving EHR ingests. Every export writes a PHI-access audit row before the bytes leave.

POST/functions/v1/generate-ccda
Body { "patient_id": "<uuid>" }. Returns C-CDA 2.1 XML as application/xml with a Content-Disposition: attachment filename. Bearer JWT, and the caller-to-patient authorization is checked separately from authentication.
POST/functions/v1/export-patient-records
Body { "patient_id": "<uuid>" }. Returns a FHIR Bundle of type: "collection", PHI rate-limited, with an X-Export-Trace-Id response header matching the audit row.

What the C-CDA carries

A Continuity of Care Document conforming to the US Realm Header and CCD templates (2.16.840.1.113883.10.20.22.1.1 and .1.2, extension 2015-08-01), with five sections:

SectiontemplateId root
Allergies and Adverse Reactions2.16.840.1.113883.10.20.22.2.6.1
Medications2.16.840.1.113883.10.20.22.2.1.1
Problem List2.16.840.1.113883.10.20.22.2.5.1
Laboratory Results2.16.840.1.113883.10.20.22.2.3.1
Encounters2.16.840.1.113883.10.20.22.2.22.1

source: supabase/functions/generate-ccda/index.ts

What the FHIR Bundle carries

export-patient-records assembles one collection Bundle across nine categories — demographics, clinical notes, medications, lab results, form responses, documents, consent records, messages and appointments — as Patient, MedicationRequest, DiagnosticReport, AllergyIntolerance, DocumentReference, QuestionnaireResponse, Consent, Communication and Appointment resources. The entry count and the category list are written into the audit event alongside the trace id.

source: supabase/functions/export-patient-records/index.ts

FHIR R4

Six endpoints, all serving application/fhir+json. The unified endpoint declares the version and the resource set itself:

GET /functions/v1/fhir-api
{
  "resourceType": "CapabilityStatement",
  "status": "active",
  "fhirVersion": "4.0.1",
  "format": ["json"],
  "rest": [{
    "mode": "server",
    "resource": [
      { "type": "Patient" },
      { "type": "Observation" },
      { "type": "MedicationRequest" },
      { "type": "MedicationStatement" },
      { "type": "AllergyIntolerance" },
      { "type": "Encounter" },
      { "type": "DocumentReference" }
    ]
  }]
}

source: supabase/functions/fhir-api/index.ts

EndpointResourceSearch parameters
fhir-apiCapabilityStatement + 7 resource typesBearer JWT. Every patient-scoped read is gated on user_has_access_to_patient() evaluated through the caller's own token, and fails closed./{resourceType}/{id}, ?patient=
fhir-patientPatientUS Core Patient profile. Emits us-core-race, us-core-ethnicity, us-core-genderIdentity, individual-pronouns (LOINC 90778-2) and sex-parameter extensions when the source columns are populated.?id=, ?org_id=
fhir-observationObservationUS Core lab Observation. LOINC-coded where a test code exists; falls back to code.text. Returns up to 500, newest collection_date first.?patient=, ?id=, ?date=
fhir-conditionConditionUS Core Condition, ICD-10-CM coded (http://hl7.org/fhir/sid/icd-10-cm), problem-list-item category. Up to 500.?patient=, ?id=
fhir-medication-requestMedicationRequestUS Core MedicationRequest. Requester is a Practitioner reference; dispenseRequest carries quantity and numberOfRepeatsAllowed.?patient=, ?id=, ?status=
fhir-document-referenceDocumentReferenceLOINC 34133-9 (Summary of episode note). include_urls=true attaches a time-limited signed URL to each attachment.?patient=, ?id=, ?type=, ?include_urls=true

The five resource-specific endpoints authenticate with an API key scoped fhir:read (sent as x-api-key, or as a Bearer value), and every query is filtered to the org the key resolves to. A single-record request returns the bare resource; anything else returns a searchset Bundle. Every request — success or failure — is written to api_request_logs with the endpoint, method, status, scopes required and whether they matched.

source: supabase/functions/fhir-*/index.ts · supabase/functions/_shared/api-auth.ts

A lab Observation

GET /functions/v1/fhir-observation?patient=<uuid> → entry[].resource
{
  "resourceType": "Observation",
  "id": "<uuid>",
  "meta": {
    "lastUpdated": "<received_at | collection_date>",
    "profile": [
      "http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab"
    ]
  },
  "status": "final",
  "category": [{
    "coding": [{
      "system": "http://terminology.hl7.org/CodeSystem/observation-category",
      "code": "laboratory",
      "display": "Laboratory"
    }]
  }],
  "code": {
    "coding": [{ "system": "http://loinc.org", "code": "<LOINC>", "display": "<test name>" }],
    "text": "<test name>"
  },
  "subject": { "reference": "Patient/<uuid>" },
  "effectiveDateTime": "<collection_date>",
  "valueQuantity": { "value": 0, "unit": "<result_unit>" },
  "interpretation": [{
    "coding": [{
      "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation",
      "code": "A",
      "display": "Abnormal"
    }]
  }],
  "referenceRange": [{ "text": "<reference_range>" }]
}

source: supabase/functions/fhir-observation/index.ts — observationToFHIR()

The Bundle wrapper

searchset Bundle — identical across every fhir-* endpoint
{
  "resourceType": "Bundle",
  "id": "<uuid>",
  "type": "searchset",
  "total": 0,
  "link": [{ "relation": "self", "url": "<endpoint>" }],
  "entry": [{ "fullUrl": "<endpoint>/<id>", "resource": { } }]
}

Errors

The unified fhir-api endpoint returns a FHIR OperationOutcome:

401 · application/fhir+json
{
  "resourceType": "OperationOutcome",
  "issue": [{
    "severity": "error",
    "code": "login",
    "diagnostics": "Missing authorization"
  }]
}

Stated precisely so nobody is surprised by it: the five resource-specific endpoints return the same application/fhir+json content type but carry a plain { "error": "<message>" } body on failure rather than an OperationOutcome. Code against both shapes. Bringing them into line is a documented, non-breaking change to the error envelope only.

Authentication and scoping

Keys are 32 bytes of CSPRNG output, hex-encoded behind a te_ prefix. The plaintext is generated at the client, shown once, and never transmitted for storage — what reaches the server is a SHA-256 hash plus the first ten characters as a lookup prefix. TrueEval cannot recover your key, which is the whole point of storing it that way.

Every request
x-api-key: te_<64 hex chars>

One key, one org

Validation returns the key's org_id and every handler filters its query to it. A child-org key that tries to override ?org_id to a different org gets a 403.

Explicit scopes

Scopes live in permissions.scopes on the key. The FHIR gate accepts the exact scope, fhir:*, or *, and rejects everything else.

Expiry and revocation

expires_at is checked on every validation, and is_active=false takes a key out immediately. last_used_at is written on each successful call.

Overlapping rotation

Keys carry rotated_from and overlap_until, so a replacement can be issued and cut over before the old key stops working.

Scopes

ScopeGrants
intake:writeSubmit patient intake data
patients:readRead patient records
patients:writeCreate/update patients
appointments:readRead appointments
appointments:writeCreate appointments
labs:readRead lab results and kit status
labs:writeDispatch lab kits, submit lab results
notes:readRead clinical chart notes
prescriptions:readRead prescription status
prescriptions:writeCreate prescriptions
billing:readRead billing and charge data
billing:writeCreate charges and payments
queue:readView visit queue
queue:writeCreate queue items
webhooks:manageManage webhook config
fhir:readRead the FHIR R4 resource endpoints. fhir:* and * also satisfy the gate.

Each key also carries rate_limit_rpm, which defaults to 60 requests per minute at issue. Exceeding it returns 429.

source: supabase/functions/_shared/api-auth.ts · create-api-key/index.ts · list-api-keys/index.ts · src/components/api-docs/ApiKeyManager.tsx

POST/functions/v1/create-api-key
Admin-role session required. Body carries org_id, name, key_hash, key_prefix, permissions, rate_limit_rpm. Returns { "id": "<uuid>" }.
POST/functions/v1/list-api-keys
Body { "org_id": "<uuid>" }. Returns key metadata only — id, name, key_prefix, permissions, rate_limit_rpm, is_active, created_at, last_used_at, overlap_until, rotated_from. Never the key.

Partner REST API

A storefront reads the catalog, hands intake off after checkout, and polls status. Three endpoints cover it, and the contract they implement is versioned with its change history recorded in the handler.

GET/functions/v1/api-treatment-catalog?org_id=<uuid>
The canonical catalog. contract_version: "v1.7". Served with Cache-Control: public, max-age=60, so a pricing change made in the admin UI is visible to a storefront inside a minute with no cron and no local mirror. Authenticate with x-api-key (the key resolves its own org) or pass org_id; neither is a 400.
POST/functions/v1/api-patient-intake
Single-protocol intake with partner prefill, for funnels that collect clinical data before checkout. Returns 201. Idempotent on external_order_id / external_reference within an org.
POST/functions/v1/external-intake-webhook
Cart-shaped intake handoff for partners running their own checkout. Upserts the patient, creates the queue item, generates form-fill links, and returns a magic link that signs the patient straight into the portal. Idempotent on external_order_id.
GET/functions/v1/api-patient-status?patient_id=<uuid>
Or ?external_patient_id=. Returns the patient's current visit, billing, prescriptions, lab kits and event timeline. Verbosity follows the org's configured detail level — minimal returns four base fields only, standard adds operational detail, detailed adds protected fields.

Cost basis is redacted at the boundary

The catalog endpoint answers unauthenticated reads by design, because patient-facing prices are meant to be public. Wholesale cost and computed margin are not. redactCostBasis removes floor_cost_cents, mso_margin_cents and affiliate_margin_cents from a deep copy before any anonymous response is serialized — at both success exits, and after the snapshot cache rather than before it, so a cached payload can never leak fields the fresh path strips. API-key holders still receive them, because the contract owes them. A field that happens to be null and a field that is redacted look identical in a probe and are not the same guarantee.

source: supabase/functions/_shared/catalog-redaction.ts

Catalog response

GET /functions/v1/api-treatment-catalog — as an API-key holder sees it
{
  "org": { "id": "<uuid>", "slug": "<slug>", "name": "<display name>" },
  "updated_at": "<ISO 8601>",
  "contract_version": "v1.7",
  "programs": [{
    "id": "<uuid>",
    "program_id": "<uuid>",
    "slug": "<slug>",
    "name": "<display name>",
    "description": "<resolved from program, falling back to root protocol>",
    "patient_facing_summary": "<long-form>",
    "marketing_hero_subtitle": "<one-liner>",
    "category": "<service_line>",
    "modality": "<modality_policy>",
    "modality_policy": "<modality_policy>",
    "renewal_mode": "<renewal_mode>",
    "patient_price_cents": 0,
    "floor_cost_cents": 0,
    "mso_margin_cents": 0,
    "affiliate_margin_cents": 0,
    "pricing_strategy": "margin_pct | flat_dollar | pass_through",
    "source": "mso_treatment_pricing | no_wholesale_on_file",
    "is_active": true,
    "show_on_marketing_site": true,
    "duration_days": 30,
    "includes_medication": true,
    "includes_lab": false,
    "lab_panel_included": null
  }],
  "protocols": [{
    "id": "<uuid>",
    "slug": "<slug>",
    "name": "<display name>",
    "description": "<clinical description>",
    "category": "<legacy taxonomy>",
    "marketing_category": "<8-value enum>",
    "patient_facing_summary": "<long-form>",
    "marketing_hero_subtitle": "<one-liner>",
    "duration_days": 30,
    "is_active": true,
    "show_on_marketing_site": true,
    "is_visit_only": false,
    "is_controlled": false,
    "requires_dea": false,
    "requires_sync_modality": false,
    "patient_price_cents": 0,
    "floor_cost_cents": 0,
    "mso_margin_cents": 0,
    "pricing_strategy": "margin_pct",
    "tier_count": 0,
    "source": "protocol_pricing | tier_pricing_only | no_pricing_on_file",
    "updated_at": "<ISO 8601>",
    "labs_required": { "baseline": true, "ongoing": false, "max_age_days": 90 },
    "lab_panel": {
      "display_name": "<panel>",
      "gender": "<gender>",
      "biomarkers": [],
      "biomarker_count": 0,
      "fasting_required": false,
      "turnaround_days": 0,
      "collection_type": "<collection_type>",
      "lab_partner": "TrueLabs"
    }
  }],
  "platform_features": [{
    "feature_key": "...",
    "title": "...",
    "description": "...",
    "icon_slug": "...",
    "display_order": 0
  }]
}

source: supabase/functions/api-treatment-catalog/index.ts · INTEGRATION-CONTRACT.md

Intake response

POST /functions/v1/api-patient-intake → 201
{
  "success": true,
  "patient_id": "<uuid>",
  "queue_item_id": "<uuid>",
  "queue_item_ids": ["<uuid>"],
  "cart_size": 1,
  "intake_link": "<url>",
  "intake_url": "<url>",
  "portal_url": "<url>",
  "intake_link_2": "<url>",
  "intake_url_2": "<url>",
  "checkout_url": "<url>",
  "magic_link_url": "<url | null>",
  "checkout_magic_link": "<url | null>",
  "status": "<queue item status>",
  "payment_required": false
}

treatment_type must be a canonical protocol slug drawn from protocols[] in the catalog; treatment_protocol_ids[] carries the full cart, primary first. Protocol ids are validated against the live catalog before any patient row is created, so a stale snapshot fails fast with the offending ids echoed back rather than creating a half-formed record.

source: supabase/functions/api-patient-intake/index.ts

Webhooks

Subscribe an HTTPS endpoint, pick the events you want, and receive a signed envelope. One builder produces the wire body for both live deliveries and test pings, so a receiver that parses the test parses production.

Every event, same envelope
{
  "id": "<uuid>",
  "timestamp": "<ISO 8601>",
  "event": "prescription.dispatched",
  "entity_type": "prescription",
  "entity_id": "<uuid>",
  "org_id": "<uuid>",
  "data": { }
}

source: supabase/functions/_shared/webhook-delivery-body.ts

Subscribable events

EventFires when
chart_review.completedA provider finalizes a chart.
visit.completedA visit is finalized.
patient.intake_startedA patient begins intake.
patient.intake_completedIntake forms are done.
prescription.dispatchedAn Rx is routed to a pharmacy.
lab_kit.shippedA lab kit ships to the patient.
lab_kit.deliveredA lab kit is delivered.
lab_results.availableLab results are ready.
payment.collectedA payment succeeds.
payment.failedA payment attempt fails.

Billing integrations can additionally receive commission.settled and commission.reversed, and webhook.test is the ping event. A subscription only receives the events it lists, scoped to its own org — an event for one org can never be delivered to another org's endpoint.

source: src/components/api-docs/WebhookConfig.tsx · supabase/functions/_shared/webhook-emit.ts

Headers

Content-Type:         application/json
X-Webhook-ID:         <delivery uuid>
X-Webhook-Signature:  sha256=<hmac>
X-Idempotency-Key:    <outbox row id>   # stable across retries of one row
X-Event-Id:           <sha256 hex>      # stable per LOGICAL event
X-Event-Sequence:     <epoch micros>    # monotonic per destination
User-Agent:           Healthcare-Webhook/1.0

Verifying the signature

the exact scheme, from webhook-sign.ts
// lowercase-hex HMAC-SHA256 of the RAW JSON body string,
// keyed by the subscription secret. Compare against the value
// after "sha256=" in X-Webhook-Signature.
const key = await crypto.subtle.importKey(
  "raw",
  new TextEncoder().encode(secret),
  { name: "HMAC", hash: "SHA-256" },
  false,
  ["sign"],
);
const signature = await crypto.subtle.sign(
  "HMAC", key, new TextEncoder().encode(rawBody),
);
const hex = Array.from(new Uint8Array(signature))
  .map((b) => b.toString(16).padStart(2, "0"))
  .join("");

source: supabase/functions/_shared/webhook-sign.ts

The delivery guarantee

What is guaranteed

  • Ordered, at-least-once, per destination. One subscription is one destination. Events for a destination are delivered serially in created_at order, ties broken deterministically.
  • Ordering holds under failure. The first failure for a destination stops that destination for the rest of the run, so nothing behind a failed event is delivered ahead of it.
  • Destinations are independent. A stuck destination never blocks another.
  • Failures are bounded. Backoff is full-jitter exponential from a 30-second base, capped at 6 hours. After 12 attempts the head event is dead-lettered, which unblocks the destination. An admin can replay a dead-lettered row.

What is not

  • No global ordering. Ordering is per-destination only.
  • At-least-once, not exactly-once. A delivery that succeeds at your end but whose 2xx we fail to observe will be retried. Deduplicate on X-Idempotency-Key (stable per outbox row) or X-Event-Id (stable per logical event).
  • A failing destination blocks its own queue, by design, until the head event dead-letters.
  • Redirects are not followed. The endpoint must be a public https:// URL; a 3xx surfaces as a failed delivery rather than being chased, because a public URL redirecting to an internal address would defeat the SSRF guard.

source: supabase/functions/webhook-deliver/index.ts · supabase/functions/_shared/webhook-delivery-policy.ts

Testing your receiver

POST/functions/v1/send-test-webhook
Body { "org_id": "<uuid>" }, optionally with "event": "commission.settled". Loads your own subscription, signs a test envelope with your own secret, POSTs it to your real endpoint, and returns { ok, delivered, status, endpoint, response_body, message } carrying the live HTTP status your receiver gave. It exercises the rail real events use, not a parallel one — a green ping means production traffic arrives the same way.

source: supabase/functions/send-test-webhook/index.ts

Versioning

The partner contract is versioned and every response carries its version in contract_version. The change history is recorded in the handler itself rather than in a changelog that can drift from it — v1.4 added the protocol layer alongside programs, v1.5 added the labs_required and lab_panel blocks, v1.6 white-labelled lab_panel, and v1.7 made a single enablement toggle the sole gate on storefront visibility.

Compatibility commitments

  • Fields are never removed from an existing event payload in a minor version.
  • Fields are never renamed. New ones are added alongside.
  • New fields may appear in data at any v1.x bump, so parse defensively.
  • Additive changes are additive: a client that ignores a new field keeps working. Both labs_required and protocols[] shipped that way, with programs[] preserved unchanged for back-compat.

source: INTEGRATION-CONTRACT.md · supabase/functions/api-treatment-catalog/index.ts

Errors

HTTPerrorMeaning
401Invalid API keyThe key hash matched nothing active, or the key was never sent.
401API key has expiredexpires_at is in the past.
403Missing required scope: <scope>The key is valid but its permissions.scopes array does not include the scope this endpoint requires, nor a fhir:* or * wildcard.
403api key does not have access to requested org_idA child-org key attempted to override ?org_id to a different org.
400x-api-key header or org_id query parameter requiredThe catalog endpoint could not resolve an org.
400invalid_uuidA request field carried a malformed UUID. Returned as a caller error, never as a 500.
400protocol_requiredtreatment_type / treatment_slug did not resolve to a protocol with a default_protocol_id. Re-fetch the catalog.
400invalid_protocol_idsOne or more treatment_protocol_ids do not exist. Body echoes the offending ids. You are on a stale catalog snapshot.
400disabled_protocol_idsThe ids exist but are flagged is_active=false. Stop selling them and re-fetch.
400service_line_unresolvedThe resolved program carries no service_line, so intake dedup cannot be keyed. Fails loud rather than mis-bucketing.
409Duplicate requestSame patient and treatment within five minutes.
429Rate limit exceededAbove the key's rate_limit_rpm.

Non-FHIR endpoints return { "error": "<code>", "message": "<detail>" } as application/json. Where a validation failure names specific inputs, the offending values are echoed back — an invalid_protocol_ids response lists exactly which ids failed, so the fix is mechanical rather than a support thread.

What this page does not claim

Everything above is the shape of a contract that exists, transcribed from the code that serves it. Some things a developer might reasonably expect on a page like this are missing on purpose:

  • ·No throughput, volume or SLA numbers. Several of these surfaces are built and integration-tested rather than exercised at volume. Publishing a capability is honest; publishing a fill rate or a latency guarantee we have not measured would not be.
  • ·No uptime or availability commitment. That belongs in a signed agreement, scoped to what you are actually running.
  • ·No security certification. The platform carries real controls — audit logging on every PHI access, break-glass records, consent versioning, SSRF-guarded egress, fail-closed authorization on patient-scoped reads. Those are controls, not an attestation, and this page will not imply one.
  • ·No live base URL or sandbox credential. The host and the key are issued together, so a key is never in flight without a counterparty.

How does this affect your practice?

Take the assessment to see how this regulatory change impacts your specific business and where you're exposed.

Frequently asked questions

Can I export my clinical data out of TrueEval?
Yes, and it is an API call rather than a contract negotiation. Patient records are addressable as FHIR R4 through six endpoints, exportable as a complete FHIR Bundle through export-patient-records, and exportable as C-CDA 2.1 XML through generate-ccda. Every export writes a PHI-access audit row before the bytes leave.
What authentication does the TrueEval API use?
An x-api-key header carrying a te_-prefixed key. TrueEval stores only the SHA-256 hash of the key, never the key itself, so it cannot be recovered after issue. Every key resolves to exactly one org, carries an explicit scope array, an optional expiry, and a per-minute rate limit. The unified FHIR endpoint additionally accepts a Bearer JWT.
Which FHIR version does TrueEval implement?
FHIR R4 (4.0.1), as declared by the CapabilityStatement the unified endpoint returns. Resources are profiled against US Core where a profile exists — us-core-patient, us-core-observation-lab, us-core-condition and us-core-medicationrequest. Responses are served as application/fhir+json.
How are webhook deliveries secured and retried?
Every body is signed with HMAC-SHA256 keyed by the subscription secret and sent as X-Webhook-Signature: sha256=<hex>. Delivery is ordered and at-least-once per destination, with full-jitter exponential backoff from a 30-second base to a 6-hour ceiling and a dead-letter after 12 attempts. Endpoints must be public HTTPS; redirects are not followed.
Can I test my webhook receiver before any real traffic exists?
Yes. send-test-webhook signs a test envelope with your own subscription secret and POSTs it to your real endpoint through the same code path a live event uses, then returns the HTTP status your receiver gave. The test body is built by the same function that builds production bodies, so a receiver that parses the test parses live traffic.
Does the partner catalog expose TrueEval's cost basis?
Not to unauthenticated callers. redactCostBasis strips floor_cost_cents, mso_margin_cents and affiliate_margin_cents from a deep copy of the payload before any anonymous response is serialized, at both success exits and after the snapshot cache rather than before it. API-key holders receive those fields because the partner contract owes them.

How does this affect your practice?

Take the assessment to see how this regulatory change impacts your specific business and where you're exposed.