Skip to main content

Pathology requests

A pathology request orders one or more pathology tests, such as a full blood count, for a patient. You send it with a group API key. An OnEarly doctor reviews it at no charge to you or the patient. The patient then confirms their details, picks a collection centre, pays for any tests Medicare doesn't cover and has their sample collected. The lab reports back to OnEarly. For the tests the patient pays for, you read the results as structured values or download the lab report.

Pathology requests have their own routes under /api/v1/marketplace/requests. They carry pathology tests only: imaging is ordered separately.

Not open everywhere yet

POST /api/v1/marketplace/requests answers 403 in a region where OnEarly hasn't opened pathology requests yet, and for an integration that orders without patient accounts. Your OnEarly contact can tell you when it opens for you.

Before you start​

  • Host. Call https://api.onearly.com. All paths in this section are relative to it. OnEarly sends each request to your group's home region; see One address in every region.
  • Group API key. Every endpoint takes a group API key, sent as Authorization: Bearer oe_sk_…. See Group API keys. Keep the key on your server.
  • Full-access scope. The key needs the * scope: these routes have no narrower one. Downloading the lab report also works with content:read. A key without the scope it needs gets 403 API_KEY_SCOPE_MISSING.
  • Your group orders. A key reads only the requests its own group ordered. Any other request answers 404, as an unknown id does.
  • Patients act in OnEarly. Patients confirm details, choose a centre and pay in OnEarly with their own account. This API doesn't do those steps for them.

The request lifecycle​

  1. Order. You create the request. OnEarly shares it with the patient's account, making one when the patient has none, and starts a Doctor Review. See Order and cancel.
  2. Doctor Review. An OnEarly doctor decides which tests to refer under Medicare. The verdict is eligible or not_eligible. See Doctor review.
  3. Patient steps. The patient confirms their details (details), picks a collection centre (centre), pays for anything not bulk billed (payment) and gives their sample (complete-tests). See Progress.
  4. Results. The lab reports, sometimes in parts. The results step is done once every test's results are back. See Results.

You can cancel the request until the doctor gives a verdict or the patient starts on it.

Endpoints​

MethodPathSummary
GET/api/v1/marketplace/services?category=pathologyThe pathology tests you can order. See Choose tests.
POST/api/v1/marketplace/requestsOrder a pathology request. Answers 201.
GET/api/v1/marketplace/requestsYour group's requests, newest first, with cursor pagination
DELETE/api/v1/marketplace/requests/{nodeLineageUuid}Cancel a request. Answers 204.
GET/api/v1/marketplace/requests/{nodeLineageUuid}/progressThe patient's steps, payment and whether results are released
GET/api/v1/marketplace/requests/{nodeLineageUuid}/doctor-reviewThe doctor's verdict and which tests were referred
GET/api/v1/marketplace/requests/{nodeLineageUuid}/summaryWho ordered it and whether it can still be cancelled
GET/api/v1/marketplace/requests/{nodeLineageUuid}/resultsThe lab's results as structured values
GET/api/download/file/{fileContentUuid}Download the lab report PDF

Choose tests​

Each test on a request names a row of the OnEarly service catalogue by its slug. List the pathology rows with GET /api/v1/marketplace/services?category=pathology, or read one with GET /api/v1/marketplace/services/{slug}.

FieldNotes
uuidThe catalogue row's id
slugUse it in services[].slug, such as full-blood-count
titleThe test's name, as the patient and doctor see it
descriptionA longer description
categorypathology for the tests you can order here
statusACTIVE or INACTIVE. Only ACTIVE rows can be ordered. With no status filter, only ACTIVE rows are listed.

A validation failure on these two routes returns the raw validator body { "success": false, "error": { … } }, not the error envelope below.

Polling​

Webhooks don't cover pathology requests yet. Poll GET /api/v1/marketplace/requests/{nodeLineageUuid}/progress for each open request, or page through GET /api/v1/marketplace/requests to find new results (resultsStored). Stop polling a request once its results step is done, or once you've cancelled it.

Errors​

Errors use the envelope { "error": true, "message", "code", "metadata"?, "issues"? }. The lab report download uses a different shape; see Download the lab report.

StatuscodeWhen
400VALIDATION_ERRORThe body failed validation, or a service is an ACTIVE row from another category, such as imaging. issues names the fields when the body failed validation.
400INVALID_CURSORList only: after isn't a cursor the list issued. Start again from the first page.
401See Authentication errorsNo key, or a key that isn't valid
403INSUFFICIENT_PERMISSIONSCreate only: performAs names another group, the integration orders without patient accounts, or pathology requests aren't open in the region
403API_KEY_SCOPE_MISSINGThe key doesn't have the * scope
403INVALID_ACTOR_TYPEThe nodeLineageUuid in the path isn't a UUID
404NOT_FOUNDNo such request, or one your group didn't order. On create: a service slug that is unknown or not ACTIVE, or the patient's account has been deleted.
409CONFLICTCancel: the request can no longer be cancelled, or it changed while being cancelled. See Cancel a request.
409EMAIL_ALREADY_IN_USE, PHONE_ALREADY_IN_USE, IDENTIFIER_CONFLICTCreate: OnEarly couldn't make the patient's account because the identifier is already taken
421WRONG_REGIONRetry once at the base_url in the body. This body is application/problem+json, not the envelope above. See Wrong region.
500INVITE_NOT_SENTCreate: the patient's account is in another region. See Who the patient is.

Authentication errors​

A missing or rejected key answers 401 with one of these codes.

CodeMeaning
MISSING_AUTHORIZATION_HEADERNo Authorization header was sent
API_KEY_INVALIDThe key isn't recognised
API_KEY_REVOKEDThe key has been revoked
API_KEY_EXPIREDThe key's expiry date has passed
USER_API_KEY_MCP_ONLYA personal API key was used. Personal keys don't work on pathology requests, though they can download files.

If the key couldn't be checked at all, the request is treated as having no key and answers MISSING_AUTHORIZATION_HEADER. A bearer token that doesn't start with oe_sk_ is checked as a sign-in token instead, and can answer a token code such as INVALID_JWT or EXPIRED_JWT.