Skip to main content

Work Orders

Work orders track repair and maintenance jobs on a machine. Each work order can carry ordered instructions, a comment thread, and file attachments. All endpoints require a bearer JWT.

Endpoints

MethodPathDescription
POST/api/v1/work-ordersCreate a work order
GET/api/v1/work-ordersList work orders
GET/api/v1/work-orders/{work_order_id}Get a work order
PATCH/api/v1/work-orders/{work_order_id}Update a work order
DELETE/api/v1/work-orders/{work_order_id}Delete a work order
GET/api/v1/work-orders/{work_order_id}/commentsList comments
POST/api/v1/work-orders/{work_order_id}/commentsAdd a comment
GET/api/v1/work-orders/{work_order_id}/instructionsList instructions
POST/api/v1/work-orders/{work_order_id}/instructionsAdd an instruction
GET/api/v1/work-orders/{work_order_id}/instructions/{instruction_id}Get an instruction
PATCH/api/v1/work-orders/{work_order_id}/instructions/{instruction_id}Update an instruction
DELETE/api/v1/work-orders/{work_order_id}/instructions/{instruction_id}Delete an instruction
POST/api/v1/attachmentsUpload an attachment
GET/api/v1/attachments/work-order/{work_order_id}List a work order's attachments
GET/api/v1/attachments/{attachment_id}Get attachment metadata
GET/api/v1/attachments/{attachment_id}/downloadDownload an attachment
DELETE/api/v1/attachments/{attachment_id}Delete an attachment

Create a work order

POST /api/v1/work-orders

Requires an operator or administrator role.

FieldTypeRequiredDescription
machine_iduuidYesMachine the work order applies to
alert_iduuidNoAlert that prompted the work order
titlestringYesTitle (1–255 chars)
descriptionstringNoDetails
prioritystringNoOne of low, medium, high, critical (default medium)
assigned_touuidNoPrimary assignee
assignee_idsarray of uuidNoAdditional assignees
due_datedatetimeNoDue date (ISO 8601 UTC)
{
"machine_id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Replace spindle bearings",
"description": "Main spindle bearings showing excessive vibration.",
"priority": "high",
"assigned_to": "3f2504e0-4f89-41d3-9a0c-0305e82c3301"
}

Response201 Created

{
"id": "ee55...",
"machine_id": "550e8400-e29b-41d4-a716-446655440000",
"alert_id": null,
"title": "Replace spindle bearings",
"description": "Main spindle bearings showing excessive vibration.",
"status": "open",
"priority": "high",
"assigned_to": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"assignee_ids": [],
"due_date": null,
"completed_at": null,
"completion_notes": null,
"created_by": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"created_at": "2026-08-07T10:00:00Z",
"updated_at": "2026-08-07T10:00:00Z"
}

List work orders

GET /api/v1/work-orders

ParameterTypeDescription
machine_iduuidFilter by machine
statusstringOne of open, in_progress, completed, cancelled
pageintegerPage number (default 1)
page_sizeintegerItems per page (default 20, max 100)

Returns an items array with a total count.

Get, update, and delete

GET /api/v1/work-orders/{work_order_id} returns one work order. PATCH /api/v1/work-orders/{work_order_id} updates it and DELETE /api/v1/work-orders/{work_order_id} removes it (204 No Content). Update and delete require an operator or administrator role.

Updatable fields include title, description, status, priority, assigned_to, assignee_ids, due_date, and completion_notes.

{
"status": "in_progress"
}

Comments

GET /api/v1/work-orders/{work_order_id}/comments lists the comment thread. POST /api/v1/work-orders/{work_order_id}/comments adds a comment (body up to 2,000 characters).

{
"body": "Bearings ordered. Expected delivery next week."
}

Instructions

Instructions are ordered steps attached to a work order.

Add an instruction

POST /api/v1/work-orders/{work_order_id}/instructions

Requires an operator or administrator role.

FieldTypeRequiredDescription
step_orderintegerYesStep position (≥ 1)
titlestringYesStep title (1–255 chars)
bodystringNoStep detail (up to 5,000 chars)
attachment_iduuidNoAttachment to show with the step
{
"step_order": 1,
"title": "Lock out and tag out the machine",
"body": "Follow the site LOTO procedure before opening the spindle housing."
}

Response201 Created

{
"id": "ff66...",
"work_order_id": "ee55...",
"step_order": 1,
"title": "Lock out and tag out the machine",
"body": "Follow the site LOTO procedure before opening the spindle housing.",
"attachment_id": null,
"created_by": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"created_at": "2026-08-07T10:05:00Z",
"updated_at": "2026-08-07T10:05:00Z"
}

List, get, update, and delete

GET /api/v1/work-orders/{work_order_id}/instructions returns the steps as an items array with a total. GET, PATCH, and DELETE on /api/v1/work-orders/{work_order_id}/instructions/{instruction_id} operate on a single step. Update and delete require an operator or administrator role.

Attachments

Attachments are files linked to a work order (or a maintenance event — see Maintenance).

Upload an attachment

POST /api/v1/attachments

Requires an operator or administrator role. Send the file as multipart/form-data under the file field and provide the target as a query parameter — either work_order_id or maintenance_event_id.

curl -X POST "https://api.haltless.io/api/v1/attachments?work_order_id=ee55..." \
-H "Authorization: Bearer <jwt>" \
-F "file=@inspection-photo.jpg"

Response201 Created

{
"id": "aa77...",
"work_order_id": "ee55...",
"maintenance_event_id": null,
"uploaded_by": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"filename": "inspection-photo.jpg",
"content_type": "image/jpeg",
"size_bytes": 245678,
"created_at": "2026-08-07T10:10:00Z",
"updated_at": "2026-08-07T10:10:00Z"
}

List, download, and delete

GET /api/v1/attachments/work-order/{work_order_id} lists a work order's attachments. GET /api/v1/attachments/{attachment_id} returns metadata, and GET /api/v1/attachments/{attachment_id}/download returns the file bytes with a Content-Disposition header. DELETE /api/v1/attachments/{attachment_id} removes an attachment (204 No Content) and requires an operator or administrator role.

Status flow

StatusDescription
openCreated, not yet started
in_progressWork underway
completedWork finished
cancelledWork order cancelled