Phenoml API · Reference

Clinical text in.
Structured data out.

10 services, one REST API. Every endpoint speaks JSON over HTTPS, authenticates with a bearer token, and returns citations you can trace back to the source. 73 endpoints across 10 groups.

Base URLhttps://experiment.app.pheno.ml
POSTQuickstart
curl -X POST 'https://experiment.app.pheno.ml/auth/token' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "token": "eyJhbGciOiJSUzI1NiJ9..."
}

Errors

Conventional HTTP status codes: 2xx for success, 4xx for problems with the request, and 5xx for problems on our side. Failed platform endpoints return a JSON envelope with success: false and a human-readable message.

Status codes

200 · 201 · 202

Success. Creates usually return 201; asynchronous work such as code-system uploads and bulk operations may return 202.

400

Invalid request: malformed body, missing required fields, or values that fail validation.

401

Missing or expired bearer token.

403

Forbidden: plan limits, ownership rules, or modifying sandbox or built-in resources.

404

Resource not found.

409

Conflict, such as uploading a code system whose name and version already exist without replace.

422

Semantically invalid, such as FHIR that fails profile validation.

500

Server error. It is safe to retry idempotent reads.

404 Not FoundError envelope
{
  "success": false,
  "message": "FHIR provider not found"
}

Common headers

These platform headers thread identity and EHR credentials through FHIR-touching calls, including tools, agents, the FHIR proxy, and the platform MCP endpoint.

Headers

Authorizationrequired

Bearer token from the auth endpoint. The SDKs attach and refresh it automatically.

X-Phenoml-On-Behalf-Ofoptional

Act in a user context: Patient/{uuid} or Practitioner/{uuid}. Required for patient-facing apps so requests are scoped accordingly.

X-Phenoml-Fhir-Provideroptional

Per-request FHIR provider credentials, formatted as {fhir_provider_id}:{oauth2_token}, for apps where users bring their own EHR tokens instead of stored provider credentials.

POSTHeaders in practice
curl -X POST "https://experiment.app.pheno.ml/tools/lang2fhir-and-search" \
  -H "Authorization: Bearer $PHENOML_TOKEN" \
  -H "X-Phenoml-On-Behalf-Of: Patient/550e8400-e29b-41d4-a716-446655440000" \
  -H "Content-Type: application/json" \
  -d '{ "text": "my appointments next week" }'

Authentication

Manage API credentials, generate authentication tokens, and handle authorization.

Generate authentication token

POST/auth/token

Generates a JWT token using Basic Authentication with API credential client ID and secret.

RequiresBearerauthentication
Returns  

Successfully generated token

Response fields

tokenstringrequired

JWT token to be used for subsequent authenticated requests

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/auth/token' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "token": "eyJhbGciOiJSUzI1NiJ9..."
}

Request an access token

POST/v2/auth/token

OAuth 2.0 client credentials token endpoint (RFC 6749 §4.4). Accepts client_id and client_secret in the request body (JSON or form-encoded) or via Basic Auth header (RFC 6749 §2.3.1), and returns an access token with expiration information.

RequiresBearerauthentication

Body parameters

grant_typestringoptional

Must be "client_credentials" if provided

client_idstringoptional

The client ID (credential username)

client_secretstringoptional

The client secret (credential password)

Returns  

Successfully generated token

Response fields

access_tokenstringrequired

JWT access token for subsequent authenticated requests

token_typestringrequired

Token type (always "Bearer")

expires_inintegerrequired

Token lifetime in seconds

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/v2/auth/token' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "client_id": "your_client_id",
  "client_secret": "your_client_secret"
}'
200 OKResponse
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 172800
}

Submit feedback on extraction results

POST/construe/feedback

Submits user feedback on results from the Construe extraction endpoint. Feedback includes the full extraction result received and the result the user expected.

RequiresBearerauthentication

Body parameters

textstringrequired

The natural language text that was used for code extraction

received_resultobjectrequired
systemobjectrequired
namestringoptional

Code system name. Can be a built-in system or a custom system name.

Built-in systems:

  • SNOMED_CT_US_LITE - version 20240901
  • RXNORM - version 11042024
  • ICD-10-CM - version 2025
  • ICD-10-PCS - version 2025
  • LOINC - version 2.78
  • HPO - version 2025
  • CPT - version 2025

Custom systems:

  • Any valid system name uploaded via /construe/upload. Requires a paid plan.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

versionstringoptional

Code system version. Must match the version available in your environment.

codesobject[]required
codestringrequired

The extracted code

descriptionstringrequired

Short description of the code

validbooleanrequired

Whether the code passed validation. Always true unless include_invalid is set to true, in which case invalid codes will have this set to false.

reasonstringoptional

Explanation for why this code was extracted (if include_rationale is true)

is_ancestorbooleanoptional

Whether this code is an ancestor (parent) of an extracted code rather than directly extracted. Only present when include_ancestors is true.

citationsobject[]optional

Source text references showing where this code was found in the input. Only present when include_citations is true and chunking method supports it. Ancestor codes do not receive citations.

categoriesobject[]optional

Higher-level groupings the extracted code belongs to (e.g. HPO category terms). Only populated by full-extraction chunking methods such as "fasthpocr".

expected_resultobjectrequired
systemobjectrequired
namestringoptional

Code system name. Can be a built-in system or a custom system name.

Built-in systems:

  • SNOMED_CT_US_LITE - version 20240901
  • RXNORM - version 11042024
  • ICD-10-CM - version 2025
  • ICD-10-PCS - version 2025
  • LOINC - version 2.78
  • HPO - version 2025
  • CPT - version 2025

Custom systems:

  • Any valid system name uploaded via /construe/upload. Requires a paid plan.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

versionstringoptional

Code system version. Must match the version available in your environment.

codesobject[]required
codestringrequired

The extracted code

descriptionstringrequired

Short description of the code

validbooleanrequired

Whether the code passed validation. Always true unless include_invalid is set to true, in which case invalid codes will have this set to false.

reasonstringoptional

Explanation for why this code was extracted (if include_rationale is true)

is_ancestorbooleanoptional

Whether this code is an ancestor (parent) of an extracted code rather than directly extracted. Only present when include_ancestors is true.

citationsobject[]optional

Source text references showing where this code was found in the input. Only present when include_citations is true and chunking method supports it. Ancestor codes do not receive citations.

categoriesobject[]optional

Higher-level groupings the extracted code belongs to (e.g. HPO category terms). Only populated by full-extraction chunking methods such as "fasthpocr".

detailstringoptional

Optional details explaining the feedback

Returns  

Feedback saved successfully

Response fields

idstringrequired

The ID of the saved feedback

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/construe/feedback' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Patient has type 2 diabetes with hyperglycemia",
  "received_result": {
    "system": {
      "name": "SNOMED_CT_US_LITE",
      "version": "20240901"
    },
    "codes": [
      {
        "code": "195967001",
        "description": "Asthma",
        "valid": true,
        "reason": "example",
        "is_ancestor": true,
        "citations": [
          {
            "text": "Patient has type 2 diabetes",
            "begin_offset": 0,
            "end_offset": 27
          }
        ],
        "categories": [
          {
            "uri": "HP:0025142",
            "label": "Constitutional symptom"
          }
        ]
      }
    ]
  },
  "expected_result": {},
  "detail": "Expected code X instead because ..."
}'
201 CreatedResponse
{
  "id": "abc123def456"
}

List available code systems

GET/construe/codes/systems

Returns the terminology server's catalog of available code systems, including both built-in standard terminologies and custom uploaded systems.

RequiresBearerauthentication
Returns  

List of available code systems

Response fields

systemsobject[]required
namestringrequired

Code system name

versionstringrequired

Code system version

code_countintegerrequired

Total number of codes in the system

builtinbooleanrequired

Whether this is a built-in system (vs custom uploaded)

GETRequest
curl 'https://experiment.app.pheno.ml/construe/codes/systems' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "systems": [
    {
      "name": "ICD-10-CM",
      "version": "2025",
      "code_count": 72750,
      "builtin": true
    }
  ]
}

Get code system detail

GET/construe/codes/systems/{codesystem}

Returns full metadata for a single code system, including timestamps and builtin status.

RequiresBearerauthentication

Path parameters

codesystemstringrequired

Code system name (e.g., "ICD-10-CM", "SNOMED_CT_US_LITE")

Query parameters

versionstringoptional

Specific version of the code system. Required if multiple versions exist.

Returns  

Code system detail

Response fields

namestringrequired

Code system name

versionstringrequired

Code system version

code_countintegerrequired

Total number of codes in the system

builtinbooleanrequired

Whether this is a built-in system (vs custom uploaded)

statusstringrequired

Processing status of the code system.

  • "processing": embeddings are being generated
  • "ready": code system is ready for use
  • "failed": processing failed (re-upload with replace=true to retry)
processingreadyfailed
created_atstring (date-time)required

When the code system was created

updated_atstring (date-time)required

When the code system was last updated

GETRequest
curl 'https://experiment.app.pheno.ml/construe/codes/systems/ICD-10-CM?version=2025' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "name": "ICD-10-CM",
  "version": "2025",
  "code_count": 72750,
  "builtin": true,
  "status": "ready",
  "created_at": "2024-01-15T09:30:00Z",
  "updated_at": "2024-01-15T09:30:00Z"
}

Delete custom code system

DELETE/construe/codes/systems/{codesystem}

Deletes a custom (non-builtin) code system and all its codes. Builtin systems cannot be deleted. Only available on dedicated instances. Large systems may take up to a minute to delete.

RequiresBearerauthentication

Path parameters

codesystemstringrequired

Code system name

Query parameters

versionstringoptional

Specific version of the code system. Required if multiple versions exist.

Returns  

Code system deleted successfully

Response fields

messagestringrequired

Confirmation message

DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/construe/codes/systems/CUSTOM_CODES?version=example' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "message": "code system deleted successfully"
}

Export custom code system

GET/construe/codes/systems/{codesystem}/export

Exports a custom (non-builtin) code system as a JSON file compatible with the upload format. The exported file can be re-uploaded directly via POST /construe/upload with format "json". Only available on dedicated instances. Builtin systems cannot be exported.

RequiresBearerauthentication

Path parameters

codesystemstringrequired

Code system name

Query parameters

versionstringoptional

Specific version of the code system. Required if multiple versions exist.

Returns  

Exported code system as JSON file

Response fields

namestringrequired

Code system name

versionstringrequired

Code system version

formatstringrequired

Upload format (always "json")

json
codesobject[]required

All codes in the system

codestringrequired

The code identifier

descriptionstringrequired

Short description of the code

definitionstringoptional

Extended definition of the code (if available)

GETRequest
curl 'https://experiment.app.pheno.ml/construe/codes/systems/CUSTOM_CODES/export?version=example' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "name": "CUSTOM_CODES",
  "version": "1.0",
  "format": "json",
  "codes": [
    {
      "code": "E11.65",
      "description": "Type 2 diabetes mellitus with hyperglycemia",
      "definition": "example"
    }
  ]
}

Upload custom code system

POST/construe/upload

Upload a custom medical code system with codes and descriptions for use in code extraction. Requires a paid plan. Returns 202 immediately; embedding generation runs asynchronously. Poll GET /construe/codes/systems/{codesystem}?version={version} to check when status transitions from "processing" to "ready" or "failed".

RequiresBearerauthentication

Body parameters

namestringrequired

Name of the code system. Names are case-insensitive and stored uppercase. Builtin system names (e.g. ICD-10-CM, SNOMED_CT_US_LITE, LOINC, CPT, etc.) are reserved and cannot be used for custom uploads; attempts return HTTP 403 Forbidden.

versionstringrequired

Version of the code system

revisionnumberoptional

Optional revision number

formatstringrequired

Upload format

csvjson
filestring (byte)optional

The file contents as a base64-encoded string. For CSV format, this is the CSV file contents. For JSON format, this is a base64-encoded JSON array; prefer using 'codes' instead.

code_colstringoptional

Column name containing codes (required for CSV format)

desc_colstringoptional

Column name containing descriptions (required for CSV format)

defn_colstringoptional

Optional column name containing long definitions (for CSV format)

codesobject[]optional

The codes to upload as a JSON array (JSON format only). This is the preferred way to upload JSON codes, as it avoids unnecessary base64 encoding. If both 'codes' and 'file' are provided, 'codes' takes precedence.

codestringrequired

The code identifier

descriptionstringrequired

Short description of the code

definitionstringoptional

Extended definition of the code (if available)

replacebooleanoptionaldefault false

If true, replaces an existing code system with the same name and version. Builtin systems cannot be replaced; attempts to do so return HTTP 403 Forbidden. When false (default), uploading a duplicate returns 409 Conflict.

Returns  

Upload accepted for asynchronous processing

Response fields

statusstringoptional
namestringoptional
versionstringoptional
POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/construe/upload' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "CUSTOM_CODES",
  "version": "1.0",
  "format": "json",
  "codes": [
    {
      "code": "X001",
      "description": "Example custom code 1"
    },
    {
      "code": "X002",
      "description": "Example custom code 2"
    }
  ]
}'
202 AcceptedResponse
{
  "status": "processing",
  "name": "CUSTOM_CODES",
  "version": "1.0"
}

List codes in a code system

GET/construe/codes/{codesystem}

Returns a paginated list of all codes in the specified code system from the terminology server.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

RequiresBearerauthentication

Path parameters

codesystemstringrequired

Code system name (e.g., "ICD-10-CM", "SNOMED_CT_US_LITE")

Query parameters

versionstringoptional

Specific version of the code system. Required if multiple versions exist.

cursorstringoptional

Pagination cursor from previous response

limitintegeroptionaldefault 20

Maximum number of codes to return (default 20)

Returns  

Paginated list of codes

Response fields

systemobjectrequired
namestringrequired

Code system name

versionstringrequired

Code system version

codesobject[]required
codestringrequired

The code identifier

descriptionstringrequired

Short description of the code

definitionstringoptional

Extended definition of the code (if available)

next_cursorstringoptional

Cursor for fetching the next page (null if no more results)

has_morebooleanrequired

Whether there are more results available

GETRequest
curl 'https://experiment.app.pheno.ml/construe/codes/ICD-10-CM?version=2025&limit=5' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "system": {
    "name": "ICD-10-CM",
    "version": "2025"
  },
  "codes": [
    {
      "code": "A00",
      "description": "Cholera"
    },
    {
      "code": "A000",
      "description": "Cholera due to Vibrio cholerae 01, biovar cholerae"
    },
    {
      "code": "A001",
      "description": "Cholera due to Vibrio cholerae 01, biovar eltor"
    },
    {
      "code": "A009",
      "description": "Cholera, unspecified"
    },
    {
      "code": "A01",
      "description": "Typhoid and paratyphoid fevers"
    }
  ],
  "next_cursor": "QTAx",
  "has_more": true
}

Get a specific code

GET/construe/codes/{codesystem}/{codeID}

Looks up a specific code in the terminology server and returns its details.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

RequiresBearerauthentication

Path parameters

codesystemstringrequired

Code system name

codeIDstringrequired

The code identifier. ICD-10-CM codes are stored without their cosmetic dot (use "E1165", not "E11.65").

Query parameters

versionstringoptional

Specific version of the code system

Returns  

Code details

Response fields

systemobjectrequired
namestringrequired

Code system name

versionstringrequired

Code system version

codestringrequired

The code identifier

descriptionstringrequired

Short description of the code

definitionstringoptional

Extended definition of the code (if available)

GETRequest
curl 'https://experiment.app.pheno.ml/construe/codes/ICD-10-CM/E1165' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "system": {
    "name": "ICD-10-CM",
    "version": "2025"
  },
  "code": "E1165",
  "description": "Type 2 diabetes mellitus with hyperglycemia"
}

Semantic search (embedding-based)

GET/construe/codes/{codesystem}/search/semantic

Performs semantic similarity search using vector embeddings.

Availability: This endpoint works for both built-in and custom code systems.

When to use: Best for natural language queries where you want to find conceptually related codes, even when different terminology is used. The search understands meaning, not just keywords.

Examples:

  • Query "trouble breathing at night" finds codes like "Sleep apnea", "Orthopnea", "Nocturnal dyspnea" — semantically related but no exact keyword matches
  • Query "heart problems" finds "Myocardial infarction", "Cardiac arrest", "Arrhythmia"

Trade-offs: Slower than text search (requires embedding generation), but finds conceptually similar results that keyword search would miss.

See also: /search/text for faster keyword-based lookup with typo tolerance.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

RequiresBearerauthentication

Path parameters

codesystemstringrequired

Code system name

Query parameters

textstringrequired

Natural language text to find semantically similar codes for

versionstringoptional

Specific version of the code system

limitintegeroptionaldefault 10

Maximum number of results (default 10, max 50)

Returns  

Semantic search results ordered by similarity

Response fields

systemobjectrequired
namestringrequired

Code system name

versionstringrequired

Code system version

resultsobject[]required

Codes ordered by semantic similarity (most similar first)

codestringrequired
descriptionstringrequired
GETRequest
curl 'https://experiment.app.pheno.ml/construe/codes/ICD-10-CM/search/semantic?text=patient%20has%20trouble%20breathing%20at%20night%20and%20wakes%20up%20gasping&limit=5' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "system": {
    "name": "ICD-10-CM",
    "version": "2025"
  },
  "results": [
    {
      "code": "R06.00",
      "description": "Dyspnea, unspecified"
    },
    {
      "code": "R06.01",
      "description": "Orthopnea"
    },
    {
      "code": "G47.33",
      "description": "Obstructive sleep apnea"
    },
    {
      "code": "R06.83",
      "description": "Snoring"
    },
    {
      "code": "J45.20",
      "description": "Mild intermittent asthma, uncomplicated"
    }
  ]
}

