MediSynth Open console
API documentation

MediSynth API guide

Build repeatable synthetic patient cohorts, simulate upstream provider variance, and export records into product tests, demos, migrations, and integration QA.

Workflow

Validate and preview, then generate and export.

The guide follows the real automation flow, from cohort spec to retained artifacts.

API sequence4 calls
Quickstart

Generate a cohort

Two credentials, never mixed on one request: tenant routes (/v1/workspace/tenants/{tenantID}/...) accept only X-API-Key with the full one-time secret, and session routes (/v1/workspace/me/...) accept only Authorization: Bearer with a console session token.

Set the placeholders once, then run two calls: a session call to read your workspace summary, and a tenant call that queues a retained cohort job.

cURL
# 1. Session route: read your workspace summary (Bearer only).
curl https://api.cloud.medisynth.io/v1/billing/me \
  -H "Authorization: Bearer $MEDISYNTH_TOKEN"

# 2. Tenant route: create a retained cohort job (X-API-Key only).
curl -X POST https://api.cloud.medisynth.io/v1/workspace/tenants/$MEDISYNTH_TENANT_ID/cohort-jobs \
  -H "X-API-Key: $MEDISYNTH_API_KEY" \
  -H "Idempotency-Key: quickstart-001" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "enterprise-mpi-evaluation",
    "population": 1000,
    "seed": 4107,
    "geography": { "state": "Washington", "city": "Vancouver" },
    "demographics": {
      "ageBands": [
        { "label": "0-17", "min": 0, "max": 17, "weight": 0.18 },
        { "label": "18-64", "min": 18, "max": 64, "weight": 0.58 },
        { "label": "65+", "min": 65, "max": 94, "weight": 0.24 }
      ],
      "sexAtBirth": { "female": 0.52, "male": 0.48 },
      "payerMix": { "commercial": 0.48, "medicare": 0.24, "medicaid": 0.23, "self-pay": 0.05 },
      "language": { "en": 0.78, "es": 0.15, "other": 0.07 }
    },
    "conditions": [
      { "name": "diabetes-type-2", "prevalence": 0.42 },
      { "name": "hypertension", "prevalence": 0.64 }
    ],
    "hie": {
      "sourceSystems": ["regional-hie", "county-provider", "claims-feed", "lab-network"],
      "duplicateRate": 0.11,
      "addressDriftRate": 0.22,
      "missingPhoneRate": 0.14
    },
    "exports": { "formats": ["json", "ndjson", "manifest"] }
  }'

Poll GET /v1/workspace/tenants/{tenantID}/cohort-jobs/{jobID} with the same API key until status is available, then list and download the retained artifacts. Prefer a typed client? The SDKs below wrap the same job flow.

Endpoints

Endpoint map by capability

The OpenAPI contract defines 198 operations. The groups below list representative routes by capability; the interactive reference renders every operation, schema, and example live from openapi.yaml. Endpoint responses are deterministic for a given seed and spec, so they work cleanly in CI and repeatable product demos.

Cohorts & scenarios

Validate and preview a spec, browse built-in scenarios, then create retained generation jobs.

GET/v1/cohorts/scenarios
POST/v1/cohorts/validate
POST/v1/cohorts/preview
POST/v1/workspace/tenants/{tenantID}/cohort-jobs
POST/v1/workspace/tenants/{tenantID}/cohort-jobs/from-scenario
Open in reference

Artifacts & exports

Inspect job artifact inventories, stream files, or mint signed download URLs. Job export formats include FHIR, NDJSON, CSV, X12 837/835, and OMOP CDM (omop or omop-parquet).

GET/v1/workspace/tenants/{tenantID}/cohort-jobs/{jobID}/artifacts
GET/v1/workspace/tenants/{tenantID}/cohort-jobs/{jobID}/artifacts/{fileName}
GET/v1/workspace/tenants/{tenantID}/cohort-jobs/{jobID}/artifacts/{fileName}/download-url
POST/v1/cohorts/export/fhir
POST/v1/cohorts/export/flat/{fileName}
Open in reference

Convert & validate

Validate FHIR resources and C-CDA documents, and convert between C-CDA and FHIR under workspace quota.

POST/v1/workspace/tenants/{tenantID}/validate/fhir
POST/v1/workspace/tenants/{tenantID}/validate/ccda
POST/v1/convert/ccda-to-fhir/tenants/{tenantID}
POST/v1/convert/fhir-to-ccda/tenants/{tenantID}
GET/v1/convert/capabilities
Open in reference

HIE simulator & topology

Retrieve per-provider views over XCA and XCPD, and validate or preview exchange topology before generating.

POST/v1/simulator/upstream/retrieve
POST/v1/simulator/upstream/xca/query
POST/v1/simulator/upstream/xcpd/discover
POST/v1/cohorts/topology/validate
POST/v1/cohorts/topology/preview
Open in reference

Conformance packs

List conformance packs, run them against the workspace, and read the SARIF scorecard for a job.

GET/v1/conformance/packs
POST/v1/conformance/packs/{packID}/run
GET/v1/workspace/tenants/{tenantID}/cohort-jobs/{jobID}/scorecard.sarif.json
Open in reference

