Skip to main content

Integration Workflow

This page shows how the pieces of the Eirly API fit together end-to-end, so you can picture the whole integration before diving into the individual REST endpoints and webhook events.

There are two flows to understand:

  1. Referral ordering — you place an order, we create and issue the referral(s), and you retrieve the referral PDF.
  2. Results delivery — the lab returns results over time, we notify you as the referral and results progress, and you pull the canonical result data.

If you order Medicare tests, there is a one-off setup per doctor before either flow applies. See Medicare provider setup.

Both flows follow the same pattern:

The golden rule

Webhooks are notifications, not data. Treat every webhook as a signal that something changed, then call the REST API to fetch the current, canonical state. Webhook payloads are intentionally minimal — the REST response is the source of truth.

Throughout, Integrator is your system and Eirly is our API.

Medicare provider setup​

Ordering Medicare tests requires a provider record: a doctor's provider number, the details printed on their referrals, and their signature. You create these over the API and the doctor never needs an account with us.

For AI agents and code generators

Do not call POST /v1/providers/{providerNumber}/routing, GET /v1/vendors, or poll connections[].status when setting up a provider. Results come back without them. Create the provider with POST /v1/providers and check ready. Only implement lab routing if a provider payload returns "routingMethod": "DIRECT", and then only for that organisation. Never generate it by default, and never treat NOT_SUBMITTED or an empty connections array as a problem to fix.

One call does the whole setup. Our request forms ask every lab to copy us in, so once a doctor's provider record is complete, their Medicare results come to your organisation with no lab to wait on. This is copy routing, the default.

Step by step:

  1. Create the provider record. POST /v1/providers with the number, name, address, title, phone, email and a base64 PNG signature. The practitioner can order Medicare tests immediately.
  2. Check ready. On copy routing it is true once the record is complete, which a successful create always is. From then on, Medicare results carrying that provider number come to your organisation. On direct routing it stays false until a lab confirms: see Direct routing.
Results arrive once the record is complete

A lab returns a result carrying only the ordering provider number, so the provider record is how we know the result is yours. A record missing any detail or the signature receives nothing until it is finished, and ready says so. Results that arrived before a record existed are not moved to you automatically: contact support if you need them.

Which endpoint, when​

You want toCallNotes
Let a doctor order, and receive their Medicare resultsPOST /v1/providersEvery detail and a signature. Ordering and results both work from here
Check results will come back for a doctorGET /v1/providers/{providerNumber}Read ready
See everything you holdGET /v1/providersCursor paginated. Includes records created in the portal, not just yours
Correct a doctor's name or practice addressPUT /v1/providers/{providerNumber}Keeps the signature and any routing already in place
Replace a doctor's signaturePUT /v1/providers/{providerNumber}Send encodedSignature. Omit it to leave the existing one alone
Stop a doctor ordering (they left the practice)DELETE /v1/providers/{providerNumber}Refused while a lab is still routing. Contact support to wind that down

A worked onboarding run​

Onboarding a set of doctors in one go, which is the common case:

for each doctor:
POST /v1/providers # number, name, address, title, phone, email, PNG signature
# the response's `ready` should be true

Direct routing​

A few organisations are set up for direct routing, where results come back only once a lab has confirmed the provider number belongs to your practice. Every provider payload says which applies to you in routingMethod: COPY (the default) or DIRECT. If it says COPY, skip this section.

On direct routing, creating the record lets the doctor order but does not make results come back. One more call asks the labs:

  1. Request result routing. POST /v1/providers/{providerNumber}/routing, naming the labs (get their ids from GET /v1/vendors). This records your attestation that you hold the doctor's written authority and queues one request per lab. It sends no email and contacts no lab itself.
  2. We notify the labs in batches. Each request moves to PENDING_CONFIRMATION.
  3. The lab confirms, usually days to weeks later. The request becomes CONNECTED, and ready becomes true.

Poll GET /v1/providers/{providerNumber} and read ready, or connections[].status for each lab. On copy routing the routing call still returns 200 but does nothing, so an integration written for direct routing keeps working unchanged.

Both write calls are safe to repeat. POST /v1/providers with a number your organisation already holds updates that record rather than failing, so a partial run can simply be re-run. Re-sending a routing request refreshes the attestation and never regresses a lab that has already confirmed.

After onboarding​