Text search (keyword-based)

GET/construe/codes/{codesystem}/search/text

Performs fast full-text search over code IDs and descriptions.

Availability: This endpoint is only available for built-in code systems. Custom code systems uploaded via /construe/upload are not indexed for full-text search and will return empty results. Use /search/semantic to search custom code systems.

When to use: Best for autocomplete UIs, code lookup, or when users know part of the code ID or specific keywords. Fast response times suitable for typeahead interfaces.

Features:

  • Substring matching on code IDs (e.g., "11.65" finds "E11.65")
  • Typo tolerance on descriptions (not on code IDs)
  • Fast response times (~10-50ms)

Examples:

  • Query "E11" finds all codes starting with E11 (diabetes codes)
  • Query "diabtes" (typo) still finds "diabetes" codes

Trade-offs: Faster than semantic search, but only matches keywords/substrings. Won't find conceptually related codes with different terminology.

See also: /search/semantic for finding conceptually similar codes.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

RequiresBearerauthentication

Path parameters

codesystemstringrequired

Code system name

Query parameters

qstringrequired

Search query (searches code IDs and descriptions)

versionstringoptional

Specific version of the code system

limitintegeroptionaldefault 20

Maximum number of results (default 20, max 100)

Returns  

Text search results

Response fields

systemobjectrequired
namestringrequired

Code system name

versionstringrequired

Code system version

resultsobject[]required

Codes matching the search query

codestringrequired
descriptionstringrequired
foundintegerrequired

Total number of matching results (may exceed results array due to pagination)

GETRequest
curl 'https://experiment.app.pheno.ml/construe/codes/ICD-10-CM/search/text?q=E11.65&limit=5' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "system": {
    "name": "ICD-10-CM",
    "version": "2025"
  },
  "results": [
    {
      "code": "E11.65",
      "description": "Type 2 diabetes mellitus with hyperglycemia"
    },
    {
      "code": "E11.649",
      "description": "Type 2 diabetes mellitus with hypoglycemia without coma"
    },
    {
      "code": "E11.69",
      "description": "Type 2 diabetes mellitus with other specified complication"
    }
  ],
  "found": 3
}

Extract medical codes from text

POST/construe/extract

Converts natural language text into structured medical codes.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

RequiresBearerauthentication

Body parameters

textstringrequired

Natural language text to extract codes from

systemobjectoptional
namestringoptional

Code system name. Can be a built-in system or a custom system name.

Built-in systems:

  • SNOMED_CT_US_LITE - version 20240901
  • RXNORM - version 11042024
  • ICD-10-CM - version 2025
  • ICD-10-PCS - version 2025
  • LOINC - version 2.78
  • HPO - version 2025
  • CPT - version 2025

Custom systems:

  • Any valid system name uploaded via /construe/upload. Requires a paid plan.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

versionstringoptional

Code system version. Must match the version available in your environment.

configobjectoptional
chunking_methodstringoptionaldefault sentences

Method for splitting input text into chunks before code extraction.

  • none - Treat the full input as a single chunk.
  • sentences - Split on sentence boundaries (supports citations).
  • paragraphs / topics / soap_note - LLM-based chunking.
  • clinical_ner_extract - Extract clinical concepts (problems, tests, treatments) and use each as a chunk (supports citations).
  • fasthpocr - Extract HPO concepts directly with category annotations (supports citations). Requires system: HPO; other systems are rejected. Causes most other config options to be ignored.
nonesentencesparagraphstopicssoap_noteclinical_ner_extractfasthpocr
max_codes_per_chunkintegeroptional

Maximum number of codes to extract per chunk. If not specified, uses system-specific defaults:

  • SNOMED: 10
  • LOINC, HPO, RXNORM: 20
  • All other systems: 5
code_similarity_filternumber (float)optionaldefault 0.9

Threshold for filtering similar codes (0.0-1.0)

validation_methodstringoptionaldefault simple

Method for validating extracted codes:

  • none - No validation, returns all candidate codes
  • simple - LLM-based validation
  • medication_search - LLM-based validation tailored for medication concepts
  • chunk_code_jaccard_similarity - Token-level Jaccard similarity between source text chunk and code description
nonesimplemedication_searchchunk_code_jaccard_similarity
chunk_code_jaccard_similarity_filtering_thresholdnumber (float)optionaldefault 0.2

Minimum Jaccard similarity (0.0-1.0) for a code to be considered valid when using the "chunk_code_jaccard_similarity" validation method. Ignored by other methods.

include_rationalebooleanoptionaldefault true

Whether to include explanations for why each code was extracted

include_ancestorsbooleanoptionaldefault false

Whether to include ancestor/parent codes in the results

include_invalidbooleanoptionaldefault false

Whether to include codes that failed validation in the results

include_citationsbooleanoptionaldefault false

Whether to include source text citations for each extracted code. Citations show the exact text spans (with character offsets) that led to each code. Supported when chunking_method is "sentences", "clinical_ner_extract", or "fasthpocr".

extraction_contextstringoptional

Optional context describing the goal of the extraction. Required when min_context_relevance is greater than 0.

min_context_relevancenumber (double)optionaldefault 0

Minimum relevance score (0.0–1.0) a chunk must reach to proceed to code extraction. Chunks are scored by an LLM against the extraction_context goal. Chunks below this threshold are dropped, reducing noise and extraction cost. Set to 0 (the default) to disable relevance filtering and extract from all chunks. Requires the "extraction_context" field when set above 0.

consistency_effortstringoptionaldefault none

How much effort to spend ensuring consistent results across repeated requests. Higher levels apply stricter filtering to remove borderline results that may vary between calls, improving determinism at the cost of additional latency.

When validation_method is set to a value other than "none", consistency is applied to the validation step: codes must be unanimously validated across multiple rounds to be included.

When validation_method is "none" and min_context_relevance is set above 0, consistency is applied to the relevance ranking step instead: chunks must pass the relevance threshold in every round to be included.

nonelowmediumhigh
Returns  

Successfully extracted codes

Response fields

systemobjectrequired
namestringoptional

Code system name. Can be a built-in system or a custom system name.

Built-in systems:

  • SNOMED_CT_US_LITE - version 20240901
  • RXNORM - version 11042024
  • ICD-10-CM - version 2025
  • ICD-10-PCS - version 2025
  • LOINC - version 2.78
  • HPO - version 2025
  • CPT - version 2025

Custom systems:

  • Any valid system name uploaded via /construe/upload. Requires a paid plan.

Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.

versionstringoptional

Code system version. Must match the version available in your environment.

codesobject[]required
codestringrequired

The extracted code

descriptionstringrequired

Short description of the code

validbooleanrequired

Whether the code passed validation. Always true unless include_invalid is set to true, in which case invalid codes will have this set to false.

reasonstringoptional

Explanation for why this code was extracted (if include_rationale is true)

is_ancestorbooleanoptional

Whether this code is an ancestor (parent) of an extracted code rather than directly extracted. Only present when include_ancestors is true.

citationsobject[]optional

Source text references showing where this code was found in the input. Only present when include_citations is true and chunking method supports it. Ancestor codes do not receive citations.

textstringrequired

The exact text span containing evidence for the code

begin_offsetintegerrequired

Starting byte offset in the original input text (0-indexed)

end_offsetintegerrequired

Ending byte offset (exclusive), such that input[begin_offset:end_offset] == text

categoriesobject[]optional

Higher-level groupings the extracted code belongs to (e.g. HPO category terms). Only populated by full-extraction chunking methods such as "fasthpocr".

uristringrequired

Identifier for the category term (e.g. an HPO URI).

labelstringrequired

Human-readable label for the category term.

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/construe/extract' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Patient is a 14-year-old female, previously healthy, who is here for evaluation of abnormal renal ultrasound with atrophic right kidney.",
  "system": {
    "name": "ICD-10-CM",
    "version": "2025"
  }
}'
200 OKResponse
{
  "system": {
    "name": "ICD-10-CM",
    "version": "2025"
  },
  "codes": [
    {
      "code": "Q60.3",
      "description": "Renal hypoplasia, unspecified",
      "valid": true
    },
    {
      "code": "R93.42",
      "description": "Abnormal findings on diagnostic imaging of kidney",
      "valid": true
    },
    {
      "code": "N28.1",
      "description": "Cyst of kidney, acquired",
      "valid": true
    }
  ]
}

Lang2FHIR

Convert natural language clinical text into structured FHIR resources including Patient, Condition, MedicationRequest, and more.

Analyze text for patient cohort criteria

POST/cohort

Converts natural language text into structured FHIR search queries for patient cohort analysis

RequiresBearerauthentication

Body parameters

textstringrequired

Natural language text describing patient cohort criteria

Returns  

Successfully analyzed cohort criteria

Response fields

successbooleanoptional

Whether the cohort analysis was successful

messagestringoptional

Human-readable message about the analysis result

queriesobject[]optional

Array of search concepts converted to FHIR search queries

resource_typestringoptional

The FHIR resource type for this search concept

search_paramsstringoptional

FHIR search parameters in standard format

conceptstringoptional

The original concept description

excludebooleanoptional

Whether this concept should be excluded from the search

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/cohort' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "female patients over 65 with diabetes but not hypertension"
}'
200 OKResponse
{
  "success": true,
  "message": "Successfully analyzed cohort criteria",
  "queries": [
    {
      "resource_type": "Patient",
      "search_params": "gender=female&birthdate=le1959-01-01",
      "concept": "female patients over 65",
      "exclude": false
    }
  ]
}

Create FHIR resource from text

POST/lang2fhir/create

Converts natural language text into a structured FHIR resource.

Patient identifier handling. When generating a patient (or patient-canvas) resource, US Core requires Patient.identifier (a business identifier such as an MRN). When the source text contains an identifier, it is extracted with an appropriate URI system. When the source text does not contain a detectable identifier, a synthetic one is generated with system: "urn:phenoml:lang2fhir-generated-id" and a UUID value so the resource remains FHIR-valid and US Core conformant. Callers who need a tenant-specific namespace should rewrite the synthetic system after extraction.

RequiresBearerauthentication

Body parameters

versionstringrequireddefault R4

FHIR version to use

resourcestringrequired

Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile. Recommended to use the supported US Core Profiles for validated results but you can also use any custom profile you've uploaded (if you're a develop or launch customer)

autoappointmentcondition-encounter-diagnosismedicationrequestcareplancondition-problems-health-concernscoverageencounterobservation-clinical-resultobservation-labpatientprocedurequestionnairequestionnaireresponseservicerequestsimple-observationvital-signs
textstringrequired

Natural language text to convert

Returns  

Successfully created FHIR resource

Response fields

resourceTypestringoptional
clinicalStatusobjectoptional
codingarray<object>optional
systemstringoptional
codestringoptional
codeobjectoptional
codingarray<object>optional
systemstringoptional
codestringoptional
displaystringoptional
textstringoptional
severityobjectoptional
codingarray<object>optional
systemstringoptional
codestringoptional
displaystringoptional
POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Patient has severe persistent asthma with acute exacerbation",
  "version": "R4",
  "resource": "condition-encounter-diagnosis"
}'
200 OKResponse
{
  "resourceType": "Condition",
  "clinicalStatus": {
    "coding": [
      {
        "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
        "code": "active"
      }
    ]
  },
  "code": {
    "coding": [
      {
        "system": "http://snomed.info/sct",
        "code": "195967001",
        "display": "Asthma"
      }
    ],
    "text": "Severe persistent asthma with acute exacerbation"
  },
  "severity": {
    "coding": [
      {
        "system": "http://snomed.info/sct",
        "code": "24484000",
        "display": "Severe"
      }
    ]
  }
}

Extract multiple FHIR resources from text

POST/lang2fhir/create/multi

Analyzes natural language text and extracts multiple FHIR resources, returning them as a transaction Bundle. Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types from the text. Resources are linked with proper references (e.g., Conditions reference the Patient).

Patient identifier handling. US Core requires Patient.identifier (a business identifier such as an MRN). When the source text contains an identifier, it is extracted with an appropriate URI system. When the source text does not contain a detectable identifier, a synthetic one is generated with system: "urn:phenoml:lang2fhir-generated-id" and a UUID value so the bundle remains FHIR-valid and US Core conformant. Callers who need a tenant-specific namespace should rewrite the synthetic system after extraction.

RequiresBearerauthentication

Body parameters

textstringrequired

Natural language text containing multiple clinical concepts to extract

versionstringoptionaldefault R4

FHIR version to use

providerstringoptional

Optional FHIR provider name for provider-specific profiles

implementation_guidestringoptional

Custom Implementation Guide name. When specified, profiles from this IG are included alongside US Core profiles during resource detection. US Core is always the base layer; custom IG profiles are additive.

detection_effortstringoptionaldefault standard

Detection effort. 'standard' runs detection once, 'deep' runs detection multiple times for higher recall.

standarddeep
validation_methodstringoptionaldefault none

FHIR validation method to apply to the generated bundle. 'none' skips validation (default). 'check' runs the bundle through a FHIR structure validator and includes the results in the response. 'fix' runs validation and attempts to auto-correct errors using an LLM (up to 3 validation passes). The response includes results from each pass. Warning: 'fix' can significantly increase latency due to multiple LLM and validation round-trips.

nonecheckfix
Returns  

Successfully extracted FHIR resources

Response fields

successbooleanoptional

Whether extraction was successful

messagestringoptional

Status message

bundleobjectoptional

FHIR transaction Bundle containing all extracted resources

resourceTypestringoptional
typestringoptional
entryobject[]optional
fullUrlstringoptional
resourceobjectoptional
requestobjectoptional
resourcesobject[]optional

Summary of extracted resources

tempIdstringoptional

Temporary UUID for the resource

resourceTypestringoptional

FHIR resource type

descriptionstringoptional

Context-enriched rewritten text excerpt for this resource

originalTextstringoptional

Verbatim text excerpt from the original clinical document

validationobjectoptional

FHIR validation results. Present when validation_method is 'check' or 'fix'. Contains results from each validation pass. For 'check', there is one pass. For 'fix', there may be up to 3 passes as the system attempts auto-correction.

passesobject[]optional

Results from each validation pass, in chronological order

issuesobject[]optional

Validation issues found in this pass

statsobjectoptional

Validation statistics for this pass

fixedbooleanoptional

Whether validation errors were successfully fixed by the LLM. Always false for 'check' mode. For 'fix' mode, true if errors were resolved and the returned bundle is the corrected version.

attemptsintegeroptional

Total number of validation passes run (1 for check, 1-3 for fix)

summarystringoptional

Human-readable summary of the validation outcome

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/create/multi' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily. Blood pressure 140/90.",
  "version": "R4"
}'
200 OKResponse
{
  "success": true,
  "message": "Successfully extracted 3 resources",
  "bundle": {
    "resourceType": "Bundle",
    "type": "transaction",
    "entry": [
      {
        "fullUrl": "urn:uuid:patient-001",
        "resource": {
          "resourceType": "Patient",
          "name": [
            {
              "given": [
                "John"
              ],
              "family": "Smith"
            }
          ],
          "gender": "male"
        },
        "request": {
          "method": "POST",
          "url": "Patient"
        }
      },
      {
        "fullUrl": "urn:uuid:condition-001",
        "resource": {
          "resourceType": "Condition",
          "code": {
            "text": "Type 2 Diabetes"
          }
        },
        "request": {
          "method": "POST",
          "url": "Condition"
        }
      },
      {
        "fullUrl": "urn:uuid:medication-001",
        "resource": {
          "resourceType": "MedicationRequest",
          "medicationCodeableConcept": {
            "text": "Metformin 500mg"
          }
        },
        "request": {
          "method": "POST",
          "url": "MedicationRequest"
        }
      }
    ]
  }
}

Convert document to FHIR resource

POST/lang2fhir/document

Extracts text from a document (PDF or image) and converts it into a structured FHIR resource.

Patient identifier handling. When generating a patient (or patient-canvas) resource, US Core requires Patient.identifier (a business identifier such as an MRN). When the source text contains an identifier, it is extracted with an appropriate URI system. When the source text does not contain a detectable identifier, a synthetic one is generated with system: "urn:phenoml:lang2fhir-generated-id" and a UUID value so the resource remains FHIR-valid and US Core conformant. Callers who need a tenant-specific namespace should rewrite the synthetic system after extraction.

RequiresBearerauthentication

Body parameters

versionstringrequired

FHIR version to use

resourcestringrequired

Type of FHIR resource to create. Accepts any FHIR resource type or US Core profile name.

contentstringrequired

Base64 encoded file content. Supported file types: PDF (application/pdf), PNG (image/png), JPEG (image/jpeg). File type is auto-detected from content magic bytes.

configobjectoptional

Optional processing configuration shared across document endpoints.

page_filterobjectoptional

Configures per-page pre-extraction filtering. When set, each page of text extracted from the document is classified by an LLM, and pages classified as irrelevant to the supplied context are dropped before FHIR extraction.

contextstringrequired

Natural-language description of what IS relevant to the extraction goal. Pages that do not match are dropped from downstream FHIR extraction.

Returns  

Successfully created FHIR resource from document

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/document' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "version": "R4",
  "resource": "questionnaire",
  "content": "Example text content",
  "config": {
    "page_filter": {
      "context": "clinical notes, diagnoses, medications — not sample collection instructions or insurance forms"
    }
  }
}'
200 OKResponse
{}

Extract multiple FHIR resources from a document

POST/lang2fhir/document/multi

Extracts text from a document (PDF or image) and converts it into multiple FHIR resources, returned as a transaction Bundle. Combines document text extraction with multi-resource detection. Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types. Resources are linked with proper references (e.g., Conditions reference the Patient).

