> 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.

# Update Material Order

PATCH https://api.coperniq.io/v1/material-orders/{material_order_id}
Content-Type: application/json

Update a material order. Supports partial updates.

- `lineItems` and `sections` replace all lines. Send a line's `id` to keep it; a kept line keeps its scope link even if `scopeLineItemId` is omitted.
- `vendorId` can only change while the material order is a `DRAFT`. Changing the vendor reprices the lines.
- `status` accepts `DRAFT`, `SENT`, `SCHEDULED`, `PARTIALLY_FULFILLED`, `FULFILLED` and `CANCELED`, following the allowed transitions. `PENDING_SUPPLIER` is read-only: it is returned as-is when a connected supplier has queued the order, and can't be set.
- Set `isActive` to `false` to archive the material order, or `true` to unarchive it.
- Delivery and supplier details are read-only.

**Orders accepted by a supplier are locked.** Once a connected supplier has accepted a material order, it can't be edited, and the request returns `400` with the reason.


Reference: https://docs.coperniq.io/api-reference/material-orders/update-material-order

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Request

### Path parameters

- `material_order_id` (integer, required) — Material order identifier

### Body (application/json)

This endpoint expects a MaterialOrderUpdate.

- `vendorId` (integer, optional) — Change the vendor. Only while the material order is a `DRAFT`.
- `title` (string, optional) — Title
- `description` (string, optional, nullable) — Material order description
- `internalMemo` (string, optional, nullable) — Internal-only memo, never shown to customers or on the PDF or portal. Rich text (HTML, like the app's editor stores). Send null or "" to clear it.
- `dueDate` (string, optional, nullable) — Due date (ISO 8601 datetime string). Send null to clear it.
- `status` (enum, optional) — Material order status. `PENDING_SUPPLIER` is read-only and can't be set.
  - Allowed values: `DRAFT`, `SENT`, `SCHEDULED`, `PARTIALLY_FULFILLED`, `FULFILLED`, `CANCELED`
- `isActive` (boolean, optional) — Set to `false` to archive the material order, or `true` to unarchive it. Applied independently of any other fields present in the same request.
- `lineItems` (list of MaterialOrderLineItemCreate, optional) — Replaces all lines. May be combined with `sections` (ungrouped items).
- `sections` (list of MaterialOrderSection, optional) — Replaces all lines, grouped into named sections. May be combined with `lineItems` (ungrouped items).

## Response

### 200

Material order updated successfully

- `id` (integer, required) — Material order identifier
- `status` (enum, required) — Material order status. `PENDING_SUPPLIER` is set only by a connected supplier (the order is queued and waiting for the supplier's order number). It is returned as-is and can't be set through the API.
  - Allowed values: `DRAFT`, `PENDING_SUPPLIER`, `SENT`, `SCHEDULED`, `PARTIALLY_FULFILLED`, `FULFILLED`, `CANCELED`
- `amount` (double, required) — Total amount in dollars
- `createdAt` (string, required) — Creation timestamp
- `updatedAt` (string, required) — Last update timestamp
- `materialOrderNumber` (integer, optional, nullable) — Unique material order number
- `title` (string, optional) — Material order title
- `description` (string, optional, nullable) — Material order description
- `internalMemo` (string, optional, nullable) — Internal-only memo, never shown to customers or on the PDF or portal. Rich text (HTML, like the app's editor stores). On update, send null or "" to clear it; responses return null when empty.
- `vendor` (MaterialOrderVendor, optional, nullable) — The vendor the materials are ordered from
- `record` (MaterialOrderRecord, optional, nullable) — The project the material order belongs to
- `issueDate` (string, optional, nullable) — Issue date
- `dueDate` (string, optional, nullable) — Due date
- `subtotal` (double, optional) — Subtotal in dollars
- `isArchived` (boolean, optional) — Whether the material order is archived
- `deliveryMethod` (enum, optional) — How the material is delivered. Read-only: set in the app when the vendor is a connected supplier. Each supplier uses its own subset of these values. - ABC Supply: `OUR_TRUCK_ROOF`, `OUR_TRUCK_GROUND`, `OUR_TRUCK_WINDOW`, `COMMON_CARRIER`, `CUSTOMER_PICKUP`, `EXPRESS_PICKUP`, `THIRD_PARTY_CARRIER` - SRS Distribution: `GROUND_DROP`, `ROOF_LOAD`, `ROOF_EDGE`, `WILL_CALL` (a branch pickup, which carries a `pickupTime` instead of a delivery window)
  - Allowed values: `OUR_TRUCK_ROOF`, `OUR_TRUCK_GROUND`, `OUR_TRUCK_WINDOW`, `COMMON_CARRIER`, `CUSTOMER_PICKUP`, `EXPRESS_PICKUP`, `THIRD_PARTY_CARRIER`, `GROUND_DROP`, `ROOF_LOAD`, `ROOF_EDGE`, `WILL_CALL`
- `deliveryWindow` (enum, optional) — Named delivery window. The branch sets the actual times. Pickups carry a `pickupTime` instead.
  - Allowed values: `ANYTIME`, `FIRST_STOP`, `MORNING`, `AFTERNOON`
- `pickupTime` (string, optional, nullable) — Pickup time (`HH:mm`, 24-hour) for an SRS `WILL_CALL` order
- `deliveryRequestedFor` (string, optional, nullable) — Requested delivery date (`YYYY-MM-DD`)
- `deliveryInstructions` (string, optional, nullable) — Delivery instructions (up to 255 characters)
- `supplierBranchNumber` (string, optional, nullable) — Supplier branch the material is ordered from
- `supplierJobAccountNumber` (integer, optional, nullable) — Supplier job account the order bills to
- `pointOfContactUser` (MaterialOrderPointOfContactUser, optional, nullable) — Team member the supplier should contact. `null` means the client.
- `deliveryContactUser` (MaterialOrderDeliveryContactUser, optional, nullable) — Team member who receives the delivery. `null` means the point of contact.
- `lineItems` (list of MaterialOrderLineItem, optional)

## Errors

### 400 Bad Request Error

Invalid request

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `NOT_FOUND`
- `field` (string, optional) — Field that caused the validation error (if applicable)

### 401 Unauthorized Error

Authentication failed

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `NOT_FOUND`

### 404 Not Found Error

Resource not found

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `NOT_FOUND`

## Types

### MaterialOrderLineItemCreate

- `catalogItemId` (integer, required) — Catalog item identifier
- `quantity` (integer, required) — Quantity
- `unitCost` (double, required) — Cost per unit. The material order's total is the sum of `unitCost` × `quantity`.
- `unitPrice` (double, required) — Selling price per unit. It doesn't affect the material order's total; it is copied to the project scope when an unlinked line is added there.
- `id` (integer, optional) — Existing line item ID, to keep that line on update. Omit for new lines.
- `description` (string, optional, nullable) — Line item description
- `scopeLineItemId` (integer, optional) — ID of a project scope line item (from `GET /projects/{project_id}/line-items`) to link this line to, so billing tracks against the project's scope. * A scope line can be linked at most once per document. * A linked `QUANTITY` line must keep the scope line's `unitCost` and `unitPrice`. * With Financials 2.0, a linked `QUANTITY` line that exceeds what is left on the scope line creates and approves a change order that increases the scope, instead of failing. * 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 linking. * On update, a kept line (sent with its `id`) keeps its scope link even if this field is omitted.

### MaterialOrderSection

A named section grouping one or more material order line items.

- `lineItems` (list of MaterialOrderLineItemCreate, required) — Line items within this section (at least one required)
- `id` (integer, optional) — Existing section ID (omit for new sections)
- `name` (string, optional, nullable) — Section name (1–500 chars). Omit or pass null for an unnamed section.

### MaterialOrderVendor

The vendor the materials are ordered from

- `id` (integer, optional)
- `name` (string, optional, nullable)

### MaterialOrderRecord

The project the material order belongs to

- `id` (integer, optional)
- `title` (string, optional)
- `type` (string, optional)

### MaterialOrderPointOfContactUser

Team member the supplier should contact. `null` means the client.

- `id` (integer, optional)

### MaterialOrderDeliveryContactUser

Team member who receives the delivery. `null` means the point of contact.

- `id` (integer, optional)

### MaterialOrderLineItem

- `id` (integer, required) — Line item identifier
- `quantity` (integer, required) — Quantity
- `unitCost` (double, required) — Cost per unit. The material order's total is the sum of `unitCost` × `quantity`.
- `unitPrice` (double, required) — Selling price per unit, as carried on the project scope. It doesn't affect the material order's total.
- `totalCost` (double, optional) — Total cost
- `totalPrice` (double, optional) — Total price
- `description` (string, optional, nullable) — Line item description
- `sectionName` (string, optional, nullable) — Name of the section the line belongs to (`null` when ungrouped)
- `catalogItem` (MaterialOrderLineItemCatalogItem, optional, nullable)
- `scopeLineItemId` (integer, optional, nullable) — ID of the project scope line item (from `GET /projects/{project_id}/line-items`) this line is linked to. `null` when unlinked.

### MaterialOrderLineItemCatalogItem

- `id` (integer, optional)
- `name` (string, optional)
- `manufacturer` (string, optional, nullable)
- `sku` (string, optional, nullable)
- `type` (enum, optional)
  - Allowed values: `PRODUCT`, `SERVICE`

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": 1,
  "status": "DRAFT",
  "amount": 1.1,
  "createdAt": "2024-01-15T09:30:00Z",
  "updatedAt": "2024-01-15T09:30:00Z",
  "materialOrderNumber": 1,
  "title": "string",
  "description": "string",
  "internalMemo": "string",
  "vendor": {
    "id": 1,
    "name": "string"
  },
  "record": {
    "id": 1,
    "title": "string",
    "type": "Project"
  },
  "issueDate": "2024-01-15T09:30:00Z",
  "dueDate": "2024-01-15T09:30:00Z",
  "subtotal": 1.1,
  "isArchived": true,
  "deliveryMethod": "OUR_TRUCK_ROOF",
  "deliveryWindow": "ANYTIME",
  "pickupTime": "08:30",
  "deliveryRequestedFor": "2023-01-15",
  "deliveryInstructions": "string",
  "supplierBranchNumber": "string",
  "supplierJobAccountNumber": 1,
  "pointOfContactUser": {
    "id": 1
  },
  "deliveryContactUser": {
    "id": 1
  },
  "lineItems": [
    {
      "id": 1,
      "quantity": 1,
      "unitCost": 1.1,
      "unitPrice": 1.1,
      "totalCost": 1.1,
      "totalPrice": 1.1,
      "description": "string",
      "sectionName": "string",
      "catalogItem": {
        "id": 1,
        "name": "string",
        "manufacturer": "string",
        "sku": "string",
        "type": "PRODUCT"
      },
      "scopeLineItemId": 1
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.coperniq.io/v1/material-orders/1"

payload = {}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.coperniq.io/v1/material-orders/1';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.coperniq.io/v1/material-orders/1"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.coperniq.io/v1/material-orders/1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.coperniq.io/v1/material-orders/1")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.coperniq.io/v1/material-orders/1', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.coperniq.io/v1/material-orders/1");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.coperniq.io/v1/material-orders/1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```