Skip to main content

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​

EndpointMethodRead-only AccessRead-write AccessDescription
/api/v1/eventsGET✅✅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 after from.

  • 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 with machine_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 422 naming 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:

    • cycle
    • step
    • part_count
    • shift_period
    • activity_reason
    • work_order_operation
    • alarm

    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 with 422 Unprocessable Entity.
  • If to <= from or either timestamp is missing, the endpoint responds with 422 Unprocessable Entity.
  • A timestamp without an offset is read in your organisation's timezone (2026-07-01T09:00:00 is 09:00 on your clock).
  • At most 500 rows per call (limit, the default); page with offset. When there are more, the X-Next-Offset response header says where the next page starts (absent on the last page), beside X-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 (or null if not set).
  • machine_display_name: the machine's name in TrackMyMachines. Always set.
  • from: event start timestamp (ISO8601).
  • to: event end timestamp (ISO8601), or null for in-flight events.
  • duration_seconds: event duration in seconds, or null for in-flight events.
  • label: display text naming what the event is. What it holds depends on the type (below).
  • cycle_type: for a cycle, how the cycle was found: machine_program_cycle, matched_cycle or toleranced_cycle. null for every other type.
  • quantity: for a part_count, how many parts it counts. Usually 1, a single part at from. A machine set to count per minute sends one part_count per minute instead, spanning from–to, with that minute's total here. null for every other type.

What label holds​

typelabel
cycleDepends 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.
stepThe part number.
work_order_operationThe work order number and operation, e.g. WO1820505 Op10.
part_countPart or Scrap.
activity_reasonThe downtime reason.
shift_periodThe shift pattern's name.
alarmThe 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'" }