Patient identifier handling. US Core requires Patient.identifier (a business identifier such as an MRN). When the source text contains an identifier, it is extracted with an appropriate URI system. When the source text does not contain a detectable identifier, a synthetic one is generated with system: "urn:phenoml:lang2fhir-generated-id" and a UUID value so the bundle remains FHIR-valid and US Core conformant. Callers who need a tenant-specific namespace should rewrite the synthetic system after extraction.

RequiresBearerauthentication

Body parameters

versionstringrequired

FHIR version to use

contentstringrequired

Base64 encoded file content. Supported file types: PDF (application/pdf), PNG (image/png), JPEG (image/jpeg). File type is auto-detected from content magic bytes.

providerstringoptional

Optional FHIR provider name for provider-specific profiles

implementation_guidestringoptional

Custom Implementation Guide name. When specified, profiles from this IG are included alongside US Core profiles during resource detection. US Core is always the base layer; custom IG profiles are additive.

detection_effortstringoptionaldefault standard

Detection effort. 'standard' runs detection once, 'deep' runs detection multiple times for higher recall.

standarddeep
validation_methodstringoptionaldefault none

FHIR validation method to apply to the generated bundle. 'none' skips validation (default). 'check' runs the bundle through a FHIR structure validator and includes the results in the response. 'fix' runs validation and attempts to auto-correct errors using an LLM (up to 3 validation passes). The response includes results from each pass. Warning: 'fix' can significantly increase latency due to multiple LLM and validation round-trips.

nonecheckfix
configobjectoptional

Optional processing configuration shared across document endpoints.

page_filterobjectoptional

Configures per-page pre-extraction filtering. When set, each page of text extracted from the document is classified by an LLM, and pages classified as irrelevant to the supplied context are dropped before FHIR extraction.

contextstringrequired

Natural-language description of what IS relevant to the extraction goal. Pages that do not match are dropped from downstream FHIR extraction.

Returns  

Successfully extracted FHIR resources from document

Response fields

successbooleanoptional
messagestringoptional
bundleobjectoptional
resourceTypestringoptional
typestringoptional
entryarray<object>optional
fullUrlstringoptional
resourceobjectoptional
requestobjectoptional
methodstringoptional
urlstringoptional
resourcesarray<object>optional
tempIdstringoptional
resourceTypestringoptional
descriptionstringoptional
originalTextstringoptional
validationobjectoptional
passesarray<object>optional
issuesarray<object>optional
severitystringoptional
codestringoptional
diagnosticsstringoptional
expressionarray<string>optional
sourcestringoptional
statsobjectoptional
resource_typestringoptional
profile_urlstringoptional
is_custom_profilebooleanoptional
duration_msnumberoptional
fixedbooleanoptional
attemptsintegeroptional
summarystringoptional
page_classificationsarray<object>optional
page_numberintegeroptional
includebooleanoptional
reasonstringoptional
POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/document/multi' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "version": "R4",
  "content": "Example text content",
  "provider": "canvas",
  "implementation_guide": "acme-cardiology",
  "detection_effort": "standard",
  "validation_method": "none",
  "config": {
    "page_filter": {
      "context": "clinical notes, diagnoses, medications — not sample collection instructions or insurance forms"
    }
  }
}'
200 OKResponse
{
  "success": true,
  "message": "Successfully extracted FHIR resources from document",
  "bundle": {
    "resourceType": "Bundle",
    "type": "transaction",
    "entry": [
      {
        "fullUrl": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8",
        "resource": {},
        "request": {
          "method": "POST",
          "url": "Patient"
        }
      }
    ]
  },
  "resources": [
    {
      "tempId": "urn:uuid:a842c4bc-f6cb-4555-9741-ac3aec4ef0b8",
      "resourceType": "Patient",
      "description": "John Smith (DOB 1980-05-12) was diagnosed with Type 2 Diabetes during office visit on 2025-03-01 with Dr. Chen",
      "originalText": "diagnosed with Type 2 Diabetes"
    }
  ],
  "validation": {
    "passes": [
      {
        "issues": [
          {
            "severity": "fatal",
            "code": "ABC123",
            "diagnostics": "example",
            "expression": [
              "example"
            ],
            "source": "example"
          }
        ],
        "stats": {
          "resource_type": "Patient",
          "profile_url": "https://example.com",
          "is_custom_profile": true,
          "duration_ms": 0.5
        }
      }
    ],
    "fixed": true,
    "attempts": 10,
    "summary": "example"
  },
  "page_classifications": [
    {
      "page_number": 1,
      "include": true,
      "reason": "clinical notes with diagnoses"
    }
  ]
}

Upload custom FHIR profile

POST/lang2fhir/profile/upload

Upload a custom FHIR StructureDefinition profile for use with the lang2fhir service.

All metadata is derived from the StructureDefinition JSON itself. The lowercase id field from the StructureDefinition is used as the profile's unique identifier and lookup key. To use the uploaded profile with /lang2fhir/create, pass this id as the resource parameter.

Uploads will be rejected if:

  • A built-in US Core or R4 base profile already exists with the same id
  • A custom profile with the same id has already been uploaded
  • A custom profile with the same url has already been uploaded
RequiresBearerauthentication

Body parameters

profilestringrequired

Base64 encoded JSON string of a FHIR StructureDefinition. The profile must include id, url, type, and a snapshot with elements. All metadata (version, resource type, identifier) is derived from the StructureDefinition itself. The lowercase id from the StructureDefinition becomes the profile's lookup key.

implementation_guidestringoptional

Implementation Guide name to group this profile under. Defaults to "custom" if omitted. Cannot be "us_core" (reserved). Use this to organize custom profiles into named IGs that can be referenced when calling create/multi or document/multi endpoints.

profile_contextstringoptional

Natural language context that helps the LLM select the right profiles from this implementation guide during resource detection. For example, "When the text mentions phenotypic features or abnormalities, prefer the hpo-observation profile over Condition." This is stored as IG-level metadata and injected into the LLM prompt. Max 2000 characters. Providing this field on any upload will update the context for the entire IG (last write wins).

Returns  

Profile successfully uploaded

Response fields

messagestringoptional
idstringoptional

The lowercase StructureDefinition id, used as the profile's unique identifier and lookup key. Pass this value as the resource parameter to /lang2fhir/create or /lang2fhir/profile/json/:version/:resource to use this profile.

typestringoptional

The FHIR resource type from the StructureDefinition

urlstringoptional

The canonical URL from the StructureDefinition

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/profile/upload' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "profile": "(base64 encoded FHIR StructureDefinition JSON)",
  "implementation_guide": "acme-cardiology",
  "profile_context": "When clinical text describes phenotypic features, abnormalities, or findings that map to HPO terms, use the hpo-phenotype-observation profile instead of Condition."
}'
201 CreatedResponse
{
  "message": "Profile successfully uploaded",
  "id": "custom-patient",
  "type": "Patient",
  "url": "http://phenoml.com/fhir/StructureDefinition/custom-patient"
}

Generate FHIR search parameters from text

POST/lang2fhir/search

Converts natural language text into FHIR search parameters. Automatically identifies the appropriate FHIR resource type and generates valid search query parameters.

Supported resource types include: AllergyIntolerance, Appointment, CarePlan, CareTeam, Condition, Coverage, Device, DiagnosticReport, DocumentReference, Encounter, Goal, Immunization, Location, Medication, MedicationRequest, Observation, Organization, Patient, PlanDefinition, Practitioner, PractitionerRole, Procedure, Provenance, Questionnaire, QuestionnaireResponse, RelatedPerson, Schedule, ServiceRequest, Slot, and Specimen.

RequiresBearerauthentication

Body parameters

textstringrequired

Natural language text to convert into FHIR search parameters. The system will automatically identify the appropriate resource type and generate valid search parameters.

Examples:

  • "Appointments between March 2-9, 2025" → Appointment search with date range
  • "Patients with diabetes" → Condition search with code parameter
  • "Active medication requests for metformin" → MedicationRequest search
  • "Lab results for creatinine" → DiagnosticReport search
  • "Dr. Smith's schedule" → Practitioner or Schedule search
Returns  

Successfully generated FHIR search parameters

Response fields

resource_typestringoptional

The FHIR resource type identified for the search

AllergyIntoleranceAppointmentCarePlanCareTeamConditionCoverageDeviceDiagnosticReportDocumentReferenceEncounterGoalImmunizationLocationMedicationMedicationRequestObservationOrganizationPatientPlanDefinitionPractitionerPractitionerRoleProcedureProvenanceQuestionnaireQuestionnaireResponseRelatedPersonScheduleServiceRequestSlotSpecimen
search_paramsstringoptional

FHIR search parameters in standard query string format. Parameters are formatted according to the FHIR specification with appropriate operators. Code parameters are resolved to standard terminology codes (SNOMED CT, LOINC, RxNorm, ICD-10-CM).

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/lang2fhir/search' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Appointments between March 2-9, 2025"
}'
200 OKResponse
{
  "resource_type": "Appointment",
  "search_params": "date=ge2025-03-02&date=le2025-03-09"
}

Summary

Generate clinical summaries from FHIR resources. Supports narrative templates, flattening for RAG, and IPS generation.

Generate a summary from FHIR resources

POST/fhir2summary/create

Creates a summary from FHIR resources using one of three modes:

  • narrative: Uses a template to substitute FHIR data into placeholders (requires template_id)
  • flatten: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
  • ips: Generates an International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG. Requires a Bundle with exactly one Patient resource (returns 400 error if no Patient or multiple Patients are present). Automatically filters resources to those referencing the patient and generates sections for allergies, medications, problems, immunizations, procedures, and vital signs.
RequiresBearerauthentication

Body parameters

modestringoptionaldefault narrative

Summary generation mode:

  • narrative: Substitute FHIR data into a template (requires template_id)
  • flatten: Flatten FHIR resources for RAG/search (no template needed)
  • ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
narrativeflattenips
template_idstring (uuid)optional

ID of the template to use (required for narrative mode)

fhir_resourcesobjectrequired

FHIR resources (single resource or Bundle). For IPS mode, must be a Bundle containing exactly one Patient resource with at least one identifier (id, fullUrl, or identifier field). Returns an error if no Patient is found, if multiple Patients are present, or if the Patient has no identifiers. Resources are automatically filtered to only include those referencing the patient.

Returns  

Summary generated successfully

Response fields

successbooleanoptional
messagestringoptional
summarystringoptional

Generated summary text

warningsstring[]optional

Unresolved placeholders or issues (narrative mode only)

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/fhir2summary/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "mode": "narrative",
  "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "fhir_resources": {
    "resourceType": "Bundle",
    "type": "collection",
    "entry": [
      {
        "resource": {
          "resourceType": "Patient",
          "name": [
            {
              "given": [
                "John"
              ],
              "family": "Doe"
            }
          ],
          "gender": "male",
          "birthDate": "1979-03-15"
        }
      },
      {
        "resource": {
          "resourceType": "Condition",
          "code": {
            "text": "Type 2 Diabetes Mellitus"
          },
          "onsetDateTime": "2024-01-15"
        }
      }
    ]
  }
}'
200 OKResponse
{
  "success": true,
  "summary": "Patient John Doe is a 45-year-old male diagnosed with Type 2 Diabetes Mellitus on January 15, 2024. Current treatment plan includes lifestyle modifications and medication management.",
  "warnings": []
}

Create a new summary template

POST/fhir2summary/template

Creates a summary template from an example using LLM function calling

RequiresBearerauthentication

Body parameters

namestringrequired

Name of the template

descriptionstringoptional

Description of the template

example_summarystringrequired

Example summary note to generate template from

target_resourcesstring[]required

List of target FHIR resources

example_fhir_dataobjectoptional

Optional example FHIR data that corresponds to the example summary

modestringrequired

Template mode (stored with the template)

Returns  

Template created successfully

Response fields

successbooleanoptional
messagestringoptional
template_idstring (uuid)optional
templateobjectoptional
idstring (uuid)optional
namestringoptional
descriptionstringoptional
templatestringoptional

Template with {{resource.field}} placeholders

target_resourcesstring[]optional

List of FHIR resource types/profiles

modestringoptional

Template mode (stored value)

metadataobjectoptional
created_atstring (date-time)optional
updated_atstring (date-time)optional
POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/fhir2summary/template' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Discharge Summary",
  "example_summary": "Patient John Doe, age 45, was admitted on 2024-01-10 with Type 2 Diabetes. Discharged on 2024-01-15 with Metformin 500mg BID.",
  "target_resources": [
    "Patient",
    "Condition",
    "MedicationRequest"
  ],
  "mode": "narrative"
}'
200 OKResponse
{
  "success": true,
  "message": "Template created successfully",
  "template_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "template": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "Discharge Summary",
    "template": "Patient <<Patient.name[0].text>>, age <<Patient.birthDate|age>>, was admitted on <<Encounter[0].period.start>> with <<Condition[0].code.coding[0].display>>. Discharged on <<Encounter[0].period.end>> with <<MedicationRequest[0].medicationCodeableConcept.coding[0].display>> <<MedicationRequest[0].dosageInstruction[0].text>>.",
    "target_resources": [
      "Patient",
      "Condition",
      "MedicationRequest"
    ],
    "mode": "narrative",
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Get a summary template by ID

GET/fhir2summary/template/{id}

Retrieves a specific summary template

RequiresBearerauthentication

Path parameters

idstringrequired

Template ID

Returns  

Template retrieved successfully

Response fields

successbooleanoptional
templateobjectoptional
idstring (uuid)optional
namestringoptional
descriptionstringoptional
templatestringoptional

Template with {{resource.field}} placeholders

target_resourcesstring[]optional

List of FHIR resource types/profiles

modestringoptional

Template mode (stored value)

metadataobjectoptional
created_atstring (date-time)optional
updated_atstring (date-time)optional
GETRequest
curl 'https://experiment.app.pheno.ml/fhir2summary/template/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "template": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Example Name",
    "description": "An example description",
    "template": "{{resource.field}}",
    "target_resources": [
      "Patient"
    ],
    "mode": "narrative",
    "metadata": {},
    "created_at": "2024-01-15T09:30:00Z",
    "updated_at": "2024-01-15T09:30:00Z"
  }
}

Update a summary template

PUT/fhir2summary/template/{id}

Updates an existing summary template

RequiresBearerauthentication

Path parameters

idstringrequired

Template ID

Body parameters

namestringrequired
descriptionstringoptional
templatestringrequired

Updated template with placeholders

target_resourcesstring[]required
modestringrequired

Template mode

Returns  

Template updated successfully

Response fields

successbooleanoptional
messagestringoptional
templateobjectoptional
idstring (uuid)optional
namestringoptional
descriptionstringoptional
templatestringoptional

Template with {{resource.field}} placeholders

target_resourcesstring[]optional

List of FHIR resource types/profiles

modestringoptional

Template mode (stored value)

metadataobjectoptional
created_atstring (date-time)optional
updated_atstring (date-time)optional
PUTRequest
curl -X PUT 'https://experiment.app.pheno.ml/fhir2summary/template/%7Bid%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Example Name",
  "description": "An example description",
  "template": "{{resource.field}}",
  "target_resources": [
    "Patient"
  ],
  "mode": "narrative"
}'
200 OKResponse
{
  "success": true,
  "message": "Template updated successfully",
  "template": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Example Name",
    "description": "An example description",
    "template": "{{resource.field}}",
    "target_resources": [
      "Patient"
    ],
    "mode": "narrative",
    "metadata": {},
    "created_at": "2024-01-15T09:30:00Z",
    "updated_at": "2024-01-15T09:30:00Z"
  }
}

Delete a summary template

DELETE/fhir2summary/template/{id}

Deletes a summary template

RequiresBearerauthentication

Path parameters

idstringrequired

Template ID

Returns  

Template deleted successfully

Response fields

successbooleanoptional
messagestringoptional
DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/fhir2summary/template/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Template deleted successfully"
}

List all summary templates

GET/fhir2summary/templates

Retrieves all summary templates for the authenticated user

RequiresBearerauthentication
Returns  

Templates retrieved successfully

Response fields

successbooleanoptional
templatesobject[]optional
idstring (uuid)optional
namestringoptional
descriptionstringoptional
templatestringoptional

Template with {{resource.field}} placeholders

target_resourcesstring[]optional

List of FHIR resource types/profiles

modestringoptional

Template mode (stored value)

metadataobjectoptional
created_atstring (date-time)optional
updated_atstring (date-time)optional
GETRequest
curl 'https://experiment.app.pheno.ml/fhir2summary/templates' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "templates": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Example Name",
      "description": "An example description",
      "template": "{{resource.field}}",
      "target_resources": [
        "Patient"
      ],
      "mode": "narrative",
      "metadata": {},
      "created_at": "2024-01-15T09:30:00Z",
      "updated_at": "2024-01-15T09:30:00Z"
    }
  ]
}

FHIR2OMOP

Map FHIR R4 resources and bundles into OMOP Common Data Model (CDM v5.4) tables.

Map FHIR resources to OMOP CDM v5.4

POST/fhir2omop/create

Maps a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows (person, visit_occurrence, condition_occurrence, drug_exposure, procedure_occurrence, measurement, observation).

Resource support is intentionally limited to the OMOP tables returned by this endpoint:

  • Patient -> person
  • Encounter -> visit_occurrence
  • Condition -> condition_occurrence
  • Procedure -> procedure_occurrence
  • MedicationRequest, MedicationStatement, and MedicationAdministration -> drug_exposure
  • Immunization -> drug_exposure
  • Observation with a numeric valueQuantity, valueInteger, or numeric-looking valueString (for example "<2") -> measurement
  • non-numeric Observation -> observation
  • AllergyIntolerance -> observation