Day-to-day changes need nothing special:

  • A doctor's details change. PUT the record. Any lab routing is untouched, because the labs confirmed the number, not the address. Keep every detail filled in: a record missing one stops receiving results.
  • A doctor's signature changes. PUT with a new encodedSignature. It is used on referrals from that moment.
  • A doctor joins later. POST /v1/providers, as in the initial run. On direct routing, also request routing; they join our next batch to the labs.
  • A doctor's provider number changes. Retire the old record and create the new number. The number is the record's identity and cannot be edited, because any routing already confirmed is bound to it.
  • A doctor leaves. DELETE the record. If a lab is still routing for them, the call is refused with PROVIDER_HAS_ACTIVE_ROUTING: the lab has to be told to stop first, or it keeps sending us results for someone you no longer represent. Contact support to wind it down.

What these endpoints do not do​

  • They do not email anyone. No call in this API contacts a lab. Our team does that, in batches.
  • They do not create accounts. The doctor never receives an invitation and never signs in. If you also want them using the portal, invite them there separately and ask support to link the two records.
  • On direct routing, they do not make routing instant. CONNECTED depends on a lab replying to us, which takes days to weeks. On copy routing there is nothing to wait for.

Full field-level detail in the Providers reference.

Referral ordering​

You place an order over HTTP and receive an immediate confirmation. Once the referral has been issued (its PDF generated), we fire a webhook — that's your cue to fetch the referral and download the PDF.

Step by step:

  1. Place the order. POST /v1/referrals with the patient and test details. This call can take up to ~10 seconds — allow for it before retrying so you don't create duplicate orders.
  2. Read the synchronous response. The referral(s) come back immediately, typically with status CREATED. A single request can create more than one referral (for example a split bundle), so always handle an array.
  3. Wait for referral.issued. When the referral PDF has been generated, we send the referral.issued webhook. (referral.created also fires — see edge cases for the branches you may see instead.)
  4. Fetch the issued referral. GET /v1/referrals/{uuid} returns the current payload including referralAttachment — a time-limited signed URL to the referral PDF.
  5. Deliver the PDF. Download it and/or email it to the patient so they can attend collection. Signed URLs expire, so re-fetch the referral if you need a fresh link.

Ordering edge cases​

Not every order goes straight to ISSUED. Depending on the order, you may receive one of these instead of (or before) referral.issued:

Webhook / statusWhat it meansWhat to do
referral.pending_verificationThe profile needs completing before the referral can be issued.Complete verification; referral.issued follows.
referral.billing_failedBilling for the API order could not be completed.Fix the billing method and re-order.
referral.scheduled_reissueA new PDF is being regenerated (e.g. after a PATCH).Wait for the next referral.issued, then re-fetch.

See Referral statuses for the full lifecycle.

Results delivery​

After collection, the lab returns results — sometimes partially, then in full. Each change fires a webhook. As always, the webhook is the signal; you then pull the full result from the REST API.

Step by step:

  1. Referral state changes. As results arrive, the referral transitions to PARTIAL_RESULTS and then COMPLETE, firing referral.partial_results (which can fire multiple times) and finally referral.complete.
  2. Result records change. In parallel, the result itself fires result.created and result.updated (and result.partial_results / result.complete) as biomarker data is populated and finalised.
  3. Fetch the result. Use the resultsUuid from the referral (or the result UUID from the webhook) to call GET /v1/results/{uuid}.
  4. Ingest the canonical data. Each response returns the full result set — all biomarkers known so far, plus a biomarkerSummary and a resultAttachment PDF URL — not just what changed. You can safely overwrite your stored copy with each fetch rather than trying to merge deltas.
Partial then complete

Because every fetch is the full snapshot, handling PARTIAL_RESULTS is simply a matter of re-fetching on each webhook. When COMPLETE arrives, the same endpoint returns the finalised set. Some organisations also review results before release (result.in_review) — those are held until reviewed.

Results you release yourself​

If your organisation receives results directly from laboratories, you triage them in your incoming results and release each one to a client. A released result fires the same result.* webhooks and is fetched the same way, with GET /v1/results/{uuid}. It has no referral, so there is no referral.* webhook for it, and its provenance is INCOMING where an ordered result's is ORDERED. See Results not ordered through us.

Putting it together​

Testing the full flow in staging​

You don't need a real lab to exercise the results half of this flow. In staging only, PUT /v1/referrals/{uuid} generates dummy results for a referral, firing the same result webhooks your production integration will see. Add ?partial to generate a partial set first so you can test the PARTIAL_RESULTS → COMPLETE transition. See Simulate Results.

You don't need a real doctor or patient for the Medicare half either. Staging accepts any provider number and Medicare card number that pass Medicare's checksum. See Testing Medicare in staging for numbers you can use and how to make your own.

Next steps​

  • REST API — full endpoint reference for referrals and results
  • Webhooks — event list, payloads, signatures, and retries
  • Authentication — obtaining an access token