# Query machine state history with time-bucket aggregation (/docs/api-reference/monitoring/MonitoringController_getMachineStates)

`GET /api/factories/{factoryId}/monitoring/machine-states`

Base URL: https://api.xentr.ai

Authentication: bearer token (`Authorization: Bearer <token>`).

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `factoryId` | path | yes | string | Factory ID |
| `machineId` | query | no | string | Filter by machine ID |
| `from` | query | no | string | Start time (ISO 8601) |
| `to` | query | no | string | End time (ISO 8601) |
| `bucket` | query | no | string | Time bucket interval (e.g., "5 minutes", "1 hour") |

## Responses

### 200: Aggregated machine state data