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
| Endpoint | Method | Read-only Access | Read-write Access | Description |
|---|---|---|---|---|
/api/v1/machine_activities | GET | ✅ | ✅ | Retrieve 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 afterfrom.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 with422 Unprocessable Entity. - If
to <= fromor either timestamp is missing, the endpoint responds with422 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 (ornullif not set).status: one ofactive,idle, oroff.from: bucket start timestamp (ISO8601).to: bucket end timestamp (ISO8601), ornullfor the currently-open bucket.duration_seconds: bucket duration in seconds, ornullfor 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" }