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

# How do I create a patient, prescription, and order in one API call?

> POST /api/v1/prescriptions/electronic_prescriptions/composite with any combination of patient, prescriber, electronic_prescription, and order objects. It is all-or-nothing: if one entity fails, nothing is created.

Blend's composite endpoint creates a patient, a prescriber, an electronic prescription, and an order in a single request. Post any combination of the four top-level objects — `patient`, `prescriber`, `electronic_prescription`, `order` — and each one follows the same required fields as its individual endpoint. Patients and prescribers can be **referenced** instead of created, so a returning patient doesn't need their profile re-sent.

The whole request is atomic. If any single entity fails validation, the entire request fails and nothing is created.

## A new patient, new prescription, and order in one request

```bash theme={null}
curl -X POST https://api.byblend.com/api/v1/prescriptions/electronic_prescriptions/composite \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "patient": {
      "first_name": "Willard",
      "last_name": "Donnelly",
      "email": "wdonnelly@example.com",
      "phone": "6417383445",
      "date_of_birth": "1990-01-01",
      "external_id": "clinic-pt-4471",
      "address": {
        "address_1": "140 Lindgren Street",
        "city": "Boston",
        "state": "MA",
        "zip_code": "02108"
      }
    },
    "prescriber": {
      "npi": "1234567890"
    },
    "electronic_prescription": {
      "medication": {
        "product_code": "HC-RAPA31",
        "drug_name": "Rapamycin",
        "quantity": 30,
        "units": "C48480",
        "days_supply": 30,
        "refills": 4,
        "sig": "Take one capsule by mouth once weekly",
        "written_at": "2026-08-20T00:00:00"
      }
    },
    "order": {
      "products": {
        "prescription": [
          { "product_code": "HC-RAPA31", "quantity": 1 }
        ]
      }
    }
  }'
```

The response returns `{ id, created }` for each entity plus a `summary` reporting `entities_created` and `entities_referenced` — so you can tell at a glance whether the patient was newly created or matched to an existing record.

## Referencing instead of creating

For a returning patient, drop the full profile and pass a reference:

```json theme={null}
"patient": { "external_id": "clinic-pt-4471" }
```

Prescribers can be referenced by `id` or `npi`. See [how Blend matches entities](/overview#how-blend-matches-patients-orders-prescribers-prescriptions-and-products) for the full matching rules.

<Warning>
  **All-or-nothing.** A malformed address on the patient means the prescription and order are not created either. Validate each object against its individual endpoint's requirements before combining them.
</Warning>

<Note>
  **Order merging still applies.** If the patient already has an open order, the order in your composite request merges into it. Pass `force_new=true` as a querystring argument to prevent that — see [Order Merging](/overview#order-merging).
</Note>

## When to use it

Reach for composite when your system already holds everything at once — a checkout flow, an intake form, an EMR pushing a completed visit. Use the individual endpoints when entities arrive at different times, which is the more common pattern for businesses whose prescriptions come through Surescripts.

<CardGroup cols={2}>
  <Card title="Composite creation" icon="layer-group" href="/api-reference/composite-creation/single-request-creation-of-a-prescription-and-order-and-patientprescriber">
    POST /prescriptions/electronic\_prescriptions/composite
  </Card>

  <Card title="Create an order" icon="prescription-bottle" href="/api-reference/orders/create-an-order">
    POST /orders
  </Card>

  <Card title="Create a patient" icon="user" href="/api-reference/patients/create-a-patient">
    POST /patients
  </Card>

  <Card title="Create an electronic prescription" icon="prescription" href="/api-reference/electronic-prescriptions/create-a-new-electronic-prescription">
    POST /prescriptions/electronic\_prescriptions
  </Card>
</CardGroup>
