Skip to main content

Maintenance

Maintenance events schedule planned work on a machine over a start and end time. They are scheduled by hand, recur on the calendar, or are created by a usage plan when a machine has run long enough. All endpoints require a bearer JWT and the Maintenance page. Writing needs an operator or administrator role that has not had maintenance changes withdrawn under Settings → Role Permissions.

Endpoints​

MethodPathDescription
POST/api/v1/maintenanceSchedule a maintenance event
GET/api/v1/maintenanceList maintenance events
GET/api/v1/maintenance/{event_id}Get a maintenance event
PUT/api/v1/maintenance/{event_id}Update a maintenance event
DELETE/api/v1/maintenance/{event_id}Delete a maintenance event
GET/api/v1/maintenance/usage-plansList usage plans
POST/api/v1/maintenance/usage-plansCreate a usage plan
PUT/api/v1/maintenance/usage-plans/{plan_id}Update a usage plan
POST/api/v1/maintenance/usage-plans/{plan_id}/resetRestart a plan's count
DELETE/api/v1/maintenance/usage-plans/{plan_id}Delete a usage plan
GET/api/v1/attachments/maintenance-event/{event_id}List an event's attachments

Schedule an event​

POST /api/v1/maintenance

Requires an operator or administrator role.

FieldTypeRequiredDescription
machine_iduuidYesMachine the event applies to
titlestringYesEvent title (1–300 chars)
descriptionstringNoDetails (up to 4,000 chars)
scheduled_startdatetimeYesStart time (ISO 8601 UTC)
scheduled_enddatetimeYesEnd time (ISO 8601 UTC)
linked_alert_iduuidNoAlert that prompted this event
assigned_touuidNoUser the event is assigned to
recurrence_rulestringNoOne of daily, weekly, monthly, quarterly

When recurrence_rule is set, a series of child events is generated automatically from the parent: 30 for daily, 52 for weekly, 12 for monthly and 4 for quarterly. 404 if the machine is not one of yours.

{
"machine_id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Quarterly bearing inspection",
"description": "Check and replace main spindle bearings if needed.",
"scheduled_start": "2026-08-10T08:00:00Z",
"scheduled_end": "2026-08-10T12:00:00Z",
"recurrence_rule": "quarterly"
}

Response: 201 Created

{
"id": "dd44...",
"tenant_id": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"machine_id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Quarterly bearing inspection",
"description": "Check and replace main spindle bearings if needed.",
"scheduled_start": "2026-08-10T08:00:00Z",
"scheduled_end": "2026-08-10T12:00:00Z",
"status": "scheduled",
"linked_alert_id": null,
"assigned_to": null,
"created_by": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"created_at": "2026-08-07T10:00:00Z",
"recurrence_rule": "quarterly",
"parent_event_id": null,
"usage_plan_id": null
}

usage_plan_id names the usage plan that created the event; null for one scheduled by hand or by recurrence.

List events​

GET /api/v1/maintenance

ParameterTypeDescription
machine_iduuidFilter by machine
statusstringOne of scheduled, in_progress, completed, cancelled
start_afterdatetimeEvents starting on or after this time
end_beforedatetimeEvents ending on or before this time

Returns an array of maintenance events.

Get an event​

GET /api/v1/maintenance/{event_id}

Returns one event, or 404 if it is not found.

Update an event​

PUT /api/v1/maintenance/{event_id}

Requires an operator or administrator role. Include only the fields you want to change.

FieldTypeDescription
titlestringNew title (1–300 chars)
descriptionstringNew description
scheduled_startdatetimeNew start time
scheduled_enddatetimeNew end time
statusstringOne of scheduled, in_progress, completed, cancelled
assigned_touuidNew assignee

Delete an event​

DELETE /api/v1/maintenance/{event_id}

Requires an operator or administrator role. Returns 204 No Content.

Statuses​

StatusDescription
scheduledPlanned, not yet started
in_progressWork underway
completedWork finished
cancelledEvent cancelled

Maintenance due by use​

A usage plan schedules maintenance by how much a machine has been used since its last service, not by the calendar. It counts one of:

  • counter: a counter tag the machine already sends, such as an hour meter, a cycle counter or a start counter. Its increases are counted; a counter that restarts from zero loses nothing.
  • run_hours: the hours the machine ran, as its run state measures them, for a machine with no hour meter. This needs the machine's run state named first (see Production signals); otherwise creating the plan returns 422.

Every five minutes the count is brought up to date. Readings from the last 24 hours are counted again each time, so readings an edge agent delivers late, after an outage, still count. When the count passes usage_limit, a maintenance event is created on the machine, starting then and lasting duration_minutes, with the count and the limit in its description. Only one is created at a time: none while the plan's last event is still scheduled or in_progress. When that event is completed, or cancelled as not needed, the count starts again from zero.

Listing, creating and changing plans needs the same access as maintenance events: any user may list, an operator or administrator writes. A user limited to some machine groups sees and writes the plans of machines in scope.

Create a usage plan​

POST /api/v1/maintenance/usage-plans

FieldTypeRequiredDescription
machine_iduuidYesThe machine
titlestringYesThe work, as the event will be titled (up to 300 chars)
descriptionstringNoNotes, added to the event's description
meter_sourcestringYescounter or run_hours
meter_metricstringWith counterThe counter tag
meter_unitstringNoHow the count reads (h, cycles, starts); run_hours is always h
usage_limitnumberYesService every this much use (> 0)
duration_minutesintegerNoHow long the work takes (default 120, up to 7 days)
initial_usednumberNoAlready used since the last service, for a plan that starts mid-interval (default 0)
{
"machine_id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Regrease the press",
"meter_source": "counter",
"meter_metric": "cycle_count",
"meter_unit": "cycles",
"usage_limit": 50000,
"duration_minutes": 90,
"initial_used": 1200
}

Response: 201 Created

{
"id": "e5f6...",
"machine_id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Regrease the press",
"description": null,
"meter_source": "counter",
"meter_metric": "cycle_count",
"meter_unit": "cycles",
"usage_limit": 50000,
"duration_minutes": 90,
"used": 1200,
"used_at": "2026-11-13T10:00:00Z",
"counting_since": "2026-11-13T10:00:00Z",
"is_active": true,
"due": false,
"open_event_id": null,
"created_at": "2026-11-13T10:00:00Z"
}

used is the count since the last service as of used_at, due is true once it has reached usage_limit, and open_event_id is the event the plan created that is not done yet.

Update, reset and delete​

PUT /api/v1/maintenance/usage-plans/{plan_id} changes title, description, usage_limit, duration_minutes, meter_unit or is_active (an inactive plan stops counting). The machine and what is counted are fixed: a different meter is a different plan.

POST /api/v1/maintenance/usage-plans/{plan_id}/reset restarts the count from zero, for a service done outside Haltless.

DELETE /api/v1/maintenance/usage-plans/{plan_id} removes the plan (204 No Content). Events it already created stay.

Attachments​

An event can carry up to 20 files: photos, documents and videos from the work. They are uploaded as a work order's are, naming maintenance_event_id instead of work_order_id (Work Orders), and downloaded and deleted the same way.

GET /api/v1/attachments/maintenance-event/{event_id} lists them as an items array with a total, each as the upload returned it. It needs the Maintenance page, and an event on a machine you cannot see is a 404.