> ## 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 record why a compound was needed?

> Attach a reasons array to each prescription line when creating an order. Pull the available reasons from GET /api/v1/reasons, or create your own with POST /api/v1/reasons.

Compounding reasons record the clinical justification for a compounded preparation — why this patient needed a compound rather than a commercially available product. Attach them per prescription line at order creation using the `reasons` array.

Blend ships a set of global reasons organized as parent categories with subcategories. You can add your own, and nest them under a global parent or one of your own.

## See what's available

```bash theme={null}
curl https://api.byblend.com/api/v1/reasons \
  -H "Authorization: Bearer {access_token}"
```

Reasons come back as parent categories each containing `subcategories` — for example "Adherence or Compliance" containing "Behavioral Issues", alongside standalone categories such as "Palatability". Filter with `type=global` or `type=customer` to separate Blend's list from your own.

## Attach them to an order line

```json theme={null}
{
  "patient": { "external_id": "clinic-pt-4471" },
  "products": {
    "prescription": [
      {
        "product_code": "HC-RAPA31",
        "quantity": 1,
        "reasons": [
          { "id": "0227d1e5-ba9a-42b5-8fe2-38882aa65708" }
        ]
      }
    ]
  }
}
```

Reasons attach to the **line item**, not the order. An order containing three compounded products can carry a different justification for each.

## Create your own

```bash theme={null}
curl -X POST https://api.byblend.com/api/v1/reasons \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Physical location",
    "description": "Patient cannot access a physical pharmacy due to natural disaster or similar event.",
    "parent_id": "0227d1e5-ba9a-42b5-8fe2-38882aa65708"
  }'
```

Both `name` and `description` are required. `parent_id` is optional — supply it to nest the reason under a global category or one of your own, or omit it to create a top-level category.

<Note>
  Give the `description` real substance. It's the text that explains the clinical rationale to anyone reviewing the record later, and a vague description makes the reason much less useful than no reason at all.
</Note>

<Tip>
  Prefer an existing global reason over creating a near-duplicate. A short, shared vocabulary reports far better across your whole order history than dozens of one-off custom reasons that mean the same thing.
</Tip>

Custom reasons can be updated later with `PUT /api/v1/reasons/{reason_id}`.

<CardGroup cols={2}>
  <Card title="Get compounding reasons" icon="list" href="/api-reference/orders/get-compounding-reasons">
    Global and custom, with subcategories
  </Card>

  <Card title="Create a custom compounding reason" icon="plus" href="/api-reference/orders/create-a-custom-compounding-reason">
    POST /reasons
  </Card>

  <Card title="Update a custom compounding reason" icon="pen" href="/api-reference/orders/update-a-custom-compounding-reason">
    PUT /reasons/{'{'}reason\_id{'}'}
  </Card>

  <Card title="Create an order" icon="prescription-bottle" href="/api-reference/orders/create-an-order">
    `reasons` on each prescription line
  </Card>
</CardGroup>
