> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.coperniq.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.coperniq.io/_mcp/server.

## Material orders, and scope links on invoices and bills

### New: material orders

Create, read, update and delete material orders (the purchase orders you place with a vendor for a project's materials).

* `GET /material-orders` and `GET /projects/{project_id}/material-orders`: list with `page`, `page_size`, `order_by`, `updated_after` and `updated_before`. Archived material orders are left out unless you pass `include_archived=true`.
* `GET /material-orders/{material_order_id}`
* `POST /material-orders`: send `recordId` (a project), `vendorId` and `lineItems` and/or `sections`. `title` defaults to "Material Order".
* `PATCH /material-orders/{material_order_id}`: partial update. `lineItems` and `sections` replace all lines, so send a line's `id` to keep it. Set `isActive` to `false` to archive it, or `true` to unarchive it.
* `DELETE /material-orders/{material_order_id}`: archives the material order, then deletes it.

```json
{
  "recordId": 789225,
  "vendorId": 3302,
  "title": "Roofing materials",
  "lineItems": [{ "catalogItemId": 10379, "quantity": 12, "unitCost": 38.5, "unitPrice": 38.5 }]
}
```

Material orders return `materialOrderNumber`, `title`, `description`, `internalMemo`, `status`, `vendor` (`{ id, name }`), `record`, `issueDate`, `dueDate`, `amount`, `subtotal`, `isArchived`, the delivery fields, `pointOfContactUser`, `deliveryContactUser`, `createdAt`, `updatedAt` and `lineItems`. Amounts are in dollars.

* **Optional fields:** `description`, `internalMemo` and `dueDate`.
* **Delivery details** (`deliveryMethod`, `deliveryWindow`, `pickupTime`, `deliveryRequestedFor`, `deliveryInstructions`, `supplierBranchNumber`, `supplierJobAccountNumber`, `pointOfContactUser` and `deliveryContactUser`) are read-only. They are set in the app when the vendor is a connected supplier (SRS Distribution or ABC Supply), and are returned when you read a material order.
* **`status`** can be set to `DRAFT`, `SENT`, `SCHEDULED`, `PARTIALLY_FULFILLED`, `FULFILLED` or `CANCELED`, following the allowed transitions. `PENDING_SUPPLIER` means a connected supplier has queued the order and is waiting for its order number. It is returned as-is and can't be set.
* `vendorId` can only change while the material order is a `DRAFT`.
* **Accepted by a supplier:** once a connected supplier has accepted a material order, it is locked. `PATCH` and `DELETE` return `400` with the reason.
* Lines take `catalogItemId`, `quantity`, `unitCost` (0 or more), `unitPrice` and `description`. A `catalogItemId` can appear at most once per request.
* **Material orders are priced by cost.** The total is `unitCost` × `quantity` across all lines. `unitPrice` is the selling price: it doesn't change the material order's total, and is copied to the project scope when a line that isn't linked to scope is added there. Removing that line from the material order later doesn't remove it from the scope.
* Material orders can only be created on projects, and can't be sent to a supplier through the API.

### New: link scope line items on invoices, bills and material orders

Lines on invoices, bills and material orders can now link a project's scope line items (the lines from `GET /projects/{project_id}/line-items`), so billing tracks against the project's scope.

```json
{
  "catalogItemId": 10379,
  "quantity": 4,
  "unitCost": 100,
  "unitPrice": 150,
  "scopeLineItemId": 9876
}
```

* `scopeLineItemId` is the `id` of a scope line. It works on `lineItems` and on `sections[].lineItems`, on create and update, for `POST` and `PATCH` on `/invoices`, `/bills` and `/material-orders`.
* On invoices and bills, `billingMode` is `QUANTITY` (the default), `PERCENTAGE` or `AMOUNT`. `PERCENTAGE` and `AMOUNT` bill part of the scope line and need a `billingValue` above 0. `billingValue` isn't accepted with `QUANTITY`.
* Material orders always order by quantity, so their lines don't take `billingMode` or `billingValue`.
* Lines now return `scopeLineItemId` (`null` when unlinked). Invoice and bill lines also return `billingMode` and `billingValue`.
* A scope line can be linked at most once per document. A request that repeats a `scopeLineItemId` returns `400`.
* A linked `QUANTITY` line must keep the scope line's `unitCost` and `unitPrice`.
* **Change orders:** when a linked `QUANTITY` line is for more than what is left on the scope line, Coperniq creates and approves a change order that increases the scope, instead of returning an error. New lines that aren't linked are added to the scope.
* Invoices on milestone-billed projects can't link scope lines.
* `PUT /projects/{project_id}/line-items` replaces scope lines, so their ids can change. Read them again before you link.
* On update, a line you keep by sending its `id` keeps its scope link, even if you leave `scopeLineItemId` out.
* Quotes can't link scope lines.