Skip to main content
POST
/
medical
/
v1
/
network
/
query
Start Network Query
curl --request POST \
  --url https://api.sandbox.metriport.com/medical/v1/network/query \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "sources": [
    "<string>"
  ],
  "metadata": {}
}
'
import { MetriportMedicalApi } from "@metriport/api-sdk";

const metriport = new MetriportMedicalApi("YOUR_API_KEY");

const status = await metriport.startNetworkQuery({
patientId: "00000000-0000-0000-00000-000000000000",
sources: ["hie", "pharmacy", "laboratory"],
metadata: {
youCan: "putAny",
stringKeyValue: "pairsHere",
},
});

This endpoint returns a 2XX status code even when one or more data sources fail to start or encounter errors. Source-level failures are reported in the errors array of the response body rather than as HTTP 4XX or 5XX status codes. Always check the errors key in the response to detect partial failures.
This endpoint triggers a network query, an asynchronous query against various kinds of health data sources including HIEs, pharmacies, and laboratories. As data from each source is processed and merged into a patient’s record, also known as their ‘Consolidated Data’, we emit network-query.* webhook events. Every time a source completes, a webhook request will be sent to your configured URL containing a link to download the patient’s consolidated data. Webhook message types - see the webhooks page for more details:
  • network-query.hie: HIE data has been merged into the consolidated bundle;
  • network-query.pharmacy: Pharmacy data has been merged into the consolidated bundle;
  • network-query.lab: Laboratory data has been merged into the consolidated bundle.

Query Params

patientId
string
required
The ID of the Patient for which to query health data.

Body

sources
string[]
required
An array of data sources to query. Must contain at least one value. Possible values: hie, pharmacy, lab.
metadata
object
Custom metadata to include with the request. This will be returned in webhook payloads.
Example Request Body:
{
  "sources": ["hie", "pharmacy", "lab"],
  "metadata": {
    "youCan": "putAny",
    "stringKeyValue": "pairsHere"
  }
}

Response

requestId
string
required
The unique identifier for this network query request. Use this to track the query status and correlate webhooks.
startedAt
string
required
ISO 8601 timestamp of when the network query request was initially made.
status
string
required
The overall status of the network query. Can be one of: - in-progress - at least one source is still being queried
  • completed - all sources have completed successfully - partial - some sources completed, some failed - failed
  • all sources failed
sources
Source[]
required
Array of status objects for each data source being queried. A source type may appear multiple times if it was retried after a failure.
errors
SourceError[]
Array of errors for data sources that could not be queried. Only present when one or more sources fail to start.
Example Response Body (all sources started):
{
  "requestId": "00000000-0000-0000-0000-000000000000",
  "startedAt": "2024-12-30T10:00:00.000Z",
  "status": "in-progress",
  "sources": [
    {
      "type": "hie",
      "status": "in-progress",
      "startedAt": "2024-12-30T10:00:00.500Z"
    },
    {
      "type": "pharmacy",
      "status": "in-progress",
      "startedAt": "2024-12-30T10:00:00.750Z"
    },
    {
      "type": "lab",
      "status": "in-progress",
      "startedAt": "2024-12-30T10:00:01.000Z"
    }
  ]
}
Example Response Body (with source errors):
{
  "requestId": "00000000-0000-0000-0000-000000000000",
  "startedAt": "2024-12-30T10:00:00.000Z",
  "status": "in-progress",
  "sources": [
    {
      "type": "hie",
      "status": "in-progress",
      "startedAt": "2024-12-30T10:00:00.500Z"
    }
  ],
  "errors": [
    {
      "source": "pharmacy",
      "httpStatus": 400,
      "message": "Access to pharmacy data source is not enabled for this account",
      "timestamp": "2024-12-30T10:00:00.600Z"
    },
    {
      "source": "lab",
      "httpStatus": 429,
      "message": "Rate limit exceeded for laboratory data source",
      "timestamp": "2024-12-30T10:00:00.800Z"
    }
  ]
}
import { MetriportMedicalApi } from "@metriport/api-sdk";

const metriport = new MetriportMedicalApi("YOUR_API_KEY");

const status = await metriport.startNetworkQuery({
patientId: "00000000-0000-0000-00000-000000000000",
sources: ["hie", "pharmacy", "laboratory"],
metadata: {
youCan: "putAny",
stringKeyValue: "pairsHere",
},
});

Rate Limits

See limits and throttling