Events
The events endpoint returns timeline-style events for one or more machines over a short time window. It is intended for building live timeline views — overlays of cycles, steps, part counts, shifts, downtime reasons, and work order operations on a per-machine timeline.
Permissions
| Endpoint | Method | Read-only Access | Read-write Access | Description |
|---|---|---|---|---|
/api/v1/events | GET | ✅ | ✅ | Retrieve timeline events for the given machines and time window |
GET /api/v1/events
Required role: read-only or read-write
Query parameters:
-
from(required): ISO8601 start timestamp. -
to(required): ISO8601 end timestamp. Must be strictly afterfrom. -
machine_foreign_ids[]: machine foreign IDs to filter by, repeated once per ID (machine_foreign_ids[]=A&machine_foreign_ids[]=B). A single bare value (machine_foreign_ids=A) also works; a comma-separated list does not — it is read as one ID. -
machine_display_names[]: machines by their name in TrackMyMachines, the same way — for machines with no foreign ID. Given withmachine_foreign_ids[], you get both sets of machines.Both match exactly, ignoring surrounding spaces, and find archived machines too. An ID or name that matches no machine returns
422naming it; an empty value is ignored. With neither, all unarchived machines in the organisation are included. -
types: one or more event types to include. Any unrecognised values are ignored. Supported values:cyclesteppart_countshift_periodactivity_reasonwork_order_operationalarm
Without
types, every type is returned, alarms included.
Deleted events (a job or a downtime reason someone removed) are not returned.
Time-window limits
The events endpoint is designed for short windows, not historical exports.
- The maximum allowed window is 1 day.
- If
to - from > 1 day, the endpoint responds with422 Unprocessable Entity. - If
to <= fromor either timestamp is missing, the endpoint responds with422 Unprocessable Entity. - A timestamp without an offset is read in your organisation's timezone (
2026-07-01T09:00:00is 09:00 on your clock). - At most 500 rows per call (
limit, the default); page withoffset. When there are more, theX-Next-Offsetresponse header says where the next page starts (absent on the last page), besideX-Total-Count.
Example request
curl -X GET "https://your-org.trackmymachines.app/api/v1/events?from=2025-05-27T08:00:00Z&to=2025-05-27T16:00:00Z&machine_foreign_ids[]=MACHINE_001&machine_foreign_ids[]=MACHINE_002&types=step&types=activity_reason" \
-H "Authorization: Bearer YOUR_API_KEY"
Example response
[
{
"id": "evt_8h3KdL2pQrxV",
"type": "step",
"machine_foreign_id": "MACHINE_001",
"machine_display_name": "Mazak 1",
"from": "2025-05-27T10:00:00Z",
"to": "2025-05-27T11:30:00Z",
"duration_seconds": 5400,
"label": "PART123",
"cycle_type": null,
"quantity": null
},
{
"id": "evt_R7nT4mZ9wKbY",
"type": "activity_reason",
"machine_foreign_id": "MACHINE_001",
"machine_display_name": "Mazak 1",
"from": "2025-05-27T11:30:00Z",
"to": null,
"duration_seconds": null,
"label": "Tool change",
"cycle_type": null,
"quantity": null
}
]
Response fields
id: prefixed external event identifier (evt_…), stable across DB reseeds.type: event type, underscored (cycle,step,part_count,shift_period,activity_reason,work_order_operation,alarm).machine_foreign_id: machine foreign ID (ornullif not set).machine_display_name: the machine's name in TrackMyMachines. Always set.from: event start timestamp (ISO8601).to: event end timestamp (ISO8601), ornullfor in-flight events.duration_seconds: event duration in seconds, ornullfor in-flight events.label: display text naming what the event is. What it holds depends on the type (below).cycle_type: for acycle, how the cycle was found:machine_program_cycle,matched_cycleortoleranced_cycle.nullfor every other type.quantity: for apart_count, how many parts it counts. Usually1, a single part atfrom. A machine set to count per minute sends onepart_countper minute instead, spanningfrom–to, with that minute's total here.nullfor every other type.
What label holds
type | label |
|---|---|
cycle | Depends on cycle_type. A machine_program_cycle comes from the machine's program, and its label is the program name or number (e.g. O1234), so a change of label between cycles is a program change. A matched_cycle is labelled with the job it was matched to (PART123 Op10). A toleranced_cycle carries the name it was set up with. |
step | The part number. |
work_order_operation | The work order number and operation, e.g. WO1820505 Op10. |
part_count | Part or Scrap. |
activity_reason | The downtime reason. |
shift_period | The shift pattern's name. |
alarm | The alarm's name. |
For any type except part_count, an event whose underlying record has since been deleted is labelled Deleted <Type>. label is meant to be read; for anything you need to match reliably, prefer the structured fields.
Internal database IDs (machine_id, numeric event IDs) are intentionally never exposed — only foreign / external identifiers cross the API boundary.
Error responses
422 Unprocessable Entity—{ "error": "from and to are required ISO8601 timestamps" }422 Unprocessable Entity—{ "error": "to must be after from" }422 Unprocessable Entity—{ "error": "window larger than maximum allowed 1 day" }422 Unprocessable Entity—{ "error": "no machine with foreign id 'MAZA-L9'" }