Medication is supported only as reference data for medication resources; it is not emitted as its own row because OMOP CDM has no Medication table. Other reference/admin resources such as Practitioner, Organization, Location, Coverage, and Claim, and clinical workflow/document resources such as DiagnosticReport, ServiceRequest, CarePlan, DocumentReference, Composition, Specimen, and DeviceUseStatement, are currently accepted in a Bundle but are not shaped into OMOP rows. Unsupported resource types are ignored rather than listed under dropped; dropped is reserved for supported resource types that were missing the subject/patient, code, or medication reference data needed to produce a valid row.

Each resource's primary clinical coding is resolved to a standard OMOP concept_id. Alongside the OMOP rows grouped by table (tables), the response carries mappings (how each source coding resolved, linked back to the row it produced), dropped (resources that could not be shaped into a row), vocab_version (the OMOP vocabulary release codes were resolved against), and a small summary of the resolution outcomes.

A concept_id of 0 is reported, not omitted (OMOP "no matching concept" semantics): it covers both a coding with no standard match (UNMAPPED) and an unverified suggestion for a text-only resource (UNCHECKED). Only the primary clinical coding is resolved, so gender/race/ethnicity/visit/value/unit concept_ids are always 0; the one populated non-resolved concept is measurement operator_concept_id, set from a value comparator (<, <=, >, >=) rather than the resolver. Each *_source_value carries the verbatim FHIR coding (system#code), and *_type_concept_id is set to 32817 (EHR).

Medication codes are resolved whether they appear inline (medicationCodeableConcept) or via a medicationReference to a contained, relative (Type/id), or bundle-entry (urn:uuid) Medication resource. Resources that cannot be shaped into a row — a medication with no usable code, resolvable reference, or display, or any clinical resource whose subject/patient reference cannot be tied to a person — are reported under dropped rather than emitted as blank rows. The bundle must contain at least one Patient resource.

RequiresBearerauthentication

Body parameters

fhir_resourcesobjectrequired

FHIR resources (single resource or Bundle). Must contain at least one Patient resource. Supported row-producing resources are Patient, Encounter, Condition, Procedure, MedicationRequest, MedicationStatement, MedicationAdministration, Immunization, Observation, and AllergyIntolerance. Standalone Medication resources are consumed by medication references rather than mapped to their own table. Other resource types are accepted but ignored.

Returns  

FHIR resources mapped to OMOP CDM v5.4

Response fields

successbooleanoptional
messagestringoptional
tablesobjectoptional

OMOP CDM v5.4 rows grouped by destination table.

locationobject[]optional
location_idinteger (int64)optional
address_1stringoptional
address_2stringoptional
citystringoptional
statestringoptional
zipstringoptional
countystringoptional
location_source_valuestringoptional
country_concept_idinteger (int64)optional
country_source_valuestringoptional
latitudenumber (double)optional
longitudenumber (double)optional
care_siteobject[]optional
care_site_idinteger (int64)optional
care_site_namestringoptional
place_of_service_concept_idinteger (int64)optional
location_idinteger (int64)optional
care_site_source_valuestringoptional
place_of_service_source_valuestringoptional
providerobject[]optional
provider_idinteger (int64)optional
provider_namestringoptional
npistringoptional
deastringoptional
specialty_concept_idinteger (int64)optional
care_site_idinteger (int64)optional
year_of_birthintegeroptional
gender_concept_idinteger (int64)optional
provider_source_valuestringoptional
specialty_source_valuestringoptional
specialty_source_concept_idinteger (int64)optional
gender_source_valuestringoptional
gender_source_concept_idinteger (int64)optional
personobject[]optional
person_idinteger (int64)optional
gender_concept_idinteger (int64)optional
year_of_birthintegeroptional
month_of_birthintegeroptional
day_of_birthintegeroptional
birth_datetimestringoptional
race_concept_idinteger (int64)optional
ethnicity_concept_idinteger (int64)optional
location_idinteger (int64)optional
person_source_valuestringoptional
gender_source_valuestringoptional
race_source_valuestringoptional
ethnicity_source_valuestringoptional
deathobject[]optional
person_idinteger (int64)optional
death_datestringoptional
death_datetimestringoptional
death_type_concept_idinteger (int64)optional
cause_concept_idinteger (int64)optional
cause_source_valuestringoptional
cause_source_concept_idinteger (int64)optional
observation_periodobject[]optional
observation_period_idinteger (int64)optional
person_idinteger (int64)optional
observation_period_start_datestringoptional
observation_period_end_datestringoptional
period_type_concept_idinteger (int64)optional
visit_occurrenceobject[]optional
visit_occurrence_idinteger (int64)optional
person_idinteger (int64)optional
visit_concept_idinteger (int64)optional
visit_start_datestringoptional
visit_start_datetimestringoptional
visit_end_datestringoptional
visit_end_datetimestringoptional
visit_type_concept_idinteger (int64)optional
provider_idinteger (int64)optional
care_site_idinteger (int64)optional
visit_source_valuestringoptional
condition_occurrenceobject[]optional
condition_occurrence_idinteger (int64)optional
person_idinteger (int64)optional
condition_concept_idinteger (int64)optional
condition_start_datestringoptional
condition_start_datetimestringoptional
condition_end_datestringoptional
condition_type_concept_idinteger (int64)optional
visit_occurrence_idinteger (int64)optional
provider_idinteger (int64)optional
condition_source_valuestringoptional
condition_source_concept_idinteger (int64)optional
condition_status_source_valuestringoptional
drug_exposureobject[]optional
drug_exposure_idinteger (int64)optional
person_idinteger (int64)optional
drug_concept_idinteger (int64)optional
drug_exposure_start_datestringoptional
drug_exposure_start_datetimestringoptional
drug_exposure_end_datestringoptional
drug_type_concept_idinteger (int64)optional
stop_reasonstringoptional
sigstringoptional
visit_occurrence_idinteger (int64)optional
provider_idinteger (int64)optional
drug_source_valuestringoptional
drug_source_concept_idinteger (int64)optional
procedure_occurrenceobject[]optional
procedure_occurrence_idinteger (int64)optional
person_idinteger (int64)optional
procedure_concept_idinteger (int64)optional
procedure_datestringoptional
procedure_datetimestringoptional
procedure_type_concept_idinteger (int64)optional
visit_occurrence_idinteger (int64)optional
provider_idinteger (int64)optional
procedure_source_valuestringoptional
procedure_source_concept_idinteger (int64)optional
measurementobject[]optional
measurement_idinteger (int64)optional
person_idinteger (int64)optional
measurement_concept_idinteger (int64)optional
measurement_datestringoptional
measurement_datetimestringoptional
measurement_type_concept_idinteger (int64)optional
value_as_numbernumber (double)optional
operator_concept_idinteger (int64)optional

OMOP "Meas Value Operator" standard concept qualifying value_as_number (<, <=, >, >=), parsed from a numeric-string value or a FHIR valueQuantity.comparator. 0 when no operator (a bare number).

value_as_concept_idinteger (int64)optional
unit_concept_idinteger (int64)optional
range_lownumber (double)optional
range_highnumber (double)optional
visit_occurrence_idinteger (int64)optional
provider_idinteger (int64)optional
measurement_source_valuestringoptional
measurement_source_concept_idinteger (int64)optional
unit_source_valuestringoptional
value_source_valuestringoptional
observationobject[]optional
observation_idinteger (int64)optional
person_idinteger (int64)optional
observation_concept_idinteger (int64)optional
observation_datestringoptional
observation_datetimestringoptional
observation_type_concept_idinteger (int64)optional
value_as_numbernumber (double)optional
value_as_stringstringoptional
value_as_concept_idinteger (int64)optional
unit_concept_idinteger (int64)optional
visit_occurrence_idinteger (int64)optional
provider_idinteger (int64)optional
observation_source_valuestringoptional
observation_source_concept_idinteger (int64)optional
unit_source_valuestringoptional
value_source_valuestringoptional
mappingsobject[]optional

One entry per source coding (or one entry for a text-only resource with no coding), describing how it resolved and linking back to the row it produced.

resource_typestringoptional
resource_idstringoptional
omop_tablestringoptional
omop_idinteger (int64)optional

The id of the OMOP row this coding produced (e.g. condition_occurrence_id), within omop_table. A resource with multiple codings yields one entry per coding, all sharing this id.

source_systemstringoptional
source_codestringoptional
source_namestringoptional
target_vocabularystringoptional
target_codestringoptional

The standard concept's own code: the source code itself for an ALREADY_STANDARD row, the standard concept's code for a MAPPED row, or the suggested code for an UNCHECKED row. Omitted for UNMAPPED rows.

target_namestringoptional
mapping_statusstringoptional

ALREADY_STANDARD (source coding is already a standard OMOP concept), MAPPED (source coding was mapped to a standard concept), UNCHECKED (a standard code was suggested — e.g. for a text-only resource — but not verified against the OMOP vocabulary, so concept_id stays 0), or UNMAPPED (no standard concept found).

notestringoptional
droppedobject[]optional

Supported resource instances that could not be shaped into an OMOP row because required subject/patient, code, or medication reference data was missing. Unsupported resource types are ignored and do not appear here.

resource_typestringoptional
resource_idstringoptional
reasonstringoptional
vocab_versionstringoptional

The OMOP vocabulary release the clinical codes were resolved against (e.g. "v20240229"), for reproducibility. Present when at least one coded concept was resolved.

summaryobjectoptional

The request's data-quality headline: how the coded concepts split across resolution outcomes, and the share that was not already in a target standard vocabulary. Each coded resource is counted once (per resolved concept), even when it carried several codings — unlike mappings, which has one entry per coding.

codes_already_standardintegeroptional

Coded concepts already a standard OMOP concept (ALREADY_STANDARD).

codes_normalizedintegeroptional

Coded concepts mapped or suggested to a standard concept (MAPPED or UNCHECKED).

codes_unmappedintegeroptional

Coded concepts with no standard concept found (UNMAPPED).

off_vocab_ratenumber (double)optional

Share of coded concepts not already standard ((normalized + unmapped) / total).

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/fhir2omop/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "fhir_resources": {
    "resourceType": "Bundle",
    "type": "collection",
    "entry": [
      {
        "resource": {
          "resourceType": "Patient",
          "id": "patient-1",
          "gender": "female",
          "birthDate": "1985-07-22"
        }
      },
      {
        "resource": {
          "resourceType": "Condition",
          "id": "condition-1",
          "subject": {
            "reference": "Patient/patient-1"
          },
          "code": {
            "coding": [
              {
                "system": "http://snomed.info/sct",
                "code": "44054006",
                "display": "Type 2 diabetes mellitus"
              }
            ]
          },
          "onsetDateTime": "2024-01-15"
        }
      },
      {
        "resource": {
          "resourceType": "MedicationRequest",
          "id": "medreq-1",
          "status": "active",
          "subject": {
            "reference": "Patient/patient-1"
          },
          "medicationReference": {
            "reference": "#med0"
          },
          "authoredOn": "2024-01-16",
          "contained": [
            {
              "resourceType": "Medication",
              "id": "med0",
              "code": {
                "coding": [
                  {
                    "system": "http://www.nlm.nih.gov/research/umls/rxnorm",
                    "code": "860975",
                    "display": "metformin hydrochloride 500 MG"
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  }
}'
200 OKResponse
{
  "success": true,
  "message": "Operation completed successfully",
  "tables": {
    "location": [
      {
        "location_id": 10,
        "address_1": "123 Main St",
        "address_2": "123 Main St",
        "city": "San Francisco",
        "state": "example",
        "zip": "example",
        "county": "example",
        "location_source_value": "example",
        "country_concept_id": 10,
        "country_source_value": "US",
        "latitude": 0.5,
        "longitude": 0.5
      }
    ],
    "care_site": [
      {
        "care_site_id": 10,
        "care_site_name": "Example Name",
        "place_of_service_concept_id": 10,
        "location_id": 10,
        "care_site_source_value": "example",
        "place_of_service_source_value": "example"
      }
    ],
    "provider": [
      {
        "provider_id": 10,
        "provider_name": "Example Name",
        "npi": "example",
        "dea": "example",
        "specialty_concept_id": 10,
        "care_site_id": 10,
        "year_of_birth": 10,
        "gender_concept_id": 10,
        "provider_source_value": "example",
        "specialty_source_value": "example",
        "specialty_source_concept_id": 10,
        "gender_source_value": "example",
        "gender_source_concept_id": 10
      }
    ],
    "person": [
      {
        "person_id": 10,
        "gender_concept_id": 10,
        "year_of_birth": 10,
        "month_of_birth": 10,
        "day_of_birth": 10,
        "birth_datetime": "example",
        "race_concept_id": 10,
        "ethnicity_concept_id": 10,
        "location_id": 10,
        "person_source_value": "example",
        "gender_source_value": "example",
        "race_source_value": "example",
        "ethnicity_source_value": "San Francisco"
      }
    ],
    "death": [
      {
        "person_id": 10,
        "death_date": "example",
        "death_datetime": "example",
        "death_type_concept_id": 10,
        "cause_concept_id": 10,
        "cause_source_value": "example",
        "cause_source_concept_id": 10
      }
    ],
    "observation_period": [
      {
        "observation_period_id": 10,
        "person_id": 10,
        "observation_period_start_date": "example",
        "observation_period_end_date": "example",
        "period_type_concept_id": 10
      }
    ],
    "visit_occurrence": [
      {
        "visit_occurrence_id": 10,
        "person_id": 10,
        "visit_concept_id": 10,
        "visit_start_date": "example",
        "visit_start_datetime": "example",
        "visit_end_date": "example",
        "visit_end_datetime": "example",
        "visit_type_concept_id": 10,
        "provider_id": 10,
        "care_site_id": 10,
        "visit_source_value": "example"
      }
    ],
    "condition_occurrence": [
      {
        "condition_occurrence_id": 10,
        "person_id": 10,
        "condition_concept_id": 10,
        "condition_start_date": "example",
        "condition_start_datetime": "example",
        "condition_end_date": "example",
        "condition_type_concept_id": 10,
        "visit_occurrence_id": 10,
        "provider_id": 10,
        "condition_source_value": "example",
        "condition_source_concept_id": 10,
        "condition_status_source_value": "active"
      }
    ],
    "drug_exposure": [
      {
        "drug_exposure_id": 10,
        "person_id": 10,
        "drug_concept_id": 10,
        "drug_exposure_start_date": "example",
        "drug_exposure_start_datetime": "example",
        "drug_exposure_end_date": "example",
        "drug_type_concept_id": 10,
        "stop_reason": "example",
        "sig": "example",
        "visit_occurrence_id": 10,
        "provider_id": 10,
        "drug_source_value": "example",
        "drug_source_concept_id": 10
      }
    ],
    "procedure_occurrence": [
      {
        "procedure_occurrence_id": 10,
        "person_id": 10,
        "procedure_concept_id": 10,
        "procedure_date": "example",
        "procedure_datetime": "example",
        "procedure_type_concept_id": 10,
        "visit_occurrence_id": 10,
        "provider_id": 10,
        "procedure_source_value": "example",
        "procedure_source_concept_id": 10
      }
    ],
    "measurement": [
      {
        "measurement_id": 10,
        "person_id": 10,
        "measurement_concept_id": 10,
        "measurement_date": "example",
        "measurement_datetime": "example",
        "measurement_type_concept_id": 10,
        "value_as_number": 0.5,
        "operator_concept_id": 10,
        "value_as_concept_id": 10,
        "unit_concept_id": 10,
        "range_low": 0.5,
        "range_high": 0.5,
        "visit_occurrence_id": 10,
        "provider_id": 10,
        "measurement_source_value": "example",
        "measurement_source_concept_id": 10,
        "unit_source_value": "example",
        "value_source_value": "example"
      }
    ],
    "observation": [
      {
        "observation_id": 10,
        "person_id": 10,
        "observation_concept_id": 10,
        "observation_date": "example",
        "observation_datetime": "example",
        "observation_type_concept_id": 10,
        "value_as_number": 0.5,
        "value_as_string": "example",
        "value_as_concept_id": 10,
        "unit_concept_id": 10,
        "visit_occurrence_id": 10,
        "provider_id": 10,
        "observation_source_value": "example",
        "observation_source_concept_id": 10,
        "unit_source_value": "example",
        "value_source_value": "example"
      }
    ]
  },
  "mappings": [
    {
      "resource_type": "Patient",
      "resource_id": "abc-123-def-456",
      "omop_table": "example",
      "omop_id": 10,
      "source_system": "example",
      "source_code": "ABC123",
      "source_name": "Example Name",
      "target_vocabulary": "example",
      "target_code": "ABC123",
      "target_name": "Example Name",
      "mapping_status": "active",
      "note": "example"
    }
  ],
  "dropped": [
    {
      "resource_type": "Patient",
      "resource_id": "abc-123-def-456",
      "reason": "example"
    }
  ],
  "vocab_version": "example",
  "summary": {
    "codes_already_standard": 10,
    "codes_normalized": 10,
    "codes_unmapped": 10,
    "off_vocab_rate": 0.5
  }
}

Get agent by ID

GET/agent/{id}

Retrieves a specific agent by its ID

RequiresBearerauthentication

Path parameters

idstringrequired

Agent ID

Returns  

Agent retrieved successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Agent ID

namestringoptional

Agent name

descriptionstringoptional

Agent description

promptsstring[]optional

Array of prompt IDs used by this agent

toolsstring[]optional

Array of MCP server tool IDs used by this agent

workflowsstring[]optional

Array of workflow IDs exposed as tools by this agent

tagsstring[]optional

Tags for categorizing the agent

provideroneOfoptional

FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers

GETRequest
curl 'https://experiment.app.pheno.ml/agent/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Agent retrieved successfully",
  "data": {
    "id": "agent_123",
    "name": "Medical Assistant",
    "description": "An AI assistant for medical information processing",
    "prompts": [
      "prompt_123",
      "prompt_456"
    ],
    "tools": [
      "mcp_server_123",
      "mcp_server_456"
    ],
    "workflows": [
      "workflow_123",
      "workflow_456"
    ],
    "tags": [
      "medical",
      "fhir"
    ],
    "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35"
  }
}

Update agent

PUT/agent/{id}

Updates an existing agent's configuration

RequiresBearerauthentication

Path parameters

idstringrequired

Agent ID

Body parameters

namestringrequired

Agent name

descriptionstringoptional

Agent description

promptsstring[]required

Array of prompt IDs to use for this agent

toolsstring[]optional

Array of MCP server tool IDs to use for this agent

workflowsstring[]optional

Array of workflow IDs to expose as tools for this agent

tagsstring[]optional

Tags for categorizing the agent

provideroneOfrequired

FHIR provider ID(s) for this agent. Required. In shared/experiment environments, the default sandbox provider is used if a different provider is not explicitly specified.

Returns  

Agent updated successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Agent ID

namestringoptional

Agent name

descriptionstringoptional

Agent description

promptsstring[]optional

Array of prompt IDs used by this agent

toolsstring[]optional

Array of MCP server tool IDs used by this agent

workflowsstring[]optional

Array of workflow IDs exposed as tools by this agent

tagsstring[]optional

Tags for categorizing the agent

provideroneOfoptional

FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers

PUTRequest
curl -X PUT 'https://experiment.app.pheno.ml/agent/%7Bid%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Example Name",
  "description": "An AI assistant for medical information processing",
  "prompts": [
    "prompt_123",
    "prompt_456"
  ],
  "tools": [
    "mcp_server_123",
    "mcp_server_456"
  ],
  "workflows": [
    "workflow_123",
    "workflow_456"
  ],
  "tags": [
    "medical",
    "fhir"
  ],
  "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35"
}'
200 OKResponse
{
  "success": true,
  "message": "Agent updated successfully",
  "data": {
    "id": "agent_123",
    "name": "Medical Assistant",
    "description": "An AI assistant for medical information processing",
    "prompts": [
      "prompt_123",
      "prompt_456"
    ],
    "tools": [
      "mcp_server_123",
      "mcp_server_456"
    ],
    "workflows": [
      "workflow_123",
      "workflow_456"
    ],
    "tags": [
      "medical",
      "fhir"
    ],
    "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35"
  }
}

Delete agent

DELETE/agent/{id}

Deletes an existing agent

RequiresBearerauthentication

Path parameters

idstringrequired

Agent ID

Returns  

Agent deleted successfully

Response fields

successbooleanoptional
messagestringoptional
DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/agent/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Agent deleted successfully"
}

Patch agent

PATCH/agent/{id}

Patches an existing agent's configuration

RequiresBearerauthentication

Path parameters

idstringrequired

Agent ID

Returns  

Agent patched successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Agent ID

namestringoptional

Agent name

descriptionstringoptional

Agent description

promptsstring[]optional

Array of prompt IDs used by this agent

toolsstring[]optional

Array of MCP server tool IDs used by this agent

workflowsstring[]optional

Array of workflow IDs exposed as tools by this agent

tagsstring[]optional

Tags for categorizing the agent

provideroneOfoptional

FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers

PATCHRequest
curl -X PATCH 'https://experiment.app.pheno.ml/agent/%7Bid%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '[
  {
    "op": "replace",
    "path": "/name",
    "value": "Updated Agent Name"
  },
  {
    "op": "add",
    "path": "/tags/-",
    "value": "new-tag"
  },
  {
    "op": "remove",
    "path": "/description"
  }
]'
200 OKResponse
{
  "success": true,
  "message": "Agent patched successfully",
  "data": {
    "id": "agent_123",
    "name": "Medical Assistant",
    "description": "An AI assistant for medical information processing",
    "prompts": [
      "prompt_123",
      "prompt_456"
    ],
    "tools": [
      "mcp_server_123",
      "mcp_server_456"
    ],
    "workflows": [
      "workflow_123",
      "workflow_456"
    ],
    "tags": [
      "medical",
      "fhir"
    ],
    "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35"
  }
}

Create a new agent

POST/agent/create

Creates a new PhenoAgent with specified configuration

RequiresBearerauthentication

Body parameters

namestringrequired

Agent name

descriptionstringoptional

Agent description

promptsstring[]required

Array of prompt IDs to use for this agent

toolsstring[]optional

Array of MCP server tool IDs to use for this agent

workflowsstring[]optional

Array of workflow IDs to expose as tools for this agent

tagsstring[]optional

Tags for categorizing the agent

provideroneOfrequired

FHIR provider ID(s) for this agent. Required. In shared/experiment environments, the default sandbox provider is used if a different provider is not explicitly specified.

Returns  

Agent created successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Agent ID

namestringoptional

Agent name

descriptionstringoptional

Agent description

promptsstring[]optional

Array of prompt IDs used by this agent

toolsstring[]optional

Array of MCP server tool IDs used by this agent

workflowsstring[]optional

Array of workflow IDs exposed as tools by this agent

tagsstring[]optional

Tags for categorizing the agent

provideroneOfoptional

FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/agent/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Example Name",
  "description": "An AI assistant for medical information processing",
  "prompts": [
    "prompt_123",
    "prompt_456"
  ],
  "tools": [
    "mcp_server_123",
    "mcp_server_456"
  ],
  "workflows": [
    "workflow_123",
    "workflow_456"
  ],
  "tags": [
    "medical",
    "fhir"
  ],
  "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35"
}'
201 CreatedResponse
{
  "success": true,
  "message": "Agent created successfully",
  "data": {
    "id": "agent_123",
    "name": "Medical Assistant",
    "description": "An AI assistant for medical information processing",
    "prompts": [
      "prompt_123",
      "prompt_456"
    ],
    "tools": [
      "mcp_server_123",
      "mcp_server_456"
    ],
    "workflows": [
      "workflow_123",
      "workflow_456"
    ],
    "tags": [
      "medical",
      "fhir"
    ],
    "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35"
  }
}

List agents

GET/agent/list

Retrieves a list of PhenoAgents belonging to the authenticated user

RequiresBearerauthentication

Query parameters

tagsstringoptional

Filter by tags

Returns  

Agents retrieved successfully

Response fields

successbooleanoptional
messagestringoptional
agentsobject[]optional
idstringoptional

Agent ID

namestringoptional

Agent name

descriptionstringoptional

Agent description

promptsstring[]optional

Array of prompt IDs used by this agent

toolsstring[]optional

Array of MCP server tool IDs used by this agent

workflowsstring[]optional

Array of workflow IDs exposed as tools by this agent

tagsstring[]optional

Tags for categorizing the agent

provideroneOfoptional

FHIR provider ID(s) - must be valid UUIDs from existing FHIR providers

GETRequest
curl 'https://experiment.app.pheno.ml/agent/list?tags=example' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Agents retrieved successfully",
  "agents": [
    {
      "id": "agent_123",
      "name": "Medical Assistant",
      "description": "An AI assistant for medical information processing",
      "prompts": [
        "prompt_123",
        "prompt_456"
      ],
      "tools": [
        "mcp_server_123",
        "mcp_server_456"
      ],
      "workflows": [
        "workflow_123",
        "workflow_456"
      ],
      "tags": [
        "medical",
        "fhir"
      ],
      "provider": "7002b0b4-8d09-445a-bf65-0fafdaf26c35"
    }
  ]
}

Chat with agent

POST/agent/chat

Send a message to an agent and receive a JSON response.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Body parameters

messagestringrequired

The message to send to the agent

contextstringoptional

Optional context for the conversation

session_idstringoptional

Optional session ID for conversation continuity. Only one request may be active for a session at a time; overlapping turns for the same session return 409 Conflict.

agent_idstringrequired

The ID of the agent to chat with

enhanced_reasoningbooleanoptionaldefault false

Enable enhanced reasoning capabilities. Increases latency but improves response quality and reliability.

Returns  

Chat response received successfully

Response fields

responsestringoptional

Agent's response

successbooleanoptional
messagestringoptional

Status message

session_idstringoptional

Chat session ID

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/agent/chat' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "message": "What is the patient'\''s current condition?",
  "agent_id": "agent-123",
  "session_id": "session-abc123"
}'
200 OKResponse
{
  "success": true,
  "message": "Response generated successfully",
  "response": "Based on the patient records, they have been diagnosed with Type 2 Diabetes Mellitus (ICD-10: E11.65) and Essential Hypertension (ICD-10: I10). Current medications include Metformin 500mg BID and Lisinopril 10mg daily. Most recent HbA1c was 7.2% on 2024-12-15.",
  "session_id": "session-abc123"
}

Get chat messages

GET/agent/chat/messages

Retrieves a list of chat messages for a given chat session

RequiresBearerauthentication

Query parameters

chat_session_idstringrequired

Chat session ID

num_messagesintegeroptionaldefault 10

Number of messages to return

rolestringoptional

Filter by one or more message roles. Multiple roles can be specified as a comma-separated string. If not specified, messages with all roles are returned.

Available roles:

  • user - Messages from the user
  • assistant - Text responses from the AI assistant
  • model - Function/tool call requests from the model
  • function - Function/tool call results
userassistantmodelfunction
orderstringoptionaldefault desc

Order of messages

ascdesc
Returns  

Chat messages retrieved successfully

Response fields

messagesobject[]optional
idstringoptional

Chat message ID

session_idstringoptional

Chat session ID

rolestringoptional

Message role indicating the source/type of the message:

  • user - Messages from the user
  • assistant - Text responses from the AI assistant
  • model - Function/tool call requests to the model
  • function - Function/tool call results
userassistantmodelfunction
contentstringoptional

Message content

createdstringoptional

Message created time

updatedstringoptional

Message updated time

function_namestringoptional

Function name

function_argsobjectoptional

Function arguments

function_resultobjectoptional

Function result

message_orderintegeroptional

Message order

totalintegeroptional
session_idstringoptional
GETRequest
curl 'https://experiment.app.pheno.ml/agent/chat/messages?role=user' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "messages": [
    {
      "id": "message_123",
      "session_id": "session_123",
      "role": "user",
      "content": "Hello, how are you?",
      "created": "2021-01-01T00:00:00Z",
      "updated": "2021-01-01T00:00:00Z",
      "function_name": "get_patient_info",
      "function_args": {
        "patient_id": "123"
      },
      "function_result": {
        "name": "John Doe"
      },
      "message_order": 1
    }
  ],
  "total": 10,
  "session_id": "session_123"
}

Chat with agent (streaming)

POST/agent/stream-chat

Send a message to an agent and receive the response as a Server-Sent Events (SSE) stream. Events include message_start, content_delta, tool_use, tool_result, message_end, and error.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Body parameters

messagestringrequired

The message to send to the agent

contextstringoptional

Optional context for the conversation

session_idstringoptional

Optional session ID for conversation continuity. Only one request may be active for a session at a time; overlapping turns for the same session return 409 Conflict.

agent_idstringrequired

The ID of the agent to chat with

enhanced_reasoningbooleanoptionaldefault false

Enable enhanced reasoning capabilities. Increases latency but improves response quality and reliability.

Returns  

Streaming chat response. Each frame is a standard SSE record (event: line + data: JSON line). The example shows a single content_delta payload — multiple frames stream until message_end.

Response fields

typestringoptional

The event type

message_startcontent_deltatool_usetool_resultmessage_enderror
session_idstringoptional

Chat session ID

contentstringoptional

Incremental text content (present in content_delta events)

successbooleanoptional

Whether the operation was successful

messagestringoptional

Status message

function_namestringoptional

Tool/function name (present in tool_use and tool_result events)

function_argsobjectoptional

Tool arguments (present in tool_use events)

function_resultobjectoptional

Tool execution result (present in tool_result events)

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/agent/stream-chat' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "message": "What is the patient'\''s current condition?",
  "context": "Respond concisely and with clear rationale",
  "session_id": "session-abc123",
  "agent_id": "agent-123",
  "enhanced_reasoning": false
}'
200 OKResponse
{
  "type": "content_delta",
  "session_id": "session_123",
  "content": "I'll create a patient record...",
  "success": true,
  "message": "Streaming chat response. Each frame is a standard SSE record\n(`event:` line + `data:` JSON line). The example shows a single\n`content_delta` payload — multiple frames stream until `message_end`.",
  "function_name": "lang2fhir_search",
  "function_args": {},
  "function_result": {}
}

