How to order Quest labs through an API

To order Quest Diagnostics tests from your own software you need three things: a programmatic connection to Quest, a licensed ordering provider with an active NPI, and a HIPAA-compliant place for the patient record. LabLink provides the connection through one REST API, on an existing Quest interface, and keeps patient data under your organization.

With LabLink you create a patient, pick tests from Quest's catalog, place an order with the ordering provider, diagnosis codes and bill type, follow its status, and receive signed webhooks when Quest has the requisition and when results are posted. This guide walks through each step and what to plan for.

Before you write code

Most teams discover at least one of these late. None of them block building in sandbox; all of them are needed before your first real order.

The order lifecycle

Every call goes to https://lablink.caregap.io/api/sandbox/v1 in sandbox or https://lablink.caregap.io/api/v1 in production, with Authorization: Bearer <key> and a key for the same environment.

  1. Create or look up the patient with POST /patients. Only first name, last name and date of birth are required. Send your own externalId: a retried create returns conflict with the existing id, and GET /patients?externalId= finds the patient later. Without one, every call creates a new patient; LabLink never merges on similar names. Patient records are billed per patient per year, so duplicates cost money as well as causing confusion.
  2. Pick tests from the catalog. GET /tests?search= matches part of a name and code= part of a Quest order code. Then call GET /tests/{id} for each test: some have ask-at-order-entry questions, and an order is not created until every one is answered. Ask them while the order is being put together, not afterwards.
  3. Place the order with POST /orders: patient, address (the first time you order for a patient), up to 25 tests, the provider's NPI, up to 10 ICD-10-CM diagnosis codes, bill type and answers, in one request. LabLink completes the questionnaire and provider authorization. If it cannot, the order is still created and comes back with actionRequired.
  4. Finish anything outstanding. actionRequired.type is answer_questions, choose_provider or choose_billing, finished with POST /orders/{id}/answers, /provider or /billing. Its message says which.
  5. Follow the status. GET /orders/{id} returns created, then awaiting_collection once Quest has the requisition, then results_final; or cancelled. Branch on status and actionRequired, not on step names.
  6. Receive webhooks. order.awaiting_collection says the patient can be drawn: download the requisition PDF they bring with GET /orders/{id}/requisition. order.results_final carries Quest's results message, HL7 v2 parsed to JSON, and the PDF report. See retrieving Quest results programmatically.

Request bodies, every field and the errors for each call are in the API docs and the OpenAPI spec, and the first sandbox order walkthrough has copy-paste requests for each step. The playground in the LabLink console sends every call in sandbox.

Sandbox and production

Sandbox Production
Base URL/api/sandbox/v1/api/v1
Keys and webhooksSandbox key; sandbox webhook endpoint and signing secretSeparate production key, endpoint and secret
DataSynthetic only. Nothing reaches a real lab or patient, and nothing is billedReal patients and real orders, under your BAA
Ordering providerA test provider, Test Physician, NPI 1336176510Your own licensed provider
OrderingOpenOpen once your account is live

Choosing a bill type per order

Bill type Quest bills Your app needs
Client BillYour subaccount, at Quest's program ratesYour own checkout, if you charge the patient
Patient CashThe patient, at Quest's standard patient pricingNothing extra for billing
Patient InsuranceThe patient's health planInsurance details and ICD-10 codes

You can use different bill types for different orders. LabLink's own platform fees apply to every order whatever the bill type; see LabLink pricing.

Implementation notes

What LabLink does not do

Questions

Do I have to handle HL7 to order Quest labs through LabLink?

No. LabLink runs a Quest interface with HL7 and file handling already in place. Your application calls a REST API and receives results as HL7 v2 parsed to JSON.

Can I test without real patients?

Yes. The LabLink sandbox has its own base URL, keys and webhooks, and a test ordering provider. Use synthetic patient data only: nothing in sandbox reaches a real lab or patient, and nothing is billed.

Can I place real orders through the API today?

Yes, once your account is live. Going live takes a signed Platform Agreement and BAA, onboarding paid, a verified ordering provider and your Quest subaccount, which typically takes several business days to set up, so it is worth starting early. Build and test in sandbox in the meantime.

What format are results in?

The order.results_final webhook carries Quest's results message, HL7 v2 ORU^R01 parsed to JSON without interpretation, and the PDF report as base64.

Next step

Read the API reference, then create an account and place your first sandbox order. If you would rather have the CareGap build team build your app or portal on LabLink, talk to us.

Related: Ordering Quest tests without your own Quest account · Retrieving Quest results programmatically