# Work Orders

Manage work orders within maintenance jobs. Requires **premium** or **unlimited** subscription plan.

## View Work Order

<mark style="color:blue;">`GET`</mark> `/maintenance/workorder/view/{id}.json`

Retrieve full details for a single work order, including related inventory units and the parent maintenance job.

#### Path Parameters

| Parameter | Type   | Description     |
| --------- | ------ | --------------- |
| id        | string | Work order UUID |

#### Response

```json
{
  "workorder": {
    "WorkOrder": {
      "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "user_id": "123",
      "n_id": "3",
      "name": "Oil change",
      "ata": "79",
      "description": "Engine oil and filter replacement.",
      "time": "1.5",
      "status": "completed",
      "created": "1714003200"
    },
    "InventoryUnit": [
      {
        "Inventory": {
          "id": "d4e5f6a7-b8c9-0123-defg-h12345678901",
          "name": "Oil filter",
          "part_number": "CH48110-1"
        }
      }
    ],
    "User": {
      "id": "123",
      "UserDetail": {
        "name": "John",
        "surname": "Doe"
      }
    },
    "Job": {
      "Aircraft": {
        "id": "45",
        "company_id": "c1d2e3f4-a5b6-7890-abcd-ef1234567890",
        "registration": "EC-ABC",
        "AircraftModel": {
          "name": "C172",
          "AircraftManufacturer": {
            "name": "Cessna"
          }
        }
      }
    }
  }
}
```

***

## Edit Work Order

<mark style="color:green;">`POST`</mark> `/maintenance/workorder/edit.json`

Create or update a work order. The parent maintenance job must belong to the authenticated user's company.

#### Request Body

| Parameter               | Type   | Required | Description                                              |
| ----------------------- | ------ | -------- | -------------------------------------------------------- |
| WorkOrder\[id]          | string | no       | Work order UUID (omit to create new)                     |
| WorkOrder\[job\_id]     | string | yes      | Parent maintenance job UUID                              |
| WorkOrder\[name]        | string | yes      | Work order name                                          |
| WorkOrder\[status]      | string | yes      | `pending`, `open`, `completed`, `accomplished`, `closed` |
| WorkOrder\[ata]         | string | no       | ATA chapter code                                         |
| WorkOrder\[description] | string | no       | Work description                                         |
| WorkOrder\[time]        | number | no       | Time spent (decimal or HH:MM)                            |
| WorkOrder\[user\_id]    | number | no       | Assigned user ID                                         |

#### Response

```json
{
  "result": {
    "WorkOrder": {
      "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Oil change",
      "status": "completed"
    }
  },
  "message": "Work order saved",
  "errors": []
}
```

On validation failure:

```json
{
  "result": false,
  "message": "Could not save work order due to validation errors",
  "errors": {
    "name": ["Please enter a name"],
    "status": ["Invalid status"]
  }
}
```

***

## Delete Work Order

<mark style="color:green;">`POST`</mark> `/maintenance/workorder/delete.json`

Delete a work order. The parent maintenance job must belong to the authenticated user's company.

#### Request Body

| Parameter | Type   | Required | Description     |
| --------- | ------ | -------- | --------------- |
| id        | string | yes      | Work order UUID |

#### Response

```json
{
  "result": true,
  "job": {
    "WorkOrder": {
      "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901"
    },
    "Job": {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
    }
  }
}
```

***

## Print Work Order

<mark style="color:blue;">`GET`</mark> `/maintenance/workorder/print/{id}`

Generate a PDF document for a work order, including related inventory, assigned user, aircraft details, and file uploads.

#### Path Parameters

| Parameter | Type   | Description     |
| --------- | ------ | --------------- |
| id        | string | Work order UUID |

#### Response

Returns a PDF document (`Content-Type: application/pdf`).

***

## Enumerations Reference

#### Status

| Value          | Description                        |
| -------------- | ---------------------------------- |
| `pending`      | Work order created but not started |
| `open`         | Work in progress                   |
| `completed`    | Work completed, awaiting review    |
| `accomplished` | Work accomplished and verified     |
| `closed`       | Work order closed                  |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flylogs.com/fcom/api-docs/reference/work-orders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