Create agent prompt

POST/agent/prompts

Creates a new agent prompt

RequiresBearerauthentication

Body parameters

namestringrequired

Prompt name

descriptionstringoptional

Prompt description

contentstringrequired

Prompt content

is_defaultbooleanoptional

Whether this is a default prompt

tagsstring[]optional

Tags for categorizing the prompt

Returns  

Prompt created successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Prompt ID

namestringoptional

Prompt name

descriptionstringoptional

Prompt description

contentstringoptional

Prompt content

is_defaultbooleanoptional

Whether this is a default prompt

tagsstring[]optional

Tags for categorizing the prompt

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/agent/prompts' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Medical Assistant System Prompt",
  "description": "System prompt for medical assistant agent",
  "content": "You are a helpful medical assistant specialized in FHIR data processing...",
  "is_default": false,
  "tags": [
    "medical",
    "system"
  ]
}'
201 CreatedResponse
{
  "success": true,
  "message": "Prompt created successfully",
  "data": {
    "id": "prompt_123",
    "name": "Medical Assistant System Prompt",
    "description": "System prompt for medical assistant agent",
    "content": "You are a helpful medical assistant...",
    "is_default": false,
    "tags": [
      "medical",
      "system"
    ]
  }
}

Get prompt by ID

GET/agent/prompts/{id}

Retrieves a specific prompt by its ID

RequiresBearerauthentication

Path parameters

idstringrequired

Prompt ID

Returns  

Prompt retrieved successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Prompt ID

namestringoptional

Prompt name

descriptionstringoptional

Prompt description

contentstringoptional

Prompt content

is_defaultbooleanoptional

Whether this is a default prompt

tagsstring[]optional

Tags for categorizing the prompt

GETRequest
curl 'https://experiment.app.pheno.ml/agent/prompts/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Prompt retrieved successfully",
  "data": {
    "id": "prompt_123",
    "name": "Medical Assistant System Prompt",
    "description": "System prompt for medical assistant agent",
    "content": "You are a helpful medical assistant...",
    "is_default": false,
    "tags": [
      "medical",
      "system"
    ]
  }
}

Update prompt

PUT/agent/prompts/{id}

Updates an existing prompt

RequiresBearerauthentication

Path parameters

idstringrequired

Prompt ID

Body parameters

namestringoptional

Prompt name

descriptionstringoptional

Prompt description

contentstringoptional

Prompt content

is_defaultbooleanoptional

Whether this is a default prompt

tagsstring[]optional

Tags for categorizing the prompt

Returns  

Prompt updated successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Prompt ID

namestringoptional

Prompt name

descriptionstringoptional

Prompt description

contentstringoptional

Prompt content

is_defaultbooleanoptional

Whether this is a default prompt

tagsstring[]optional

Tags for categorizing the prompt

PUTRequest
curl -X PUT 'https://experiment.app.pheno.ml/agent/prompts/%7Bid%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Medical Assistant System Prompt",
  "description": "System prompt for medical assistant agent",
  "content": "You are a helpful medical assistant specialized in FHIR data processing...",
  "is_default": false,
  "tags": [
    "medical",
    "system"
  ]
}'
200 OKResponse
{
  "success": true,
  "message": "Prompt updated successfully",
  "data": {
    "id": "prompt_123",
    "name": "Medical Assistant System Prompt",
    "description": "System prompt for medical assistant agent",
    "content": "You are a helpful medical assistant...",
    "is_default": false,
    "tags": [
      "medical",
      "system"
    ]
  }
}

Delete prompt

DELETE/agent/prompts/{id}

Deletes a prompt

RequiresBearerauthentication

Path parameters

idstringrequired

Prompt ID

Returns  

Prompt deleted successfully

Response fields

successbooleanoptional
messagestringoptional
DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/agent/prompts/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Prompt deleted successfully"
}

Patch prompt

PATCH/agent/prompts/{id}

Patches an existing prompt

RequiresBearerauthentication

Path parameters

idstringrequired

Agent Prompt ID

Returns  

Prompt patched successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional
idstringoptional

Prompt ID

namestringoptional

Prompt name

descriptionstringoptional

Prompt description

contentstringoptional

Prompt content

is_defaultbooleanoptional

Whether this is a default prompt

tagsstring[]optional

Tags for categorizing the prompt

PATCHRequest
curl -X PATCH 'https://experiment.app.pheno.ml/agent/prompts/%7Bid%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '[
  {
    "op": "replace",
    "path": "/name",
    "value": "Updated Agent Name"
  },
  {
    "op": "add",
    "path": "/tags/-",
    "value": "new-tag"
  },
  {
    "op": "remove",
    "path": "/description"
  }
]'
200 OKResponse
{
  "success": true,
  "message": "Prompt patched successfully",
  "data": {
    "id": "prompt_123",
    "name": "Medical Assistant System Prompt",
    "description": "System prompt for medical assistant agent",
    "content": "You are a helpful medical assistant...",
    "is_default": false,
    "tags": [
      "medical",
      "system"
    ]
  }
}

List agent prompts

GET/agent/prompts/list

Retrieves a list of agent prompts belonging to the authenticated user

RequiresBearerauthentication
Returns  

Prompts retrieved successfully

Response fields

successbooleanoptional
messagestringoptional
promptsobject[]optional
idstringoptional

Prompt ID

namestringoptional

Prompt name

descriptionstringoptional

Prompt description