Trust audit & attestations

Inspect trust-bundle status, run a trust audit, and verify signed cohort attestations.

GET/v1/simulator/upstream/trust/status
POST/v1/simulator/upstream/trust/audit
POST/v1/attestations/verify
Open in reference

Billing & usage

Read plans and the current workspace summary, export the usage ledger, and check remaining quota. Generation and other MediSynth workflows record their own metered usage automatically.

GET/v1/billing/plans
GET/v1/billing/me
GET/v1/billing/tenants/{tenantID}/usage/export
GET/v1/workspace/tenants/{tenantID}/quota
Open in reference

Webhooks & deliveries

Register webhook endpoints, test or rotate them, and audit cohort-job deliveries.

POST/v1/workspace/tenants/{tenantID}/webhooks
GET/v1/workspace/tenants/{tenantID}/webhooks
POST/v1/workspace/tenants/{tenantID}/webhooks/{webhookID}/test
GET/v1/workspace/tenants/{tenantID}/cohort-jobs/{jobID}/deliveries
Open in reference

Health & status

Unauthenticated probes for uptime checks and the public status page.

GET/v1/
GET/v1/heartbeat
GET/v1/status
Open in reference
SDKs

Client SDKs

Typed Python, TypeScript, and Go clients are generated from the same OpenAPI contract — one method per operation across all 198 operations — and live in this repository under sdks/. Installs are monorepo-local; registry publishing is not available yet. Every client raises a structured error carrying the API code, requestId, and problem detail.

TypeScript
# Build from the monorepo (Node 20.6+)
cd sdks/typescript
npm install
npm run build

# First call: create a retained cohort job on a tenant route (X-API-Key)
import { MediSynthClient } from "@medisynth/sdk";

const client = new MediSynthClient({ apiKey: process.env.MEDISYNTH_API_KEY });
const { job } = await client.createWorkspaceCohortJob(process.env.MEDISYNTH_TENANT_ID ?? "", {
  name: "quickstart",
  population: 25,
  seed: 4107,
  exports: { formats: ["fhir", "ndjson"] }
});
console.log(job.id, job.status);
Python
# Install from the monorepo (stdlib only, no runtime dependencies)
cd sdks/python
pip install -e .

# First call: create a retained cohort job on a tenant route (X-API-Key)
from medisynth import MediSynthClient, MediSynthError

client = MediSynthClient(api_key="ms_live_...")
spec = {
    "name": "quickstart",
    "population": 25,
    "seed": 4107,
    "exports": {"formats": ["fhir", "ndjson"]},
}
resp = client.create_workspace_cohort_job("tenant-...", spec)
print(resp["job"]["id"], resp["job"]["status"])
Go
# Install the module (this repository is its own Go module)
go get github.com/MediSynth-io/medisynth/sdks/go/medisynth

# First call: create a retained cohort job on a tenant route (X-API-Key)
import medisynth "github.com/MediSynth-io/medisynth/sdks/go/medisynth"

client := medisynth.New(medisynth.WithAPIKey("ms_live_..."))
resp, err := client.CreateWorkspaceCohortJob(ctx, tenantID, medisynth.CohortSpec{
    Name:       "quickstart",
    Population: 25,
    Seed:       4107,
    Exports:    medisynth.ExportProfile{Formats: []string{"fhir", "ndjson"}},
}, medisynth.CreateWorkspaceCohortJobParams{})

Spec fixtures: replay explainability

Replay drift fixtures for HIE ingestion tests, passed as the cohort spec hie.qualityTargets block.

Replay explainability: fully traced
{
  "name": "fully-traced-hie-replay",
  "population": 750,
  "seed": 4107,
  "hie": {
    "sourceSystems": ["regional-hie", "county-clinic", "lab-network"],
    "qualityTargets": {
      "documentIngestion": "medium",
      "replayExplainability": "high"
    }
  },
  "exports": { "formats": ["json", "ndjson", "manifest"] }
}
Replay explainability: negative ingestion fixture
{
  "request": {
    "name": "unmatched-replay-drift",
    "population": 750,
    "seed": 4108,
    "hie": {
      "sourceSystems": ["regional-hie", "county-clinic", "lab-network"],
      "qualityTargets": {
        "documentIngestion": "medium",
        "replayExplainability": "low"
      }
    }
  },
  "expectedQualityShape": {
    "sourceReplayCausality": {
      "matchRate": "less than 1.0",
      "unmatchedReasonCounts": {
        "missing-stale-cache-window": "present",
        "missing-missing-document-retry": "present",
        "missing-source-omission-notice": "present when source omissions are generated"
      }
    }
  }
}
Schemas

Request and response fields

Use these fields to build typed clients, fixtures, and account usage views.

Authentication

HeaderApplies toDescription
X-API-KeyTenant routes (/v1/workspace/tenants/{tenantID}/...)The full one-time API key secret from the console Keys view. The only credential tenant routes accept.
AuthorizationSession routes (/v1/workspace/me/...)Bearer console session token. The only credential session routes accept.
Idempotency-KeyOptional on job creation and usage meteringStable retry key. Reusing it with a different payload returns 409.
Content-TypePOSTUse application/json for JSON request bodies.

