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

# Add lines to purchase order

> Appends lines to a DRAFT purchase order. Returns the created lines with HTTP 201.

<ParamField header="x-api-key" type="string" required>
  API key with `inventory:write` scope.
</ParamField>

<ParamField path="vendorId" type="string" required>
  Vendor UUID.
</ParamField>

<ParamField path="orderId" type="string" required>
  Purchase order UUID. Must be in `DRAFT` status.
</ParamField>

<ParamField query="action" type="string" required>
  Must be `add-lines`.
</ParamField>

<ParamField body="lines" type="object[]" required>
  Lines to add (at least 1). Same fields as on order creation: `item_id` / `external_item_id` / `supplier_sku`, `qty`, `qty_base`, `base_unit_id`, `item_unit_id`, `unit_code`, `unit_label`, `unit_cost`, `tax_amount`, `delivery_amount`, `total_amount`, `markup_amount`, `notes`, `metadata`. `qty_base` is optional when the line references `unit_code` or `item_unit_id` — the server derives it from the unit's `factor_to_base`.
</ParamField>

<ParamField body="enforce_supplier_catalog" type="boolean">
  When `true`, every line item must exist in the supplier's catalog.
</ParamField>

<ResponseField name="lines" type="object[]">
  The created lines with full detail.
</ResponseField>

<RequestExample>
  ```json theme={null}
  {
    "lines": [
      {
        "item_id": "itm_rice_01...",
        "qty": 20,
        "qty_base": 20000,
        "base_unit_id": "unit_g_01...",
        "unit_to_base_factor": 1000,
        "unit_label": "kg",
        "unit_cost": 1.2
      }
    ]
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "lines": [
      {
        "id": "pol_02...",
        "purchase_order_id": "po_01j5k...",
        "item_id": "itm_rice_01...",
        "qty": 20,
        "qty_base": 20000,
        "base_unit_id": "unit_g_01...",
        "unit_label": "kg",
        "unit_cost": 1.2
      }
    ]
  }
  ```

  ```json 422 theme={null}
  {
    "error": {
      "kind": "purchase_order_not_draft",
      "message": "Lines can only be added to DRAFT orders"
    }
  }
  ```
</ResponseExample>