contentstringoptional

Prompt content

is_defaultbooleanoptional

Whether this is a default prompt

tagsstring[]optional

Tags for categorizing the prompt

GETRequest
curl 'https://experiment.app.pheno.ml/agent/prompts/list' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Prompts retrieved successfully",
  "prompts": [
    {
      "id": "prompt_123",
      "name": "Medical Assistant System Prompt",
      "description": "System prompt for medical assistant agent",
      "content": "You are a helpful medical assistant...",
      "is_default": false,
      "tags": [
        "medical",
        "system"
      ]
    }
  ]
}

Workflow

Create and execute clinical workflows. Define workflow logic and test execution with sample data.

List all workflows

GET/workflows

Retrieves all workflow definitions for the authenticated user

RequiresBearerauthentication

Query parameters

verbosebooleanoptionaldefault false

If true, includes full workflow implementation details in workflow_details field

Returns  

Successfully retrieved workflows

Response fields

successbooleanoptional

Whether the workflow list was retrieved successfully

messagestringoptional

Status message

workflowsobject[]optional

Array of simplified workflow responses for the authenticated user

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Simplified list of workflow steps without operation details

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

workflow_detailsobject[]optional

Only included when verbose=true - contains full implementation details for all workflows

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Ordered list of workflow execution steps

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

GETRequest
curl 'https://experiment.app.pheno.ml/workflows?verbose=true' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully retrieved workflows",
  "workflows": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "name": "Patient Data Mapping Workflow",
      "workflow_instructions": "Given diagnosis data, find the patient and create condition record",
      "sample_data": {
        "diagnosis_code": "I10",
        "diagnosis_date": "2025-01-01",
        "patient_first_name": "Clay",
        "patient_last_name": "Rippin"
      },
      "config": {
        "fhir_provider_ids": [
          "550e8400-e29b-41d4-a716-446655440000"
        ],
        "dynamic_generation": false
      },
      "graph": {
        "steps": [
          {
            "id": "step_1_id",
            "name": "Find Patient",
            "description": "Search for an existing patient by first name and last name",
            "type": "search",
            "provider_id": "550e8400-e29b-41d4-a716-446655440000"
          }
        ]
      },
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T15:45:00Z"
    }
  ],
  "workflow_details": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "name": "Patient Data Mapping Workflow",
      "workflow_instructions": "Given diagnosis data, find the patient and create condition record",
      "sample_data": {
        "diagnosis_code": "I10",
        "diagnosis_date": "2025-01-01",
        "patient_first_name": "Clay",
        "patient_last_name": "Rippin"
      },
      "config": {},
      "graph": {
        "steps": [
          {
            "id": "1",
            "name": "Create Patient Resource",
            "description": "Create a FHIR Patient resource from input data",
            "type": "create",
            "operation": {
              "search_definition": {
                "original_query": "find patient {{patient_first_name}} {{patient_last_name}} by first name and last name",
                "resource_type": "Patient",
                "search_parameters": {
                  "family": "{{patient_last_name}}",
                  "given": "{{patient_first_name}}"
                },
                "required_fields": [
                  "id",
                  "name",
                  "identifier"
                ],
                "runtime_placeholders": {
                  "{{patient_first_name}}": "input.patient_first_name",
                  "{{patient_last_name}}": "input.patient_last_name"
                }
              },
              "create_definition": {
                "original_description": "create condition with diagnosis code {{diagnosis_code}} and diagnosis date 2025-01-01",
                "resource_type": "Condition",
                "resource_template": {
                  "resourceType": "Condition",
                  "code": {
                    "coding": [
                      {
                        "code": "{{diagnosis_code}}",
                        "system": "http://hl7.org/fhir/sid/icd-10"
                      }
                    ]
                  },
                  "subject": {
                    "reference": "Patient/{{step_1_id}}"
                  }
                },
                "runtime_placeholders": {
                  "{{diagnosis_code}}": "input.diagnosis_code",
                  "{{diagnosis_date}}": "input.diagnosis_date"
                }
              },
              "workflow_definition": {
                "workflow_id": "550e8400-e29b-41d4-a716-446655440002",
                "input": {
                  "patient_id": "{{step_1_id}}",
                  "additional_context": "laboratory_results"
                },
                "runtime_placeholders": {
                  "{{step_1_id}}": "step_1.result.id",
                  "{{patient_data}}": "input.patient_data"
                }
              },
              "decision_definition": {
                "expression": "input.patient_age >= 18",
                "paths": {
                  "true": "step_adult_workflow",
                  "false": "step_pediatric_workflow",
                  "default": "step_error_handler"
                },
                "runtime_placeholders": {
                  "{{patient_age}}": "input.patient_age",
                  "{{diagnosis_type}}": "step_2.result.diagnosis_category"
                }
              }
            },
            "provider_id": "550e8400-e29b-41d4-a716-446655440000",
            "dependencies": [],
            "dynamic_generation": false
          }
        ]
      },
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T15:45:00Z"
    }
  ]
}

Create new workflow

POST/workflows

Creates a new workflow definition with graph generation from workflow instructions

RequiresBearerauthentication

Query parameters

verbosebooleanoptionaldefault false

If true, includes full workflow implementation details in workflow_details field

Body parameters

namestringrequired

Human-readable name for the workflow

workflow_instructionsstringrequired

Natural language instructions that define the workflow logic

sample_dataobjectrequired

Sample data to use for workflow graph generation

fhir_provider_idoneOfrequired

FHIR provider ID(s) - must be valid UUID(s) from existing FHIR providers

dynamic_generationbooleanoptional

Enable dynamic lang2fhir calls instead of pre-populated templates

Returns  

Successfully created workflow

Response fields

successbooleanoptional

Whether the workflow was created successfully

messagestringoptional

Status message

workflow_idstring (uuid)optional

ID of the created workflow

workflowobjectoptional

Simplified workflow representation without implementation details

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Simplified list of workflow steps without operation details

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

workflow_detailsobjectoptional

Only included when verbose=true - contains full implementation details including operation definitions and placeholders

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Ordered list of workflow execution steps

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/workflows' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Patient Data Mapping Workflow",
  "workflow_instructions": "Given diagnosis data, find the patient and create a condition record linked to their encounter",
  "sample_data": {
    "patient_last_name": "Rippin",
    "patient_first_name": "Clay",
    "diagnosis_code": "I10",
    "encounter_date": "2024-01-15"
  },
  "fhir_provider_id": "550e8400-e29b-41d4-a716-446655440000"
}'
200 OKResponse
{
  "success": true,
  "message": "Workflow created successfully",
  "workflow_id": "7a8b9c0d-1234-5678-abcd-ef9876543210",
  "workflow": {
    "id": "7a8b9c0d-1234-5678-abcd-ef9876543210",
    "name": "Patient Data Mapping Workflow",
    "workflow_instructions": "Given diagnosis data, find the patient and create a condition record linked to their encounter",
    "sample_data": {
      "patient_last_name": "Rippin",
      "patient_first_name": "Clay",
      "diagnosis_code": "I10",
      "encounter_date": "2024-01-15"
    },
    "created_at": "2024-01-15T09:30:00Z",
    "updated_at": "2024-01-15T09:30:00Z"
  }
}

Get workflow by ID

GET/workflows/{id}

Retrieves a workflow definition by its ID

RequiresBearerauthentication

Path parameters

idstring (uuid)required

ID of the workflow to retrieve

Query parameters

verbosebooleanoptionaldefault false

If true, includes full workflow implementation details in workflow_details field

Returns  

Successfully retrieved workflow

Response fields

successbooleanoptional
workflowobjectoptional

Simplified workflow representation without implementation details

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Simplified list of workflow steps without operation details

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

workflow_detailsobjectoptional

Only included when verbose=true - contains full implementation details

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Ordered list of workflow execution steps

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

GETRequest
curl 'https://experiment.app.pheno.ml/workflows/550e8400-e29b-41d4-a716-446655440000?verbose=true' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "workflow": {
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "name": "Patient Data Mapping Workflow",
    "workflow_instructions": "Given diagnosis data, find the patient and create condition record",
    "sample_data": {
      "diagnosis_code": "I10",
      "diagnosis_date": "2025-01-01",
      "patient_first_name": "Clay",
      "patient_last_name": "Rippin"
    },
    "config": {
      "fhir_provider_ids": [
        "550e8400-e29b-41d4-a716-446655440000"
      ],
      "dynamic_generation": false
    },
    "graph": {
      "steps": [
        {
          "id": "step_1_id",
          "name": "Find Patient",
          "description": "Search for an existing patient by first name and last name",
          "type": "search",
          "provider_id": "550e8400-e29b-41d4-a716-446655440000"
        }
      ]
    },
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T15:45:00Z"
  },
  "workflow_details": {
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "name": "Patient Data Mapping Workflow",
    "workflow_instructions": "Given diagnosis data, find the patient and create condition record",
    "sample_data": {
      "diagnosis_code": "I10",
      "diagnosis_date": "2025-01-01",
      "patient_first_name": "Clay",
      "patient_last_name": "Rippin"
    },
    "config": {},
    "graph": {
      "steps": [
        {
          "id": "1",
          "name": "Create Patient Resource",
          "description": "Create a FHIR Patient resource from input data",
          "type": "create",
          "operation": {
            "search_definition": {
              "original_query": "find patient {{patient_first_name}} {{patient_last_name}} by first name and last name",
              "resource_type": "Patient",
              "search_parameters": {
                "family": "{{patient_last_name}}",
                "given": "{{patient_first_name}}"
              },
              "required_fields": [
                "id",
                "name",
                "identifier"
              ],
              "runtime_placeholders": {
                "{{patient_first_name}}": "input.patient_first_name",
                "{{patient_last_name}}": "input.patient_last_name"
              }
            },
            "create_definition": {
              "original_description": "create condition with diagnosis code {{diagnosis_code}} and diagnosis date 2025-01-01",
              "resource_type": "Condition",
              "resource_template": {
                "resourceType": "Condition",
                "code": {
                  "coding": [
                    {
                      "code": "{{diagnosis_code}}",
                      "system": "http://hl7.org/fhir/sid/icd-10"
                    }
                  ]
                },
                "subject": {
                  "reference": "Patient/{{step_1_id}}"
                }
              },
              "runtime_placeholders": {
                "{{diagnosis_code}}": "input.diagnosis_code",
                "{{diagnosis_date}}": "input.diagnosis_date"
              }
            },
            "workflow_definition": {
              "workflow_id": "550e8400-e29b-41d4-a716-446655440002",
              "input": {
                "patient_id": "{{step_1_id}}",
                "additional_context": "laboratory_results"
              },
              "runtime_placeholders": {
                "{{step_1_id}}": "step_1.result.id",
                "{{patient_data}}": "input.patient_data"
              }
            },
            "decision_definition": {
              "expression": "input.patient_age >= 18",
              "paths": {
                "true": "step_adult_workflow",
                "false": "step_pediatric_workflow",
                "default": "step_error_handler"
              },
              "runtime_placeholders": {
                "{{patient_age}}": "input.patient_age",
                "{{diagnosis_type}}": "step_2.result.diagnosis_category"
              }
            }
          },
          "provider_id": "550e8400-e29b-41d4-a716-446655440000",
          "dependencies": [],
          "dynamic_generation": false
        }
      ]
    },
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T15:45:00Z"
  }
}

Update workflow

PUT/workflows/{id}

Updates an existing workflow definition

RequiresBearerauthentication

Path parameters

idstring (uuid)required

ID of the workflow to update

Query parameters

verbosebooleanoptionaldefault false

If true, includes full workflow implementation details in workflow_details field

Body parameters

namestringrequired

Human-readable name for the workflow

workflow_instructionsstringrequired

Natural language instructions that define the workflow logic

sample_dataobjectrequired

Sample data to use for workflow graph generation

fhir_provider_idoneOfrequired

FHIR provider ID(s) - must be valid UUID(s) from existing FHIR providers

dynamic_generationbooleanoptional

Enable dynamic lang2fhir calls instead of pre-populated templates

Returns  

Successfully updated workflow

Response fields

successbooleanoptional
messagestringoptional
workflowobjectoptional

Simplified workflow representation without implementation details

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Simplified list of workflow steps without operation details

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

workflow_detailsobjectoptional

Only included when verbose=true - contains full implementation details

idstring (uuid)optional

Unique identifier for the workflow

namestringoptional

Human-readable name for the workflow

workflow_instructionsstringoptional

Natural language instructions that define the workflow logic

sample_dataobjectoptional

Sample data used for workflow graph generation

configobjectoptional
fhir_provider_idsstring (uuid)[]optional

FHIR provider IDs for executing workflow steps

dynamic_generationbooleanoptional

Whether to use dynamic lang2fhir generation instead of pre-populated templates

graphobjectoptional
stepsobject[]optional

Ordered list of workflow execution steps

created_atstring (date-time)optional

Timestamp when the workflow was created

updated_atstring (date-time)optional

Timestamp when the workflow was last updated

PUTRequest
curl -X PUT 'https://experiment.app.pheno.ml/workflows/%7Bid%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Updated Patient Data Mapping Workflow",
  "workflow_instructions": "Given diagnosis data, find the patient and create condition record",
  "sample_data": {
    "patient_last_name": "Smith",
    "patient_first_name": "John",
    "diagnosis_code": "E11"
  },
  "fhir_provider_id": "550e8400-e29b-41d4-a716-446655440000",
  "dynamic_generation": false
}'
200 OKResponse
{
  "success": true,
  "message": "Successfully updated workflow",
  "workflow": {
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "name": "Patient Data Mapping Workflow",
    "workflow_instructions": "Given diagnosis data, find the patient and create condition record",
    "sample_data": {
      "diagnosis_code": "I10",
      "diagnosis_date": "2025-01-01",
      "patient_first_name": "Clay",
      "patient_last_name": "Rippin"
    },
    "config": {
      "fhir_provider_ids": [
        "550e8400-e29b-41d4-a716-446655440000"
      ],
      "dynamic_generation": false
    },
    "graph": {
      "steps": [
        {
          "id": "step_1_id",
          "name": "Find Patient",
          "description": "Search for an existing patient by first name and last name",
          "type": "search",
          "provider_id": "550e8400-e29b-41d4-a716-446655440000"
        }
      ]
    },
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T15:45:00Z"
  },
  "workflow_details": {
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "name": "Patient Data Mapping Workflow",
    "workflow_instructions": "Given diagnosis data, find the patient and create condition record",
    "sample_data": {
      "diagnosis_code": "I10",
      "diagnosis_date": "2025-01-01",
      "patient_first_name": "Clay",
      "patient_last_name": "Rippin"
    },
    "config": {},
    "graph": {
      "steps": [
        {
          "id": "1",
          "name": "Create Patient Resource",
          "description": "Create a FHIR Patient resource from input data",
          "type": "create",
          "operation": {
            "search_definition": {
              "original_query": "find patient {{patient_first_name}} {{patient_last_name}} by first name and last name",
              "resource_type": "Patient",
              "search_parameters": {
                "family": "{{patient_last_name}}",
                "given": "{{patient_first_name}}"
              },
              "required_fields": [
                "id",
                "name",
                "identifier"
              ],
              "runtime_placeholders": {
                "{{patient_first_name}}": "input.patient_first_name",
                "{{patient_last_name}}": "input.patient_last_name"
              }
            },
            "create_definition": {
              "original_description": "create condition with diagnosis code {{diagnosis_code}} and diagnosis date 2025-01-01",
              "resource_type": "Condition",
              "resource_template": {
                "resourceType": "Condition",
                "code": {
                  "coding": [
                    {
                      "code": "{{diagnosis_code}}",
                      "system": "http://hl7.org/fhir/sid/icd-10"
                    }
                  ]
                },
                "subject": {
                  "reference": "Patient/{{step_1_id}}"
                }
              },
              "runtime_placeholders": {
                "{{diagnosis_code}}": "input.diagnosis_code",
                "{{diagnosis_date}}": "input.diagnosis_date"
              }
            },
            "workflow_definition": {
              "workflow_id": "550e8400-e29b-41d4-a716-446655440002",
              "input": {
                "patient_id": "{{step_1_id}}",
                "additional_context": "laboratory_results"
              },
              "runtime_placeholders": {
                "{{step_1_id}}": "step_1.result.id",
                "{{patient_data}}": "input.patient_data"
              }
            },
            "decision_definition": {
              "expression": "input.patient_age >= 18",
              "paths": {
                "true": "step_adult_workflow",
                "false": "step_pediatric_workflow",
                "default": "step_error_handler"
              },
              "runtime_placeholders": {
                "{{patient_age}}": "input.patient_age",
                "{{diagnosis_type}}": "step_2.result.diagnosis_category"
              }
            }
          },
          "provider_id": "550e8400-e29b-41d4-a716-446655440000",
          "dependencies": [],
          "dynamic_generation": false
        }
      ]
    },
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T15:45:00Z"
  }
}

Delete workflow

DELETE/workflows/{id}

Deletes a workflow definition by its ID

RequiresBearerauthentication

Path parameters

idstring (uuid)required

ID of the workflow to delete

Returns  

Successfully deleted workflow

Response fields

successbooleanoptional
messagestringoptional
DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/workflows/550e8400-e29b-41d4-a716-446655440000' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully deleted workflow"
}

Execute workflow

POST/workflows/{id}/execute

Executes a workflow with provided input data and returns results

RequiresBearerauthentication

Path parameters

idstring (uuid)required

ID of the workflow to execute

Body parameters

input_dataobjectrequired

Input data for workflow execution

previewbooleanoptionaldefault false

If true, create operations return mock resources instead of persisting to the FHIR server

Returns  

Successfully executed workflow

Response fields

successbooleanoptional

Whether the workflow execution was successful

