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

# Replace Work Order Line Items

PUT https://api.coperniq.io/v1/work-orders/{work_order_id}/line-items
Content-Type: application/json

Replaces all line items on a work order. Internally updates or creates the underlying quote linked to the task.

Supported **only** for service work orders on an **account** (parent project type `ACCOUNT`). Requests for other work orders receive `400`.

Provide **either** `sections` **or** `lineItems` (not both), using the same shapes as quote line items.


Reference: https://docs.coperniq.io/api-reference/line-items/replace-work-order-line-items

## Authentication

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

## Request

### Path parameters

- `work_order_id` (integer, required) — Work order identifier

### Body (application/json)

This endpoint expects a WorkOrderLineItemsPutRequest.

- `sections` (list of QuoteSection, optional)
- `lineItems` (list of QuoteLineItemCreate, optional)

## Response

### 200

Updated line items (dollar amounts)

- `list of WorkOrderLineItem`

## Errors

### 400 Bad Request Error

Invalid request

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

### 401 Unauthorized Error

Authentication failed

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

### 404 Not Found Error

Resource not found

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

### 500 Internal Server Error

Internal server error

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

## Types

### QuoteSection

- `lineItems` (list of QuoteLineItemCreate, required) — Line items within this section (at least one required)
- `id` (integer, optional) — Section identifier
- `name` (string, optional, nullable) — Section name (1–500 chars)

### QuoteLineItemCreate

- `catalogItemId` (integer, required) — Catalog item identifier
- `quantity` (integer, required) — Quantity
- `unitCost` (double, required) — Cost per unit (dollars, cent precision)
- `unitPrice` (double, required) — Price per unit (dollars, must be positive with cent precision)
- `id` (integer, optional) — Existing line item ID (omit for new items)
- `description` (string, optional, nullable) — Line item description

### WorkOrderLineItem

- `id` (integer, optional)
- `quantity` (integer, optional)
- `description` (string, optional, nullable)
- `unitCost` (double, optional)
- `totalCost` (double, optional, nullable)
- `unitPrice` (double, optional)
- `totalPrice` (double, optional, nullable)
- `sectionName` (string, optional, nullable)
- `catalogItem` (WorkOrderLineItemCatalogItem, optional, nullable)

### WorkOrderLineItemCatalogItem

- `id` (integer, optional)
- `name` (string, optional)
- `sku` (string, optional, nullable)
- `type` (string, optional, nullable)
- `manufacturer` (string, optional, nullable)

## Examples

**Request**

```json
{}
```

**Response**

```json
[
  {
    "id": 1,
    "quantity": 1,
    "description": "string",
    "unitCost": 1.1,
    "totalCost": 1.1,
    "unitPrice": 1.1,
    "totalPrice": 1.1,
    "sectionName": "string",
    "catalogItem": {
      "id": 1,
      "name": "string",
      "sku": "string",
      "type": "string",
      "manufacturer": "string"
    }
  }
]
```

**SDK Code**

```python
import requests

url = "https://api.coperniq.io/v1/work-orders/1/line-items"

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

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

print(response.json())
```

```javascript
const url = 'https://api.coperniq.io/v1/work-orders/1/line-items';
const options = {
  method: 'PUT',
  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/work-orders/1/line-items"

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

	req, _ := http.NewRequest("PUT", 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/work-orders/1/line-items")

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

request = Net::HTTP::Put.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.put("https://api.coperniq.io/v1/work-orders/1/line-items")
  .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('PUT', 'https://api.coperniq.io/v1/work-orders/1/line-items', [
  '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/work-orders/1/line-items");
var request = new RestRequest(Method.PUT);
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/work-orders/1/line-items")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```