Do not mix the two credentials: tenant routes do not accept a session bearer, and session routes do not accept an API key.

Cohort request

FieldTypeDescription
namestringHuman-readable scenario or cohort identifier.
populationnumberTotal synthetic patient count to generate.
seednumberDeterministic seed for repeatable cohorts.
conditionsarrayClinical conditions with prevalence targets.
hieobjectProvider spread, missingness, and identity drift settings.
hie.qualityTargetsobjectOptional workflow fixture targets for MPI, document ingestion, payer reconciliation, labs, provider routing, privacy, and replay explainability.
hie.qualityTargets.replayExplainabilitystringhigh keeps replay drift fully traceable; medium and low intentionally leave selected drift rows unmatched for negative HIE ingestion tests.

Generate response

FieldTypeDescription
manifestobjectResource counts, source-record counts, and duplicate identity totals.
qualityobjectDeterministic seed, document count, demographics, conditions, mutations, source-system counts, and warnings.
quality.sourceReplayCausalityobjectTraceability summary for stale, retry, source-omission, correction, and late-arriving replay drift rows.
patients[].documentsarrayLinked clinical documents generated from encounters, conditions, and observations.
sources[].endpointobjectReserved provider hostname, simulated CNAME, TEST-NET IP, auth mode, TLS/mTLS posture, rate limit, timeout, and allowlist requirements for upstream simulator responses.
patientSummariesarrayShort inspection strings for generated patients.
Abbreviated generate response
{
  "spec": { "name": "mpi-hard-matches", "population": 250 },
  "preview": { "documents": { "estimatedDocumentCount": 2076 } },
  "manifest": {
    "sourcePatientRecordCount": 1038,
    "resourceCounts": {
      "Patient": 1038,
      "DiagnosticReport": 1038,
      "DocumentReference": 2076
    }
  },
  "quality": {
    "documentCount": 2076,
    "conditionCounts": { "asthma": 40, "hypertension": 78 }
  },
  "patients": [
    {
      "sourceSystem": "north-hie",
      "documents": [
        { "type": "encounter-summary", "text": "..." }
      ]
    }
  ],
  "patientSummaries": ["1 -- Ava Garcia (1974-01-01, female) Vancouver, Washington"]
}

Usage event

FieldTypeDescription
patientsGeneratednumberGenerated patient count for the metered event.
sourceRecordsnumberTotal provider-specific records created.
fhirResourcesnumberTotal exported clinical resources.
generationJobCountnumberNumber of generation jobs to record.

Error model

FieldTypeDescription
errorstringHuman-readable failure detail; mirrors detail.
typestringProblem type URI: https://api.medisynth.io/errors/<code>.
titlestringShort problem summary.
statusnumberHTTP status code, repeated in the body.
codestringStable machine-readable reason, such as validation_failed, quota_exceeded, or rate_limit_exceeded.
detailstringHuman-readable corrective detail.
requestIdstringIdentifier to correlate client and server logs; quote it in support requests.
retryablebooleantrue when an immediate retry can succeed.
retryAfterSecondsnumberSeconds to wait before retrying; present on retryable 429 responses and mirrors the Retry-After header.
fields / errorsarrayPer-field validation failures ({ "field", "message" }) on 400 validation_failed; both arrays carry the same rows.
quotaobjectPlan quota and current usage metadata on 402 quota_exceeded.
400 validation_failed
{
  "error": "population must be greater than zero",
  "type": "https://api.medisynth.io/errors/validation_failed",
  "title": "Cohort validation failed",
  "status": 400,
  "code": "validation_failed",
  "detail": "population must be greater than zero",
  "requestId": "req-7f3c9a21d0b44e86",
  "retryable": false,
  "valid": false,
  "fields": [
    { "field": "population", "message": "must be greater than zero" }
  ],
  "errors": [
    { "field": "population", "message": "must be greater than zero" }
  ]
}
429 concurrent_generation_limit
{
  "error": "concurrent generation job limit reached for the current plan",
  "type": "https://api.medisynth.io/errors/concurrent_generation_limit",
  "title": "Too many concurrent jobs",
  "status": 429,
  "code": "concurrent_generation_limit",
  "detail": "concurrent generation job limit reached for the current plan",
  "requestId": "req-2b8e14f7c3a54c29",
  "retryable": true,
  "retryAfterSeconds": 30
}
Operational behavior

Failure responses stay predictable.

Every failed request returns the same problem envelope — status, code, detail, and requestId — so callers can retry, correct the payload, or pause generation. A 402 quota_exceeded response also carries plan quota metadata.

400 · validation_failed

Invalid spec

Malformed JSON, impossible prevalence, or unsupported cohort settings; the fields array lists each failing field.

401 · authentication_required

Unauthenticated

The API key or session token is missing, invalid, expired, or sent to the wrong route family.

429 · rate_limit_exceeded

Rate limited

The account or calling client is above the allowed request rate; retryable responses carry retryAfterSeconds.