messagestringoptional

Status message with execution details

resultsobjectoptional
stepsobjectoptional

Results for each executed workflow step, keyed by step ID

previewbooleanoptional

Whether the workflow was executed in preview mode

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/workflows/7a8b9c0d-1234-5678-abcd-ef9876543210/execute' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "input_data": {
    "patient_last_name": "Johnson",
    "patient_first_name": "Mary",
    "diagnosis_code": "M79.3",
    "encounter_date": "2024-03-20"
  }
}'
200 OKResponse
{
  "success": true,
  "message": "Workflow executed successfully",
  "results": {
    "steps": {
      "step_1_id": {
        "type": "search_result",
        "original_query": "find patient by first name Mary and last name Johnson",
        "resource_type": "Patient",
        "search_params": {
          "family": "Johnson",
          "given": "Mary"
        },
        "results": [
          {
            "resourceType": "Patient",
            "id": "patient-123",
            "name": [
              {
                "family": "Johnson",
                "given": [
                  "Mary"
                ],
                "use": "usual"
              }
            ],
            "gender": "female",
            "birthDate": "1961-01-01"
          }
        ]
      },
      "step_2_id": {
        "type": "create_result",
        "id": "condition-456",
        "resource_type": "Condition",
        "original_desc": "create condition with diagnosis code M79.3 for the patient from step_1_id",
        "preview": false,
        "created_resource": {
          "resourceType": "Condition",
          "id": "condition-456",
          "clinicalStatus": {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
                "code": "active"
              }
            ]
          },
          "code": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/sid/icd-10",
                "code": "M79.3",
                "display": "Panniculitis, unspecified"
              }
            ]
          },
          "subject": {
            "reference": "Patient/patient-123"
          }
        }
      }
    }
  },
  "preview": false
}

Analyze patient cohorts

POST/tools/cohort

Uses LLM to extract search concepts from natural language and builds patient cohorts with inclusion/exclusion criteria

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Body parameters

textstringrequired

Natural language text describing the patient cohort criteria

providerstring (uuid)required

FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)

Returns  

Successfully analyzed cohort and retrieved patient list

Response fields

successbooleanoptional

Whether the cohort analysis was successful

messagestringoptional

Status message with details about the analysis

patientIdsstring[]optional

Array of patient IDs that match the cohort criteria

patientCountintegeroptional

Total number of patients in the cohort

queriesobject[]optional

Individual search concepts that were identified and executed

resource_typestringoptional

The FHIR resource type identified for this concept

search_paramsstringoptional

FHIR search parameters for this concept

conceptstringoptional

Description of what this search represents

excludebooleanoptional

Whether this is an exclusion criteria

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/tools/cohort' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "female patients over 20 with diabetes but not hypertension",
  "provider": "550e8400-e29b-41d4-a716-446655440000"
}'
200 OKResponse
{
  "success": true,
  "message": "Successfully analyzed cohort and retrieved patient list",
  "patientIds": [
    "patient-123",
    "patient-456",
    "patient-789"
  ],
  "patientCount": 33,
  "queries": [
    {
      "resource_type": "Patient",
      "search_params": "gender=female&birthdate=le2004-01-01",
      "concept": "female patients over 20",
      "exclude": false
    },
    {
      "resource_type": "Condition",
      "search_params": "code=55822004",
      "concept": "hyperlipidemia",
      "exclude": false
    }
  ]
}

Create FHIR resource from text and store it

POST/tools/lang2fhir-and-create

Converts natural language to FHIR resource and optionally stores it in a FHIR server

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Body parameters

resourcestringrequired

Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile.

autoappointmentcondition-encounter-diagnosismedicationrequestcareplancondition-problems-health-concernscoverageencounterobservation-clinical-resultobservation-labpatientprocedurequestionnairequestionnaireresponseservicerequestsimple-observationvital-signs
textstringrequired

Natural language text to convert to FHIR resource

providerstring (uuid)optional

FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)

Returns  

Successfully created FHIR resource

Response fields

fhir_resourceobjectoptional

The created FHIR resource

fhir_idstringoptional

ID of the resource in the FHIR server (if successfully stored)

successbooleanoptional
messagestringoptional

Status message

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/tools/lang2fhir-and-create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "resource": "condition-encounter-diagnosis",
  "text": "Patient John Doe has severe asthma with acute exacerbation",
  "provider": "550e8400-e29b-41d4-a716-446655440000"
}'
200 OKResponse
{
  "fhir_resource": {
    "resourceType": "Condition",
    "id": "condition-123",
    "code": {
      "coding": [
        {
          "system": "http://snomed.info/sct",
          "code": "195967001",
          "display": "Asthma"
        }
      ]
    },
    "subject": {
      "reference": "Patient/patient-123",
      "display": "John Doe"
    }
  },
  "fhir_id": "condition-123",
  "success": true,
  "message": "Successfully created FHIR resource"
}

Extract and store multiple FHIR resources

POST/tools/lang2fhir-and-create-multi

Extracts multiple FHIR resources from natural language text and stores them in a FHIR server. Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types. Resources are linked with proper references and submitted as a transaction bundle. For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically resolve them via PUT requests after the initial bundle creation.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Body parameters

textstringrequired

Natural language text containing multiple clinical concepts to extract

versionstringoptionaldefault R4

FHIR version to use

providerstringrequired

FHIR provider ID or name

Returns  

Successfully created FHIR resources

Response fields

successbooleanoptional

Whether the resources were created successfully

messagestringoptional

Status message

response_bundleobjectoptional

FHIR transaction-response Bundle from the server with resolved resource IDs

resourceTypestringoptional
typestringoptional
entryobject[]optional
resource_infoobject[]optional

Metadata about created resources (temp IDs, types, descriptions)

tempIdstringoptional

Original temporary UUID

resourceTypestringoptional

FHIR resource type

descriptionstringoptional

Text excerpt this resource was extracted from

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/tools/lang2fhir-and-create-multi' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
  "version": "R4",
  "provider": "medplum"
}'
200 OKResponse
{
  "success": true,
  "message": "Successfully created FHIR resources",
  "response_bundle": {
    "resourceType": "Bundle",
    "type": "transaction-response",
    "entry": [
      {}
    ]
  },
  "resource_info": [
    {
      "tempId": "urn:uuid:patient-abc123",
      "resourceType": "Patient",
      "description": "John Smith, 45-year-old male"
    }
  ]
}

Search FHIR resources from natural language

POST/tools/lang2fhir-and-search

Converts natural language to FHIR search parameters and executes search in FHIR server

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Body parameters

textstringrequired

Natural language text to convert to FHIR search parameters

patient_idstringoptional

Patient ID to filter results

countintegeroptional

Maximum number of results to return

providerstring (uuid)optional

FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)

Returns  

Successfully generated search and retrieved results

Response fields

resource_typestringoptional

The FHIR resource type identified for the search

search_paramsstringoptional

FHIR search parameters in standard format

fhir_resultsobject[]optional

Array of FHIR resources returned from the search

successbooleanoptional
messagestringoptional

Status message

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/tools/lang2fhir-and-search' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Find all appointments for patient John Doe next week",
  "patient_id": "patient-123",
  "count": 10,
  "provider": "550e8400-e29b-41d4-a716-446655440000"
}'
200 OKResponse
{
  "resource_type": "Appointment",
  "search_params": "patient=Patient/patient-123&date=ge2024-01-15&date=le2024-01-22",
  "fhir_results": [
    {
      "resourceType": "Appointment",
      "id": "appointment-123",
      "status": "booked",
      "start": "2024-01-16T10:00:00Z",
      "end": "2024-01-16T11:00:00Z",
      "participant": [
        {
          "actor": {
            "reference": "Patient/patient-123",
            "display": "John Doe"
          }
        }
      ]
    }
  ],
  "success": true,
  "message": "Successfully generated search and retrieved results"
}

Get MCP server by ID

GET/tools/mcp-server/{mcp_server_id}

Gets a MCP server by ID

RequiresBearerauthentication

Path parameters

mcp_server_idstringrequired

ID of the MCP server to retrieve

Returns  

Successfully retrieved MCP server

Response fields

successbooleanoptional

Whether the operation succeeded

messagestringoptional

Status message

dataobjectoptional

Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_serversobject[]optional

List of MCP servers. Returned by /tools/mcp-server/create (the newly created server) and /tools/mcp-server/list (all servers).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_server_toolsobject[]optional

Tools loaded from the MCP server. Returned by /tools/mcp-server/create alongside the server record, since tool discovery happens at create time.

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

GETRequest
curl 'https://experiment.app.pheno.ml/tools/mcp-server/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully retrieved MCP server",
  "data": {
    "id": "123",
    "name": "My MCP Server",
    "description": "My MCP Server is a server that provides MCP services",
    "mcp_server_url": "https://mcp.example.com"
  },
  "mcp_servers": [
    {
      "id": {},
      "name": {},
      "description": {},
      "mcp_server_url": {}
    }
  ],
  "mcp_server_tools": [
    {
      "id": "123",
      "name": "My MCP Server Tool",
      "description": "My MCP Server Tool is a tool that provides MCP services",
      "input_schema": {
        "name": "string",
        "age": "number"
      },
      "mcp_server_id": "123",
      "mcp_server_url": "https://mcp.example.com"
    }
  ]
}

Delete MCP server by ID

DELETE/tools/mcp-server/{mcp_server_id}

Deletes a MCP server by ID

RequiresBearerauthentication

Path parameters

mcp_server_idstringrequired

ID of the MCP server to delete

Returns  

Successfully deleted MCP server

Response fields

successbooleanoptional

Whether the operation succeeded

messagestringoptional

Status message

dataobjectoptional

Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_serversobject[]optional

List of MCP servers. Returned by /tools/mcp-server/create (the newly created server) and /tools/mcp-server/list (all servers).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_server_toolsobject[]optional

Tools loaded from the MCP server. Returned by /tools/mcp-server/create alongside the server record, since tool discovery happens at create time.

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/tools/mcp-server/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully deleted MCP server",
  "data": {
    "id": "123",
    "name": "My MCP Server",
    "description": "My MCP Server is a server that provides MCP services",
    "mcp_server_url": "https://mcp.example.com"
  },
  "mcp_servers": [
    {
      "id": {},
      "name": {},
      "description": {},
      "mcp_server_url": {}
    }
  ],
  "mcp_server_tools": [
    {
      "id": "123",
      "name": "My MCP Server Tool",
      "description": "My MCP Server Tool is a tool that provides MCP services",
      "input_schema": {
        "name": "string",
        "age": "number"
      },
      "mcp_server_id": "123",
      "mcp_server_url": "https://mcp.example.com"
    }
  ]
}

Create MCP server

POST/tools/mcp-server/create

Creates a new MCP server

RequiresBearerauthentication

Body parameters

namestringrequired

Name of the MCP server

mcp_server_urlstringrequired

URL of the MCP server

Returns  

Successfully created MCP server

Response fields

successbooleanoptional

Whether the operation succeeded

messagestringoptional

Status message

dataobjectoptional

Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_serversobject[]optional

List of MCP servers. Returned by /tools/mcp-server/create (the newly created server) and /tools/mcp-server/list (all servers).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_server_toolsobject[]optional

Tools loaded from the MCP server. Returned by /tools/mcp-server/create alongside the server record, since tool discovery happens at create time.

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/tools/mcp-server/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "My MCP Server",
  "mcp_server_url": "https://mcp.example.com"
}'
200 OKResponse
{
  "success": true,
  "message": "Successfully created MCP server",
  "data": {
    "id": "123",
    "name": "My MCP Server",
    "description": "My MCP Server is a server that provides MCP services",
    "mcp_server_url": "https://mcp.example.com"
  },
  "mcp_servers": [
    {
      "id": {},
      "name": {},
      "description": {},
      "mcp_server_url": {}
    }
  ],
  "mcp_server_tools": [
    {
      "id": "123",
      "name": "My MCP Server Tool",
      "description": "My MCP Server Tool is a tool that provides MCP services",
      "input_schema": {
        "name": "string",
        "age": "number"
      },
      "mcp_server_id": "123",
      "mcp_server_url": "https://mcp.example.com"
    }
  ]
}

List MCP servers

GET/tools/mcp-server/list

Lists all MCP servers for a specific user

RequiresBearerauthentication
Returns  

Successfully listed MCP servers

Response fields

successbooleanoptional

Whether the operation succeeded

messagestringoptional

Status message

dataobjectoptional

Single MCP server (returned by GET /tools/mcp-server/{mcp_server_id}).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_serversobject[]optional

List of MCP servers. Returned by /tools/mcp-server/create (the newly created server) and /tools/mcp-server/list (all servers).

idstringoptional

ID of the MCP server

namestringoptional

Name of the MCP server

descriptionstringoptional

Description of the MCP server

mcp_server_urlstringoptional

URL of the MCP server

mcp_server_toolsobject[]optional

Tools loaded from the MCP server. Returned by /tools/mcp-server/create alongside the server record, since tool discovery happens at create time.

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

GETRequest
curl 'https://experiment.app.pheno.ml/tools/mcp-server/list' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully listed MCP servers",
  "data": {
    "id": "123",
    "name": "My MCP Server",
    "description": "My MCP Server is a server that provides MCP services",
    "mcp_server_url": "https://mcp.example.com"
  },
  "mcp_servers": [
    {
      "id": {},
      "name": {},
      "description": {},
      "mcp_server_url": {}
    }
  ],
  "mcp_server_tools": [
    {
      "id": "123",
      "name": "My MCP Server Tool",
      "description": "My MCP Server Tool is a tool that provides MCP services",
      "input_schema": {
        "name": "string",
        "age": "number"
      },
      "mcp_server_id": "123",
      "mcp_server_url": "https://mcp.example.com"
    }
  ]
}

List MCP server tools

GET/tools/mcp-server/{mcp_server_id}/list

Lists all MCP server tools for a specific MCP server

RequiresBearerauthentication

Path parameters

mcp_server_idstringrequired

ID of the MCP server to list tools for

Returns  

Successfully listed MCP server tools

Response fields

successbooleanoptional

Whether the operation succeeded

messagestringoptional

Status message

dataobjectoptional

Single MCP server tool (returned by GET /tools/mcp-server/tool/{mcp_server_tool_id}).

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

mcp_server_toolsobject[]optional

List of MCP server tools. Returned by /tools/mcp-server/{mcp_server_id}/list.

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

GETRequest
curl 'https://experiment.app.pheno.ml/tools/mcp-server/abc-123-def-456/list' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully listed MCP server tools",
  "data": {
    "id": "123",
    "name": "My MCP Server Tool",
    "description": "My MCP Server Tool is a tool that provides MCP services",
    "input_schema": {
      "name": "string",
      "age": "number"
    },
    "mcp_server_id": "123",
    "mcp_server_url": "https://mcp.example.com"
  },
  "mcp_server_tools": [
    {
      "id": {},
      "name": {},
      "description": {},
      "input_schema": {},
      "mcp_server_id": {},
      "mcp_server_url": {}
    }
  ]
}

Get MCP server tool by ID

GET/tools/mcp-server/tool/{mcp_server_tool_id}

Gets a MCP server tool by ID

RequiresBearerauthentication

Path parameters

mcp_server_tool_idstringrequired

ID of the MCP server tool to retrieve

Returns  

Successfully retrieved MCP server tool

Response fields

successbooleanoptional

Whether the operation succeeded

messagestringoptional

Status message

dataobjectoptional

Single MCP server tool (returned by GET /tools/mcp-server/tool/{mcp_server_tool_id}).

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

mcp_server_toolsobject[]optional

List of MCP server tools. Returned by /tools/mcp-server/{mcp_server_id}/list.

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

GETRequest
curl 'https://experiment.app.pheno.ml/tools/mcp-server/tool/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully retrieved MCP server tool",
  "data": {
    "id": "123",
    "name": "My MCP Server Tool",
    "description": "My MCP Server Tool is a tool that provides MCP services",
    "input_schema": {
      "name": "string",
      "age": "number"
    },
    "mcp_server_id": "123",
    "mcp_server_url": "https://mcp.example.com"
  },
  "mcp_server_tools": [
    {
      "id": {},
      "name": {},
      "description": {},
      "input_schema": {},
      "mcp_server_id": {},
      "mcp_server_url": {}
    }
  ]
}

Delete MCP server tool by ID

DELETE/tools/mcp-server/tool/{mcp_server_tool_id}

Deletes a MCP server tool by ID

RequiresBearerauthentication

Path parameters

mcp_server_tool_idstringrequired

ID of the MCP server tool to delete

Returns  

Successfully deleted MCP server tool

Response fields

successbooleanoptional

Whether the operation succeeded

messagestringoptional

Status message

dataobjectoptional

Single MCP server tool (returned by GET /tools/mcp-server/tool/{mcp_server_tool_id}).

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

mcp_server_toolsobject[]optional

List of MCP server tools. Returned by /tools/mcp-server/{mcp_server_id}/list.

idstringoptional

ID of the MCP server tool

namestringoptional

Name of the MCP server tool

descriptionstringoptional

Description of the MCP server tool

input_schemaobjectoptional

Input schema of the MCP server tool

mcp_server_idstringoptional

ID of the MCP server that the tool belongs to

mcp_server_urlstringoptional

URL of the MCP server

DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/tools/mcp-server/tool/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Successfully deleted MCP server tool",
  "data": {
    "id": "123",
    "name": "My MCP Server Tool",
    "description": "My MCP Server Tool is a tool that provides MCP services",
    "input_schema": {
      "name": "string",
      "age": "number"
    },
    "mcp_server_id": "123",
    "mcp_server_url": "https://mcp.example.com"
  },
  "mcp_server_tools": [
    {
      "id": {},
      "name": {},
      "description": {},
      "input_schema": {},
      "mcp_server_id": {},
      "mcp_server_url": {}
    }
  ]
}

