curl --request POST \
--url https://api.openloophealth.com/v0.1/laboratories \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"patient_id": "<string>",
"lab_test_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"passthrough": "<string>",
"activate_by": "<string>"
}
'import requests
url = "https://api.openloophealth.com/v0.1/laboratories"
payload = {
"patient_id": "<string>",
"lab_test_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"passthrough": "<string>",
"activate_by": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
patient_id: '<string>',
lab_test_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
passthrough: '<string>',
activate_by: '<string>'
})
};
fetch('https://api.openloophealth.com/v0.1/laboratories', 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.openloophealth.com/v0.1/laboratories",
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([
'patient_id' => '<string>',
'lab_test_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'passthrough' => '<string>',
'activate_by' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.openloophealth.com/v0.1/laboratories"
payload := strings.NewReader("{\n \"patient_id\": \"<string>\",\n \"lab_test_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"passthrough\": \"<string>\",\n \"activate_by\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.openloophealth.com/v0.1/laboratories")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"patient_id\": \"<string>\",\n \"lab_test_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"passthrough\": \"<string>\",\n \"activate_by\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openloophealth.com/v0.1/laboratories")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"patient_id\": \"<string>\",\n \"lab_test_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"passthrough\": \"<string>\",\n \"activate_by\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"order_id": "<string>",
"junction_user_id": "<string>",
"patient_id": "<string>",
"lab_test_ids": [
"<string>"
],
"status": "<string>",
"collection_method": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}Create lab requisition
Order one or more lab tests for a patient in your organization. The order is placed with OpenLoop’s lab network using the patient’s name, date of birth, gender, phone, email and home address as stored on the patient record, so those fields must be present before you call this endpoint (see the 400 response).
Send the lab_test_ids your OLH implementation contact confirms for your organization. Leave collection_method out unless a test supports more than one method. A 201 means the order was accepted by the lab network; there is no read-back of the order or its results on this API yet.
Retries and duplicates. Send an Idempotency-Key on every call. A repeat under the same key for the same patient returns the original order instead of placing a second one. Without a key, a repeat request for the same patient and the same set of lab_test_ids as an earlier order that was also placed without a key returns that order, so a genuinely new order for the same tests needs a new key. A request with a key never matches one without: retrying a keyed request without its key places a second order. Either match is held for two years.
Lab ordering is available by arrangement: your credentials are granted laboratories:write when it is set up for your organization.
Permissions: laboratories:write
curl --request POST \
--url https://api.openloophealth.com/v0.1/laboratories \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"patient_id": "<string>",
"lab_test_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"passthrough": "<string>",
"activate_by": "<string>"
}
'import requests
url = "https://api.openloophealth.com/v0.1/laboratories"
payload = {
"patient_id": "<string>",
"lab_test_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"passthrough": "<string>",
"activate_by": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
patient_id: '<string>',
lab_test_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
passthrough: '<string>',
activate_by: '<string>'
})
};
fetch('https://api.openloophealth.com/v0.1/laboratories', 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.openloophealth.com/v0.1/laboratories",
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([
'patient_id' => '<string>',
'lab_test_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'passthrough' => '<string>',
'activate_by' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.openloophealth.com/v0.1/laboratories"
payload := strings.NewReader("{\n \"patient_id\": \"<string>\",\n \"lab_test_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"passthrough\": \"<string>\",\n \"activate_by\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.openloophealth.com/v0.1/laboratories")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"patient_id\": \"<string>\",\n \"lab_test_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"passthrough\": \"<string>\",\n \"activate_by\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openloophealth.com/v0.1/laboratories")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"patient_id\": \"<string>\",\n \"lab_test_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"passthrough\": \"<string>\",\n \"activate_by\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"order_id": "<string>",
"junction_user_id": "<string>",
"patient_id": "<string>",
"lab_test_ids": [
"<string>"
],
"status": "<string>",
"collection_method": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"error_code": "<string>"
},
"request_id": "<string>"
}Authorizations
Headers
Recommended. A UUID your client generates once per intended order and reuses on every retry of that order. A retry under the same key for the same patient returns the original order with 201 instead of placing a second one. A key is not compared against the request body, so never reuse a key for a different order, and never drop the key on a retry: a request without a key does not match one sent with a key. Leading and trailing whitespace is trimmed. A key that is then empty, or longer than 200 characters, is not rejected: it is ignored, and the request is handled as if no key were sent.
Body
1 to 20 lab test ids (UUIDs), provided by your OLH implementation contact for each environment. Always send this field: when it is omitted the order falls back to an environment default that is not specific to your organization, and where no default is configured the request returns 400.
1 - 20 elementsHow the sample is collected: walk_in_test (patient visits a lab draw site), testkit (kit mailed to the patient), at_home_phlebotomy, or on_site_collection. Optional: null, an empty string, or omitting the field all mean no collection method is sent with the order. Leave it out for tests that have a single collection method: the lab network uses that method, and rejects the order if one is sent. Send it only for tests that support more than one method; if the lab network rejects it, the request returns 400 with the order-rejected message.
testkit, walk_in_test, at_home_phlebotomy, on_site_collection, null 
