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": {
"hie": {
"enabled": true
},
"pharmacy": {
"enabled": true,
"realtime": true
},
"lab": {
"enabled": true
}
},
"proofedIdentityId": "<string>",
"metadata": {}
}
'import requests
url = "https://api.sandbox.metriport.com/medical/v1/network/query"
payload = {
"sources": {
"hie": { "enabled": True },
"pharmacy": {
"enabled": True,
"realtime": True
},
"lab": { "enabled": True }
},
"proofedIdentityId": "<string>",
"metadata": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sources: {
hie: {enabled: true},
pharmacy: {enabled: true, realtime: true},
lab: {enabled: true}
},
proofedIdentityId: '<string>',
metadata: {}
})
};
fetch('https://api.sandbox.metriport.com/medical/v1/network/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.metriport.com/medical/v1/network/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sources' => [
'hie' => [
'enabled' => true
],
'pharmacy' => [
'enabled' => true,
'realtime' => true
],
'lab' => [
'enabled' => true
]
],
'proofedIdentityId' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.metriport.com/medical/v1/network/query"
payload := strings.NewReader("{\n \"sources\": {\n \"hie\": {\n \"enabled\": true\n },\n \"pharmacy\": {\n \"enabled\": true,\n \"realtime\": true\n },\n \"lab\": {\n \"enabled\": true\n }\n },\n \"proofedIdentityId\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.metriport.com/medical/v1/network/query")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sources\": {\n \"hie\": {\n \"enabled\": true\n },\n \"pharmacy\": {\n \"enabled\": true,\n \"realtime\": true\n },\n \"lab\": {\n \"enabled\": true\n }\n },\n \"proofedIdentityId\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.metriport.com/medical/v1/network/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sources\": {\n \"hie\": {\n \"enabled\": true\n },\n \"pharmacy\": {\n \"enabled\": true,\n \"realtime\": true\n },\n \"lab\": {\n \"enabled\": true\n }\n },\n \"proofedIdentityId\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_bodyimport { MetriportMedicalApi } from "@metriport/api-sdk";
const metriport = new MetriportMedicalApi("YOUR_API_KEY");
const status = await metriport.startNetworkQuery({
patientId: "00000000-0000-0000-0000-000000000000",
sources: {
hie: { enabled: true },
pharmacy: { enabled: true, realtime: true },
lab: { enabled: true },
},
metadata: {
youCan: "putAny",
stringKeyValue: "pairsHere",
},
});
Network
Start Network Query
Triggers a network query for the specified patient across all available health data networks.
Listen to this page1 min 33 sec
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": {
"hie": {
"enabled": true
},
"pharmacy": {
"enabled": true,
"realtime": true
},
"lab": {
"enabled": true
}
},
"proofedIdentityId": "<string>",
"metadata": {}
}
'import requests
url = "https://api.sandbox.metriport.com/medical/v1/network/query"
payload = {
"sources": {
"hie": { "enabled": True },
"pharmacy": {
"enabled": True,
"realtime": True
},
"lab": { "enabled": True }
},
"proofedIdentityId": "<string>",
"metadata": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sources: {
hie: {enabled: true},
pharmacy: {enabled: true, realtime: true},
lab: {enabled: true}
},
proofedIdentityId: '<string>',
metadata: {}
})
};
fetch('https://api.sandbox.metriport.com/medical/v1/network/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.metriport.com/medical/v1/network/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sources' => [
'hie' => [
'enabled' => true
],
'pharmacy' => [
'enabled' => true,
'realtime' => true
],
'lab' => [
'enabled' => true
]
],
'proofedIdentityId' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.metriport.com/medical/v1/network/query"
payload := strings.NewReader("{\n \"sources\": {\n \"hie\": {\n \"enabled\": true\n },\n \"pharmacy\": {\n \"enabled\": true,\n \"realtime\": true\n },\n \"lab\": {\n \"enabled\": true\n }\n },\n \"proofedIdentityId\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.metriport.com/medical/v1/network/query")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sources\": {\n \"hie\": {\n \"enabled\": true\n },\n \"pharmacy\": {\n \"enabled\": true,\n \"realtime\": true\n },\n \"lab\": {\n \"enabled\": true\n }\n },\n \"proofedIdentityId\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.metriport.com/medical/v1/network/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sources\": {\n \"hie\": {\n \"enabled\": true\n },\n \"pharmacy\": {\n \"enabled\": true,\n \"realtime\": true\n },\n \"lab\": {\n \"enabled\": true\n }\n },\n \"proofedIdentityId\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_bodyimport { MetriportMedicalApi } from "@metriport/api-sdk";
const metriport = new MetriportMedicalApi("YOUR_API_KEY");
const status = await metriport.startNetworkQuery({
patientId: "00000000-0000-0000-0000-000000000000",
sources: {
hie: { enabled: true },
pharmacy: { enabled: true, realtime: true },
lab: { enabled: true },
},
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.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;network-query.hie.first-data-ready: the first batch of HIE data is available to reingest, ahead of the HIE query completing.
purposeOfUse: "ias" when applicable.
Headers
Required when the
purposeOfUse query parameter is ias.
An active AAL2 session ID for the patient’s verified
identity. See Create AAL2
Challenge.Query Params
The purpose of the request. One of
treatment or ias.
Defaults to treatment. Use ias when the patient is
retrieving their own records through Individual Access
Services - see Individual Access
(IAS).Body
Data sources to query. At least one source must be enabled.
Show Source configuration
Show Source configuration
Legacy format: The API also accepts an array of source names (e.g.,
sources: ["hie", "pharmacy", "lab"]) for backward compatibility,
but the object format above is recommended as it supports per-source options.Required when the
purposeOfUse query parameter is ias. The verified identity returned on the
ias.identity.verified webhook.Custom metadata to include with the request. This will be returned in webhook payloads.
Show Metadata properties
Show Metadata properties
Holds a record of up to 50 custom string key-value pairs. Key names can be up to 40 characters long and values up to 500 characters long.
{
"sources": {
"hie": { "enabled": true },
"pharmacy": { "enabled": true, "realtime": true },
"lab": { "enabled": true }
},
"metadata": {
"youCan": "putAny",
"stringKeyValue": "pairsHere"
}
}
Response
The unique identifier for this network query request. Use
this to track the query status and correlate webhooks.
The overall status of the network query. Can be one of:
processing- at least one source is still being queriedcompleted- all sources have completed successfullypartial- some sources completed, some failedfailed- all sources failed
Array of status objects for each data source being
queried. A source type may appear multiple times if it was
retried after a failure.
Array of errors for data sources that could not be
queried. Only present when one or more sources fail to
start.
Show SourceError properties
Show SourceError properties
The HTTP status code representing the error. Common
values: -
400 - Bad Request (access to this data
source is not enabled for this account) - 429 - Too
Many Requests (rate limit exceeded for this data
source){
"requestId": "00000000-0000-0000-0000-000000000000",
"startedAt": "2024-12-30T10:00:00.000Z",
"status": "processing",
"sources": [
{
"type": "hie",
"status": "processing",
"startedAt": "2024-12-30T10:00:00.500Z"
},
{
"type": "pharmacy",
"status": "processing",
"startedAt": "2024-12-30T10:00:00.750Z"
},
{
"type": "lab",
"status": "processing",
"startedAt": "2024-12-30T10:00:01.000Z"
}
]
}
{
"requestId": "00000000-0000-0000-0000-000000000000",
"startedAt": "2024-12-30T10:00:00.000Z",
"status": "processing",
"sources": [
{
"type": "hie",
"status": "processing",
"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-0000-000000000000",
sources: {
hie: { enabled: true },
pharmacy: { enabled: true, realtime: true },
lab: { enabled: true },
},
metadata: {
youCan: "putAny",
stringKeyValue: "pairsHere",
},
});