Create FHIR provider

POST/fhir-provider

Creates a new FHIR provider configuration with authentication credentials.

Note: The "sandbox" provider type cannot be created via this API - it is managed internally.

RequiresBearerauthentication

Body parameters

namestringrequired

Display name for the FHIR provider

descriptionstringoptional

Optional description of the FHIR provider

providerstringrequired

Type of FHIR server provider.

The "sandbox" provider type is managed internally and cannot be created via API. It is used on shared instances.

aidboxathenahealthcanvascernerelationepicgoogle_healthcarehapimeditechmedplumphenostoresandbox
base_urlstring (uri)required

Base URL of the FHIR server

authoneOfrequired
Returns  

FHIR provider created successfully

Response fields

successbooleanoptional
messagestringoptional
dataoneOfoptional

Provider details. Sandbox providers return FhirProviderSandboxInfo.

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/fhir-provider' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Epic Sandbox",
  "description": "Epic sandbox environment for testing",
  "provider": "epic",
  "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
  "auth": {
    "auth_method": "jwt",
    "client_id": "your-client-id",
    "credential_expiry": "2024-12-31T23:59:59Z",
    "role": "read",
    "scopes": "system/Patient.read system/Observation.read"
  }
}'
201 CreatedResponse
{
  "success": true,
  "message": "FHIR provider created successfully",
  "data": {
    "id": "1716d214-de93-43a4-aa6b-a878d864e2ad",
    "name": "Epic Sandbox",
    "description": "Epic sandbox environment for testing",
    "provider": "epic",
    "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
    "client_id": "your-client-id",
    "auth_configs": {},
    "last_updated": "2024-01-15T10:30:00Z"
  }
}

Get FHIR provider by ID

GET/fhir-provider/{fhir_provider_id}

Retrieves a specific FHIR provider configuration by its ID.

Sandbox providers return FhirProviderSandboxInfo. On shared instances, only sandbox providers can be accessed.

RequiresBearerauthentication

Path parameters

fhir_provider_idstringrequired

ID of the FHIR provider to retrieve

Returns  

FHIR provider retrieved successfully

Response fields

successbooleanoptional
messagestringoptional
dataoneOfoptional

Provider details. Sandbox providers return FhirProviderSandboxInfo.

GETRequest
curl 'https://experiment.app.pheno.ml/fhir-provider/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "FHIR provider retrieved successfully",
  "data": {
    "id": "1716d214-de93-43a4-aa6b-a878d864e2ad",
    "name": "Epic Sandbox",
    "description": "Epic sandbox environment for testing",
    "provider": "epic",
    "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
    "client_id": "your-client-id",
    "auth_configs": {},
    "last_updated": "2024-01-15T10:30:00Z"
  }
}

Delete FHIR provider

DELETE/fhir-provider/{fhir_provider_id}

Deletes a FHIR provider.

Note: Sandbox providers cannot be deleted.

RequiresBearerauthentication

Path parameters

fhir_provider_idstringrequired

ID of the FHIR provider to delete

Returns  

FHIR provider deleted successfully

Response fields

successbooleanoptional
messagestringoptional
DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/fhir-provider/abc-123-def-456' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Fhir provider deleted successfully"
}

Execute FHIR bundle operation

POST/fhir-provider/{fhir_provider_id}/fhir

Executes a FHIR Bundle transaction or batch operation on the specified provider. This allows multiple FHIR resources to be processed in a single request.

The request body should contain a valid FHIR Bundle resource with transaction or batch type.

The request is proxied to the configured FHIR server with appropriate authentication headers.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Path parameters

fhir_provider_idstringrequired

The ID of the FHIR provider to use. Can be either:

  • A UUID representing the provider ID
  • A provider name (legacy support - will just use the most recently updated provider with this name)
Returns  

Bundle executed successfully

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/fhir' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "request": {
        "method": "POST",
        "url": "Patient"
      },
      "resource": {
        "resourceType": "Patient",
        "name": [
          {
            "family": "Doe",
            "given": [
              "John"
            ]
          }
        ]
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "Observation"
      },
      "resource": {
        "resourceType": "Observation",
        "status": "final",
        "subject": {
          "reference": "Patient/123"
        }
      }
    }
  ]
}'
200 OKResponse
{}

Read or search FHIR resources

GET/fhir-provider/{fhir_provider_id}/fhir/{fhir_path}

Retrieves FHIR resources from the specified provider. Supports both individual resource retrieval (e.g. Patient/123 via the path) and search operations.

FHIR search parameters are passed through to the upstream server verbatim as native query-string parameters; this proxy does not model, validate, or transform them. Append standard FHIR search parameters directly to the request URL. Supported parameters include:

  • Resource-specific search parameters (e.g. name for Patient, status for Observation)
  • Common search parameters (_id, _lastUpdated, _tag, _profile, _security, _text, _content, _filter)
  • Result parameters (_count, _offset, _sort, _include, _revinclude, _summary, _elements)
  • Search prefixes for dates, numbers, and quantities (eq, ne, gt, ge, lt, le, sa, eb, ap)

Examples:

  • Patient?name=John%20Doe&_count=10&_sort=family
  • Observation?patient=Patient/123&date=ge2023-01-01&category=vital-signs&_sort=-date

When using a generated SDK, supply these via the client's request-level query-parameter option (the SDK escape hatch) rather than a typed argument.

The request is proxied to the configured FHIR server with appropriate authentication headers.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Path parameters

fhir_provider_idstringrequired

The ID of the FHIR provider to use. Can be either:

  • A UUID representing the provider ID
  • A provider name (legacy support - will just use the most recently updated provider with this name)
fhir_pathstringrequired

The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples:

  • "Patient" (for resource type operations)
  • "Patient/123" (for specific resource operations)
  • "Patient/123/_history" (for history operations)
Returns  

Successfully retrieved FHIR resource(s)

Response fields

resourceTypestringoptional
totalintegeroptional
entryarray<object>optional
resourceobjectoptional
resourceTypestringoptional
idstringoptional
namearray<object>optional
familystringoptional
givenarray<string>optional
GETRequest
curl 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/fhir/%7Bfhir_path%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "resourceType": "Bundle",
  "total": 2,
  "entry": [
    {
      "resource": {
        "resourceType": "Patient",
        "id": "123",
        "name": [
          {
            "family": "Doe",
            "given": [
              "John"
            ]
          }
        ]
      }
    }
  ]
}

Upsert FHIR resource

PUT/fhir-provider/{fhir_provider_id}/fhir/{fhir_path}

Creates or updates a FHIR resource on the specified provider. If the resource exists, it will be updated; otherwise, it will be created.

The request is proxied to the configured FHIR server with appropriate authentication headers.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Path parameters

fhir_provider_idstringrequired

The ID of the FHIR provider to use. Can be either:

  • A UUID representing the provider ID
  • A provider name (legacy support - will just use the most recently updated provider with this name)
fhir_pathstringrequired

The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples:

  • "Patient" (for resource type operations)
  • "Patient/123" (for specific resource operations)
  • "Patient/123/_history" (for history operations)
Returns  

Resource upserted successfully

PUTRequest
curl -X PUT 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/fhir/%7Bfhir_path%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "resourceType": "Patient",
  "id": "123"
}'
200 OKResponse
{}

Create FHIR resource

POST/fhir-provider/{fhir_provider_id}/fhir/{fhir_path}

Creates a new FHIR resource on the specified provider. The request body should contain a valid FHIR resource in JSON format.

The request is proxied to the configured FHIR server with appropriate authentication headers.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Path parameters

fhir_provider_idstringrequired

The ID of the FHIR provider to use. Can be either:

  • A UUID representing the provider ID
  • A provider name (legacy support - will just use the most recently updated provider with this name)
fhir_pathstringrequired

The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples:

  • "Patient" (for resource type operations)
  • "Patient/123" (for specific resource operations)
  • "Patient/123/_history" (for history operations)
Returns  

Resource created successfully

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/fhir/%7Bfhir_path%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "resourceType": "Patient"
}'
200 OKResponse
{}

Delete FHIR resource

DELETE/fhir-provider/{fhir_provider_id}/fhir/{fhir_path}

Deletes a FHIR resource from the specified provider.

The request is proxied to the configured FHIR server with appropriate authentication headers.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Path parameters

fhir_provider_idstringrequired

The ID of the FHIR provider to use. Can be either:

  • A UUID representing the provider ID
  • A provider name (legacy support - will just use the most recently updated provider with this name)
fhir_pathstringrequired

The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples:

  • "Patient" (for resource type operations)
  • "Patient/123" (for specific resource operations)
  • "Patient/123/_history" (for history operations)
Returns  

Resource deleted successfully

DELETERequest
curl -X DELETE 'https://experiment.app.pheno.ml/fhir-provider/550e8400-e29b-41d4-a716-446655440000/fhir/%7Bfhir_path%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{}

Patch FHIR resource

PATCH/fhir-provider/{fhir_provider_id}/fhir/{fhir_path}

Partially updates a FHIR resource on the specified provider.

Two body formats are supported, selected by request content type:

  • application/json-patch+json — an array of JSON Patch operations as defined in RFC 6902. Each operation specifies:
    • op: The operation type (add, remove, replace, move, copy, test)
    • path: JSON Pointer to the target location in the resource
    • value: The value to use (required for add, replace, and test operations)
  • application/fhir+json — a partial FHIR resource for merge-patch semantics.

Note: This proxy currently forwards the request body to the upstream FHIR server with Content-Type: application/fhir+json regardless of the declared request content type. JSON Patch (RFC 6902) therefore only succeeds against upstream servers that accept patch arrays under application/fhir+json; servers that strictly enforce patch media types may reject or misinterpret it. Support for either format ultimately depends on the upstream FHIR server.

The request is proxied to the configured FHIR server with appropriate authentication headers.

RequiresBearerauthentication

Header parameters

X-Phenoml-On-Behalf-Ofstringoptional

Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity. Must be in the format: Patient/{uuid} or Practitioner/{uuid}

X-Phenoml-Fhir-Providerstringoptional

Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}. Multiple FHIR provider integrations can be provided as comma-separated values.

Path parameters

fhir_provider_idstringrequired

The ID of the FHIR provider to use. Can be either:

  • A UUID representing the provider ID
  • A provider name (legacy support - will just use the most recently updated provider with this name)
fhir_pathstringrequired

The FHIR resource path to operate on. This follows FHIR RESTful API conventions. Examples:

  • "Patient" (for resource type operations)
  • "Patient/123" (for specific resource operations)
  • "Patient/123/_history" (for history operations)
Returns  

Resource patched successfully

PATCHRequest
curl -X PATCH 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/fhir/%7Bfhir_path%7D' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '[
  {
    "op": "replace",
    "path": "/name/0/family",
    "value": "NewFamilyName"
  }
]'
200 OKResponse
{}

List FHIR providers

GET/fhir-provider/list

Retrieves a list of all active FHIR providers for the authenticated user.

On shared instances, only sandbox providers are returned. Sandbox providers return FhirProviderSandboxInfo.

RequiresBearerauthentication
Returns  

FHIR providers retrieved successfully

Response fields

successbooleanoptional
messagestringoptional
fhir_providersoneOf[]optional

List of FHIR providers. Sandbox providers return FhirProviderSandboxInfo, other providers return FhirProviderTemplate.

GETRequest
curl 'https://experiment.app.pheno.ml/fhir-provider/list' \
  -H 'Authorization: Bearer YOUR_API_KEY'
200 OKResponse
{
  "success": true,
  "message": "Fhir providers retrieved successfully",
  "fhir_providers": [
    {
      "id": "1716d214-de93-43a4-aa6b-a878d864e2ad",
      "name": "Epic Sandbox",
      "description": "Epic sandbox environment for testing",
      "provider": "epic",
      "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
      "client_id": "your-client-id",
      "auth_configs": {},
      "last_updated": "2024-01-15T10:30:00Z"
    }
  ]
}

Add authentication configuration

PATCH/fhir-provider/{fhir_provider_id}/add-auth-config

Adds a new authentication configuration to an existing FHIR provider. This enables key rotation and multiple auth configurations per provider.

Note: Sandbox providers cannot be modified.

RequiresBearerauthentication

Path parameters

fhir_provider_idstringrequired

ID of the FHIR provider to add auth config to

Returns  

Auth configuration added successfully

Response fields

successbooleanoptional
messagestringoptional
dataoneOfoptional

Provider details. Sandbox providers return FhirProviderSandboxInfo.

PATCHRequest
curl -X PATCH 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/add-auth-config' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "auth_method": "jwt",
  "client_id": "your-client-id",
  "credential_expiry": "2024-12-31T23:59:59Z",
  "role": "read",
  "scopes": "system/Patient.read system/Observation.read"
}'
200 OKResponse
{
  "success": true,
  "message": "Auth configuration added successfully",
  "data": {
    "id": "1716d214-de93-43a4-aa6b-a878d864e2ad",
    "name": "Epic Sandbox",
    "description": "Epic sandbox environment for testing",
    "provider": "epic",
    "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
    "client_id": "your-client-id",
    "auth_configs": {},
    "last_updated": "2024-01-15T10:30:00Z"
  }
}

Remove authentication configuration

PATCH/fhir-provider/{fhir_provider_id}/remove-auth-config

Removes an authentication configuration from a FHIR provider. Cannot remove the currently active auth configuration.

Note: Sandbox providers cannot be modified.

RequiresBearerauthentication

Path parameters

fhir_provider_idstringrequired

ID of the FHIR provider

Body parameters

auth_config_idstringrequired

ID of the auth configuration to remove

Returns  

Auth configuration removed successfully

Response fields

successbooleanoptional
messagestringoptional
dataobjectoptional

Full FHIR provider configuration returned for non-sandbox providers. auth_configs and last_updated are always populated, which is how list responses distinguish this shape from FhirProviderSandboxInfo.

idstringrequired

Unique identifier for the FHIR provider

namestringrequired

Display name for the FHIR provider

descriptionstringoptional

Optional description of the FHIR provider

providerstringrequired

Type of FHIR server provider.

The "sandbox" provider type is managed internally and cannot be created via API. It is used on shared instances.

aidboxathenahealthcanvascernerelationepicgoogle_healthcarehapimeditechmedplumphenostoresandbox
base_urlstring (uri)optional

Base URL of the FHIR server

client_idstringoptional

OAuth client ID. Deprecated: use client_id on FhirProviderAuthConfig instead. Retained for backward compatibility with existing providers.

auth_configsobjectrequired

Map of authentication configurations (key is auth_config_id)

last_updatedstring (date-time)required

Timestamp when the provider was last updated

PATCHRequest
curl -X PATCH 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/remove-auth-config' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "auth_config_id": "auth-config-123"
}'
200 OKResponse
{
  "success": true,
  "message": "Auth configuration removed successfully",
  "data": {
    "id": "1716d214-de93-43a4-aa6b-a878d864e2ad",
    "name": "Epic Sandbox",
    "description": "Epic sandbox environment for testing",
    "provider": "epic",
    "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
    "client_id": "your-client-id",
    "auth_configs": {},
    "last_updated": "2024-01-15T10:30:00Z"
  }
}

Set active authentication configuration

PATCH/fhir-provider/{fhir_provider_id}/set-active-auth-config

Sets which authentication configuration should be active for a FHIR provider. Only one auth config can be active at a time.

If the specified auth config is already active, the request succeeds without making any changes and returns a message indicating the config is already active.

Note: Sandbox providers cannot be modified.

RequiresBearerauthentication

Path parameters

fhir_provider_idstringrequired

ID of the FHIR provider

Body parameters

auth_config_idstringrequired

ID of the auth configuration to set as active

Returns  

Active auth configuration set successfully, or the config was already active. Check the message field to determine which case occurred.

Response fields

successbooleanoptional
messagestringoptional
dataoneOfoptional

Provider details. Sandbox providers return FhirProviderSandboxInfo.

PATCHRequest
curl -X PATCH 'https://experiment.app.pheno.ml/fhir-provider/%7Bfhir_provider_id%7D/set-active-auth-config' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "auth_config_id": "auth-config-123"
}'
200 OKResponse
{
  "success": true,
  "message": "Active auth configuration set successfully, or the config was already active.\nCheck the message field to determine which case occurred.",
  "data": {
    "id": "1716d214-de93-43a4-aa6b-a878d864e2ad",
    "name": "Epic Sandbox",
    "description": "Epic sandbox environment for testing",
    "provider": "epic",
    "base_url": "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4",
    "client_id": "your-client-id",
    "auth_configs": {},
    "last_updated": "2024-01-15T10:30:00Z"
  }
}

Voice

Transcribe audio recordings into text with speech-to-text. Pair the transcript with Lang2FHIR to turn spoken clinical notes into structured FHIR resources.

Transcribe audio

POST/transcribe

Transcribes an uploaded audio recording and returns the transcript. Send the raw audio bytes as the request body; the audio format is detected automatically (WAV, FLAC, MP3, OGG/WebM Opus).

Supports up to ~5 minutes of audio per request. This limit is on audio duration regardless of file size or format, so a compressed recording within the size limit can still be rejected for being too long. Pair the transcript with a downstream text step (e.g. POST /lang2fhir/create) to turn it into a FHIR resource.

RequiresBearerauthentication

Query parameters

languagestring[]optional

BCP-47 language tag, repeatable for up to 4 candidate languages. Defaults to en-US.

Returns  

Transcription succeeded.

Response fields

transcriptstringrequired

The full transcript of the audio.

POSTRequest
curl -X POST 'https://experiment.app.pheno.ml/transcribe' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '"example"'
200 OKResponse
{
  "transcript": "example"
}