> ## Documentation Index
> Fetch the complete documentation index at: https://developers.vibrant-wellness.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Orders

> From quote to placed order.

An **order** is a lab requisition for one or more products, for one patient.

## Quote first, then order — the same codes

[`POST /quote`](https://developers.vibrant-wellness.com/api-reference/pricing/quote) and [`POST /orders`](https://developers.vibrant-wellness.com/api-reference/orders/place) take
the **same list of product `code`s** (`testCodes`). Quote is a safe, no-commitment preview of the
price and eligibility; ordering re-sends the same codes. You don't thread a quote id — you send the
codes you quoted.

```mermaid theme={null}
flowchart LR
  C[List catalog] -->|codes| Q[POST /quote]
  Q -->|same codes| O[POST /orders]
  Q -->|ineligible + failures| F[Fix & re-quote]
  F --> Q
```

The lab does the rest server-side: prices the order (BestDeal), applies **New York routing**
(auto-substitutes the NY version of a test and adds the NY fee when the patient is in NY), runs the
eligibility check, and places the order only when eligible. You never send demographics, prices, kit
settings, or internal ids — your account context (customer and clinic) is applied server-side.

## Idempotency: placerId

`placerId` is your own unique id for the order — and it's **optional**. Omit it and every request
creates a **new** order. Send one and it becomes the idempotency key: the server first checks it, and
if an order with the same `placerId` already exists you get the **original** result back
(`status: duplicate`), never a second order or a double charge; if none exists, a new order is
created. Always send one in production so a network retry is safe.

## Order outcomes

The response has a single `status`:

| `status` | HTTP | Meaning |
| :- | :- | :- |
| `placed` | 201 | Eligible and placed. Returns `orderId`, `sampleId`, `accessionId`. |
| `duplicate` | 201 | This `placerId` was already used — the original result is returned. |
| `ineligible` | 422 | Eligibility rules rejected it. Nothing placed/charged. Returns `failures[]`. |
| `rejected` | 422 | Understood but not buildable (unknown codes, provider mismatch). Returns `reason`. |

## The same problem, seen from quote and order

Quote and order report the same underlying condition differently. Don't map a quote failure
straight onto an order failure:

| Condition | `POST /quote` | `POST /orders` |
| :- | :- | :- |
| Patient doesn't exist | `200`, `eligible: false`, `PatientNotFound` failure | `422`, `rejected`, `reason: patient_not_found` |
| Patient exists but is missing required demographics | `200` with the eligibility result | `422`, `ineligible`, `failures[]` |
| Unknown test code | `400` with `unknownCodes` | `422`, `rejected`, `reason: unrecognized_test_codes` |
| Ordering provider not in your clinic | not evaluated | `422`, `rejected`, `reason: provider_scope_mismatch` |

> [!NOTE]
>
> 🚧 **Working in progress** — reason codes are being unified across the two endpoints; the same
> condition currently uses different names and casing.

## Ordering restrictions

### One blood collection per order

Tests that need blood are collected one of two ways: a **blood** draw, or a **DBS** — a dried blood
spot card the patient could use at home. Only some blood tests offer a DBS version.

The lab works from a single blood sample per order, so an order uses one collection method or the
other, never both. `NEURAL_ZOOMER` (blood) and `FOOD_ZOOMER_DBS` (DBS) cannot be ordered together,
even though they are different tests.

`POST /orders` rejects mixed collection methods with `422 mixed_collection_methods`, naming the
conflicting codes in `errorCodes`.

Tests that don't need blood — saliva, urine, stool — are unaffected, and go with either.

Each product's [`sampleType`](https://developers.vibrant-wellness.com/concepts/catalog) tells you which it is.

### The same test only once

A test can appear once per order, in one version. `NEURAL_ZOOMER` and `NEURAL_ZOOMER_DBS` are the
same test. `POST /orders` rejects repeated tests with `422 duplicate_test_codes`.

### Add-on products

ApoE, Factor II-V and MTHFR each come in a blood and a saliva version. None can be ordered on its
own — each rides along with another test's sample:

| Add-on | Goes with |
| :- | :- |
| `APOE_BLOOD` · `FACTOR_II_V_BLOOD` · `MTHFR_BLOOD` | Any blood-draw test — DBS does not qualify |
| `APOE_SALIVA` · `FACTOR_II_V_SALIVA` · `MTHFR_SALIVA` | Any saliva test |
| `CELIAC_GENETICS` | `WHEAT_ZOOMER` — the blood version |

Ordering an add-on without its companion returns `422 no_orderable_items`, naming the code.

> [!NOTE]
>
> 🚧 **Working in progress** — a saliva add-on is currently accepted alongside hosts other than a
> saliva test. Build to the saliva add-on rule above: orders that break it can be placed today but
> the lab cannot fulfil them.

## Eligibility failures

An `ineligible` order returns a `failures` array — one entry per rule, each with a machine `code` and
a human `reason`. Resolve each and re-order. Current reason codes:

| `code` | Triggered when |
| :- | :- |
| `PatientNotFound` | `patientId` doesn't resolve to a patient. |
| `CustomerNotFound` | The token's customer doesn't resolve. |
| `PatientNotInClinic` | The patient doesn't belong to your token's clinic. |
| `IncompletePatientInfo` | The patient is missing date of birth, gender, or address. |
| `GeneticTestAlreadyOrdered` | A one-time genetic test was already ordered for this patient. |
| `PFSAMaleOnly` | PFSA is ordered for a patient whose gender is not male. |
| `ProzFollowupNoPreviousOrder` | A nutriProz follow-up with no prior nutriProz order. |
| `SkincareFollowupNoPreviousOrder` | A skincare follow-up with no prior skincare order. |

> [!NOTE]
>
> Treat this list as non-exhaustive — tolerate unknown future `code`s and fall back to `reason`.
> Gut Zoomer NY/standard versioning is handled automatically by New York routing, not returned as a failure.

## The accession id links order → report

A placed order returns `orderId`, `sampleId`, and **`accessionId`**. The `accessionId` (also called
the barcode) is what you pass to [`GET /report/fhir/{id}`](https://developers.vibrant-wellness.com/api-reference/reports/get) to
retrieve the result, status, and issues.

## Who pays

`chargeIndicator` selects billing: `C` = customer pays; `P`/`I`/`O` or omitted = patient pays later.
For these flows, payment instruments are handled in the Portal. See the [FAQ](https://developers.vibrant-wellness.com/faq.md).

> [!NOTE]
>
> **WIP — coming soon.** `T` adds payment by a third-party platform using its stored card.
> It requires `platformId` and a signed `X-Payment-Authorization` header in addition to the
> provider access token. See [Third-party payment](https://developers.vibrant-wellness.com/guides/third-party-payment.md) for the planned
> contract, setup, and request example.

## Tracking an order

[`GET /orders`](https://developers.vibrant-wellness.com/api-reference/orders/status) returns the order's lifecycle status, kit shipping,
lab receipt, report readiness, open exceptions, and cancellation information when available.
[Cancellation eligibility and fee preview](https://developers.vibrant-wellness.com/api-reference/orders/status.md#cancellation-preview)
remain WIP. [Webhooks](https://developers.vibrant-wellness.com/concepts/webhooks.md) notify you when an order, its kit, or its reports change;
they use their own status values and identify the order by `accessionId`. Issue changes also
trigger notifications; query issue details through the order or report APIs.

## Cancelling an order

`POST /orders/cancel` with the order's `placerId` **or** `sampleId` (exactly one — the `orderId` is
not accepted). Free **before the kit ships**, **\$25 after it ships**, and **not possible once the
lab has received the sample**. The response returns the `refundAmount` actually applied (`0` when
nothing had been charged). Cancelling an already-cancelled order returns `422` /
`not_cancellable` — treat it as already done. See [Cancel an order](https://developers.vibrant-wellness.com/api-reference/orders/cancel.md).

## When something holds up the result

A redraw, an unsigned waiver, or an unanswered questionnaire surfaces as an **issue** on the report —
and Vibrant resolves each one automatically. See [Exceptions](https://developers.vibrant-wellness.com/concepts/exceptions.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.