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

# Create and manage work orders

> Create, update, and sync AssetOps work orders through the KODE API, including lookups, comments, and attachments.

Use the work order endpoints to raise AssetOps work orders from external systems and keep them in sync. Each work order belongs to a building and references categories, priorities, and people from that building.

Each linked endpoint can switch the sample between cURL, JavaScript, Python, and PowerShell, or send the request for you.

## Before you begin

You need:

* An access token. See the [quickstart](https://docs.kodelabs.com/products/kode-api/quickstart.md).
* A `buildingId` from [List buildings](https://docs.kodelabs.com/products/kode-api/api-reference/buildings/list-buildings.md).
* AssetOps enabled for the building.

## Create a work order

**1. Look up valid values**

Work orders reference identifiers that must exist in the building. Get them from the lookup endpoints:

| Field | Lookup endpoint |
| - | - |
| `category`, `issueType` | [List categories and issue types](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/list-categories-and-issue-types.md) |
| `priority` | [List priorities](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/list-priorities.md) |
| `vendor` | [List vendors](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/list-vendors.md) |
| `team` | [List teams](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/list-teams.md) |
| `assignees` | [List assignees](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/list-assignees.md) |

Cache these values and refresh them periodically. They change less often than work orders.

**2. Create the work order**

Send the work order to [Create a work order](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/create-a-work-order.md). The API accepts `CORRECTIVE_MAINTENANCE` and `SERVICE_REQUEST` as the `workType`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request POST \
  "https://api.kodelabs.com/kodeos/api/v1/buildings/${BUILDING_ID}/assetops/work-orders" \
  --header "Authorization: Bearer ${KODE_ACCESS_TOKEN}" \
  --header "Content-Type: application/json" \
  --data '{
    "workType": "CORRECTIVE_MAINTENANCE",
    "title": "Replace AHU-01 supply fan belt",
    "description": "Belt is worn and slipping during morning startup.",
    "startDate": "2026-10-08T09:00:00",
    "dueDate": "2026-10-10T17:00:00",
    "category": { "id": "6501c2d3e4f5a6b7c8d9e0f1" },
    "issueType": { "id": "6501c2d3e4f5a6b7c8d9e0f2" },
    "priority": { "id": "6501c2d3e4f5a6b7c8d9e0c4" },
    "assignees": [{ "email": "dana.ruiz@example.com" }],
    "linkedSource": { "identifier": "FAULT-88231", "type": "EXTERNAL" }
  }'
```

Store the returned `id` and `identifier`. Set `linkedSource.identifier` to the record ID in your system so that you can match work orders later.

**3. Attach files**

Upload photos or documents with [Upload attachments](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/upload-attachments.md) as multipart form data. If your system already holds base64 content, use [Upload base64 attachments](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/upload-base64-attachments.md). Both endpoints accept up to 10 files per request.

## Update a work order

[Update a work order](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/update-a-work-order.md) replaces the editable details. Optional fields you leave out, such as `description`, `vendor`, `team`, and `assignees`, can be cleared.

To change one field safely:

1. Get the current work order with [Get a work order](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/get-a-work-order.md).
2. Change the field you need.
3. Send the complete body back.

You cannot change `workType` or `linkedSource` after creation. If you omit `priority`, the current priority stays in place.

## Sync work orders with another system

To keep an external system up to date, poll for changes instead of reading every work order:

* Call [List work orders](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/list-work-orders.md) with `updatedAtFrom` set to the time of your last sync.
* Call [List building comments](https://docs.kodelabs.com/products/kode-api/api-reference/work-orders/list-building-comments.md) with the same filter to collect new comments.
* Filter by `sourceType` to return only work orders your integration created.

Store the sync time only after you process every page, so a failure does not skip changes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.