Skip to main content

Machine activities

The machine activities endpoint returns aggregated machine status buckets for a short time window — the same data that powers the timeline status strip. Each row represents a contiguous span of time during which a machine was in one status (active, idle, or off).

Permissions

EndpointMethodRead-only AccessRead-write AccessDescription
/api/v1/machine_activitiesGETRetrieve machine status buckets for the given machines and time window

GET /api/v1/machine_activities

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: array of machine foreign IDs to filter by. If omitted, all unarchived machines in the organisation are included.

Time-window limits

The machine activities endpoint shares the same windowing rules as /api/v1/events:

  • 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.

Example request

curl -X GET "https://your-org.trackmymachines.app/api/v1/machine_activities?from=2025-05-27T08:00:00Z&to=2025-05-27T16:00:00Z&machine_foreign_ids=MACHINE_001" \
-H "Authorization: Bearer YOUR_API_KEY"

Example response

[
{
"machine_foreign_id": "MACHINE_001",
"status": "active",
"from": "2025-05-27T08:00:00Z",
"to": "2025-05-27T10:15:00Z",
"duration_seconds": 8100
},
{
"machine_foreign_id": "MACHINE_001",
"status": "idle",
"from": "2025-05-27T10:15:00Z",
"to": null,
"duration_seconds": null
}
]

Response fields

  • machine_foreign_id: machine foreign ID (or null if not set).
  • status: one of active, idle, or off.
  • from: bucket start timestamp (ISO8601).
  • to: bucket end timestamp (ISO8601), or null for the currently-open bucket.
  • duration_seconds: bucket duration in seconds, or null for the currently-open bucket.

Internal database IDs (machine_id, etc.) are intentionally never exposed — only foreign 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" }