---
# System prepended metadata

title: 批量查詢機台狀態
tags: [狀態查詢]

---

# 批量查詢機台狀態

**查詢多台機器的線上狀態與最後上線時間**

#### 網址
{domain}/smart-daily/healthy/check-machines-status

#### 認證方式
無需認證

#### Method
POST

#### 傳入參數

|欄位名稱|必填|型態|說明|備註|
| ------------ | :-----------: |:-----------: |------------ |------------ |
|machine_code | Y | string | 機台代碼 | |
|security_key | Y | string | 認證安全碼 | |

#### 回傳參數（機台存在時）

|Name|Type|說明|備註|
| ------------ | ------------ |------------ |------------ |
|machine_code|string|機台代碼||
|machine_status|int|機台狀態|1:線上 / 0:離線|
|last_online_at|string|最後上線時間|格式: Y-m-d H:i:s|

#### 回傳參數（機台不存在時）

|Name|Type|說明|備註|
| ------------ | ------------ |------------ |------------ |
|machine_code|string|機台代碼||
|error|string|錯誤訊息|機台不存在|

#### Request Body
```json
Content-Type: application/json
```

#### Json Example
Request POST
```json
[
    {
        "machine_code": "SMART001",
        "security_key": "abc123xyz"
    },
    {
        "machine_code": "SMART002",
        "security_key": "def456uvw"
    },
    {
        "machine_code": "SMART003",
        "security_key": "ghi789rst"
    }
]
```

Response Json Success
```json
{
    "status": true,
    "message": "success",
    "data": [
        {
            "machine_code": "SMART001",
            "machine_status": 1,
            "last_online_at": "2025-11-29 14:30:25"
        },
        {
            "machine_code": "SMART002",
            "machine_status": 0,
            "last_online_at": "2025-11-28 10:15:00"
        },
        {
            "machine_code": "SMART003",
            "error": "機台不存在"
        }
    ]
}
```

Response Json Error (請求格式錯誤)
```json
{
    "status": false,
    "message": "Bad Request",
    "errors": []
}
```

Response Json Error (缺少必填欄位)
```json
{
    "status": false,
    "message": "machine_code and security_key are required",
    "errors": []
}
```
