> ## Documentation Index
> Fetch the complete documentation index at: https://openloop.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# How orders are created

> The order lifecycle for partners: payment and clinical review create the order; its status reaches you as prescription webhook events, not as a read.

> [!WARNING]
>
> There is **no partner order endpoint**: partners neither create orders nor read them. Orders are
> created by the platform as a result of payment and clinical review, and every status change is
> delivered to you as a **prescription webhook event** (configured per customer; give OpenLoop the
> HTTPS endpoint that should receive them).

## The lifecycle

1. **Payment starts it.** The patient pays via `POST /v0.1/checkouts/sessions` (or a subscription
   created with `POST /v0.1/subscriptions`). Payment state is readable on the billing side:
   `GET /v0.1/subscriptions?email=` and the subscription's invoices.
2. **A clinician reviews and prescribes.** OpenLoop's clinical workflow reviews the intake and, if
   appropriate, prescribes. Dispensing and shipping follow internally.
3. **You receive the events.** `prescription.created`, `prescription.ordered`, `prescription.shipped`
   and `prescription.cancelled` arrive as signed webhooks as they happen. Each event carries the
   order's current status (`data.status`), the timestamps of every stage so far (`data.timestamps.*`),
   and — once it ships — the carrier and tracking reference (`data.carrier`, `data.tracking_ref`).
   Payment state is **not** on these events; read it from the billing side (step 1).

## Reading status from the events

Keep the latest event per prescription `data.resource_id` and render from it: `data.status` for where
the order is (`created` → `ordered` → `shipped`, or `cancelled`), and `data.carrier` /
`data.tracking_ref` for the parcel once it ships. Order events by the envelope `occurredAt` and dedupe
on the envelope `id` (also the `webhook-id` header). Key the event to your patient on
`data.emr_patient_id`, the patient's `/v0.1` id, the `id` that `GET /v0.1/patients/{id}` takes; it is
set whenever the id is known and omitted otherwise, never `null`. `data.patient_ref` is an opaque
reference, not guaranteed to be the `/v0.1` patient id: when the event has no `emr_patient_id`, how it
is correlated for patients created through the Partner API is agreed when your endpoint is registered.
Field-by-field reference:
[Prescription events](https://openloop.mintlify.site/cookbook/prescription-events.md).


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