{
    "openapi": "3.1.0",
    "info": {
        "title": "Ruang IoT REST API",
        "version": "1.0.0",
        "description": "API untuk membaca proyek, perangkat, nilai terakhir, dan riwayat; mengirim nilai dari perangkat non-MQTT; dan mengirim perintah. Semua waktu dalam WIB (ISO 8601, +07:00). Autentikasi dengan API key workspace (menu akun → API & Webhook).",
        "contact": {
            "name": "Ruang IoT",
            "url": "https://ruangiot.id/docs/api"
        }
    },
    "servers": [
        {
            "url": "https://ruangiot.id/api/v1"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        },
        {
            "apiKeyHeader": []
        }
    ],
    "tags": [
        {
            "name": "Proyek",
            "description": "Proyek di workspace pemilik API key."
        },
        {
            "name": "Perangkat",
            "description": "Perangkat, variabel, nilai terakhir, dan riwayat."
        },
        {
            "name": "Data",
            "description": "Kirim nilai lewat HTTP untuk perangkat non-MQTT."
        },
        {
            "name": "Perintah",
            "description": "Kirim perintah ke variabel berarah Perintah."
        }
    ],
    "paths": {
        "/projects": {
            "get": {
                "operationId": "listProjects",
                "tags": [
                    "Proyek"
                ],
                "summary": "Daftar proyek workspace",
                "description": "Proyek di workspace pemilik API key, berhalaman.\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Daftar proyek.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data",
                                        "meta"
                                    ],
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Project"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/PageMeta"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 50
                        }
                    }
                ]
            }
        },
        "/projects/{project}": {
            "get": {
                "operationId": "getProject",
                "tags": [
                    "Proyek"
                ],
                "summary": "Detail proyek",
                "description": "Satu proyek milik workspace API key.\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Proyek.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Project"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "project",
                        "in": "path",
                        "required": true,
                        "description": "ID proyek (AUTH_TOKEN di program perangkat).",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9]{1,64}$"
                        }
                    }
                ]
            }
        },
        "/projects/{project}/devices": {
            "get": {
                "operationId": "listProjectDevices",
                "tags": [
                    "Proyek"
                ],
                "summary": "Perangkat dalam proyek",
                "description": "Semua perangkat proyek beserta statusnya (Online, Tidak aktif, Offline, Belum pernah terhubung).\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Daftar perangkat.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/DeviceSummary"
                                            }
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "project",
                        "in": "path",
                        "required": true,
                        "description": "ID proyek (AUTH_TOKEN di program perangkat).",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9]{1,64}$"
                        }
                    }
                ]
            }
        },
        "/projects/{project}/alerts": {
            "get": {
                "operationId": "listProjectAlerts",
                "tags": [
                    "Proyek"
                ],
                "summary": "Alarm proyek",
                "description": "Kejadian Alarm & Otomasi proyek. Bawaan: alarm terbuka (Aktif dan Diakui).\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Daftar kejadian alarm.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/AlertEvent"
                                            }
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "422": {
                        "$ref": "#/components/responses/E422"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "project",
                        "in": "path",
                        "required": true,
                        "description": "ID proyek (AUTH_TOKEN di program perangkat).",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9]{1,64}$"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "open",
                                "all"
                            ],
                            "default": "open"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 50
                        }
                    }
                ]
            }
        },
        "/devices/{device}": {
            "get": {
                "operationId": "getDevice",
                "tags": [
                    "Perangkat"
                ],
                "summary": "Detail perangkat",
                "description": "Perangkat beserta variabelnya.\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Perangkat.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/DeviceDetail"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "device",
                        "in": "path",
                        "required": true,
                        "description": "Device ID.",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,64}$"
                        }
                    }
                ]
            }
        },
        "/devices/{device}/variables": {
            "get": {
                "operationId": "listDeviceVariables",
                "tags": [
                    "Perangkat"
                ],
                "summary": "Variabel perangkat",
                "description": "Data & Topik perangkat: Sensor (telemetry), Perintah (command), dan Status.\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Daftar variabel.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Variable"
                                            }
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "device",
                        "in": "path",
                        "required": true,
                        "description": "Device ID.",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,64}$"
                        }
                    }
                ]
            }
        },
        "/devices/{device}/latest": {
            "get": {
                "operationId": "getDeviceLatest",
                "tags": [
                    "Perangkat"
                ],
                "summary": "Nilai terbaru perangkat",
                "description": "Nilai terakhir setiap variabel (sumber yang sama dengan halaman Ringkasan dan Perangkat).\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Nilai terakhir.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data",
                                        "meta"
                                    ],
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/LatestValue"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/LatestMeta"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "device",
                        "in": "path",
                        "required": true,
                        "description": "Device ID.",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,64}$"
                        }
                    }
                ]
            }
        },
        "/devices/{device}/history": {
            "get": {
                "operationId": "getDeviceHistory",
                "tags": [
                    "Perangkat"
                ],
                "summary": "Riwayat nilai perangkat",
                "description": "Riwayat nilai dalam rentang waktu. interval=raw mengembalikan titik asli (paling banyak limit); minute/hour/day/month mengembalikan rata-rata, minimum, maksimum, jumlah, dan banyak data per ember waktu WIB (dihitung di basis data). Hanya data berkualitas valid.\n\nCakupan API key yang dibutuhkan: `read`.",
                "x-ruangiot-scope": "read",
                "responses": {
                    "200": {
                        "description": "Deret riwayat per variabel.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data",
                                        "meta"
                                    ],
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/HistorySeries"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/HistoryMeta"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "422": {
                        "$ref": "#/components/responses/E422"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "device",
                        "in": "path",
                        "required": true,
                        "description": "Device ID.",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,64}$"
                        }
                    },
                    {
                        "name": "variable",
                        "in": "query",
                        "description": "Kunci variabel, pisahkan dengan koma. Bawaan: semua variabel angka dan ON/OFF.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "description": "Awal rentang (ISO 8601). Bawaan: 24 jam sebelum \"to\". Tanpa zona = WIB.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "description": "Akhir rentang (ISO 8601). Bawaan: sekarang.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "interval",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "raw",
                                "minute",
                                "hour",
                                "day",
                                "month"
                            ],
                            "default": "raw"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Untuk interval=raw.",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 5000,
                            "default": 1000
                        }
                    }
                ]
            }
        },
        "/devices/{device}/data": {
            "post": {
                "operationId": "sendDeviceData",
                "tags": [
                    "Data"
                ],
                "summary": "Kirim nilai",
                "description": "Menyimpan nilai Sensor/Status lewat HTTP. Jalurnya sama dengan pesan MQTT: riwayat, status Online perangkat, Alarm & Otomasi, Digital Twin, dan webhook data.received. Variabel berarah Perintah ditolak.\n\nCakupan API key yang dibutuhkan: `write`.",
                "x-ruangiot-scope": "write",
                "responses": {
                    "202": {
                        "description": "Nilai diterima.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/IngestResult"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "415": {
                        "$ref": "#/components/responses/E415"
                    },
                    "422": {
                        "$ref": "#/components/responses/E422"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    }
                },
                "parameters": [
                    {
                        "name": "device",
                        "in": "path",
                        "required": true,
                        "description": "Device ID.",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,64}$"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/IngestRequest"
                            },
                            "example": {
                                "values": {
                                    "suhu": 27.5,
                                    "kelembapan": 61
                                },
                                "timestamp": "2026-11-21T08:00:00+07:00"
                            }
                        }
                    }
                }
            }
        },
        "/devices/{device}/commands": {
            "post": {
                "operationId": "sendDeviceCommand",
                "tags": [
                    "Perintah"
                ],
                "summary": "Kirim perintah",
                "description": "Mengirim perintah ke variabel berarah Perintah lewat jalur yang sama dengan dashboard dan Alarm & Otomasi. Butuh izin kendali pembuat API key (akses ubah proyek; perangkat pinjaman sekolah hanya selama izin kontrol aktif).\n\nCakupan API key yang dibutuhkan: `control`.",
                "x-ruangiot-scope": "control",
                "responses": {
                    "202": {
                        "description": "Perintah dikirim.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "data"
                                    ],
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/CommandResult"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/E401"
                    },
                    "403": {
                        "$ref": "#/components/responses/E403"
                    },
                    "404": {
                        "$ref": "#/components/responses/E404"
                    },
                    "415": {
                        "$ref": "#/components/responses/E415"
                    },
                    "422": {
                        "$ref": "#/components/responses/E422"
                    },
                    "429": {
                        "$ref": "#/components/responses/E429"
                    },
                    "503": {
                        "$ref": "#/components/responses/E503"
                    }
                },
                "parameters": [
                    {
                        "name": "device",
                        "in": "path",
                        "required": true,
                        "description": "Device ID.",
                        "schema": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,64}$"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CommandRequest"
                            },
                            "example": {
                                "variable": "lampu",
                                "value": true
                            }
                        }
                    }
                }
            }
        }
    },
    "webhooks": {
        "alert.triggered": {
            "post": {
                "operationId": "webhookAlertTriggered",
                "summary": "Alarm terpicu",
                "description": "Header: X-RuangIoT-Event (jenis), X-RuangIoT-Event-Id (ID peristiwa), X-RuangIoT-Delivery (ID pengiriman), X-RuangIoT-Timestamp (detik Unix), X-RuangIoT-Signature: v1=<hex HMAC-SHA256(rahasia, \"<timestamp>.<badan mentah>\")>. Tolak stempel waktu yang lebih lama dari 5 menit. Jawab 2xx dalam 6 detik; selain itu dicoba ulang (10 dtk, 1 mnt, 5 mnt, 30 mnt).",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookAlertTriggered"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Diterima."
                    }
                }
            }
        },
        "alert.recovered": {
            "post": {
                "operationId": "webhookAlertRecovered",
                "summary": "Alarm pulih",
                "description": "Header: X-RuangIoT-Event (jenis), X-RuangIoT-Event-Id (ID peristiwa), X-RuangIoT-Delivery (ID pengiriman), X-RuangIoT-Timestamp (detik Unix), X-RuangIoT-Signature: v1=<hex HMAC-SHA256(rahasia, \"<timestamp>.<badan mentah>\")>. Tolak stempel waktu yang lebih lama dari 5 menit. Jawab 2xx dalam 6 detik; selain itu dicoba ulang (10 dtk, 1 mnt, 5 mnt, 30 mnt).",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookAlertRecovered"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Diterima."
                    }
                }
            }
        },
        "device.online": {
            "post": {
                "operationId": "webhookDeviceOnline",
                "summary": "Perangkat menjadi Online",
                "description": "Header: X-RuangIoT-Event (jenis), X-RuangIoT-Event-Id (ID peristiwa), X-RuangIoT-Delivery (ID pengiriman), X-RuangIoT-Timestamp (detik Unix), X-RuangIoT-Signature: v1=<hex HMAC-SHA256(rahasia, \"<timestamp>.<badan mentah>\")>. Tolak stempel waktu yang lebih lama dari 5 menit. Jawab 2xx dalam 6 detik; selain itu dicoba ulang (10 dtk, 1 mnt, 5 mnt, 30 mnt).",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookDeviceOnline"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Diterima."
                    }
                }
            }
        },
        "device.inactive": {
            "post": {
                "operationId": "webhookDeviceInactive",
                "summary": "Perangkat menjadi Tidak aktif",
                "description": "Header: X-RuangIoT-Event (jenis), X-RuangIoT-Event-Id (ID peristiwa), X-RuangIoT-Delivery (ID pengiriman), X-RuangIoT-Timestamp (detik Unix), X-RuangIoT-Signature: v1=<hex HMAC-SHA256(rahasia, \"<timestamp>.<badan mentah>\")>. Tolak stempel waktu yang lebih lama dari 5 menit. Jawab 2xx dalam 6 detik; selain itu dicoba ulang (10 dtk, 1 mnt, 5 mnt, 30 mnt).",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookDeviceInactive"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Diterima."
                    }
                }
            }
        },
        "data.received": {
            "post": {
                "operationId": "webhookDataReceived",
                "summary": "Data baru masuk (paling sering 1 per perangkat tiap 10 dtk)",
                "description": "Header: X-RuangIoT-Event (jenis), X-RuangIoT-Event-Id (ID peristiwa), X-RuangIoT-Delivery (ID pengiriman), X-RuangIoT-Timestamp (detik Unix), X-RuangIoT-Signature: v1=<hex HMAC-SHA256(rahasia, \"<timestamp>.<badan mentah>\")>. Tolak stempel waktu yang lebih lama dari 5 menit. Jawab 2xx dalam 6 detik; selain itu dicoba ulang (10 dtk, 1 mnt, 5 mnt, 30 mnt).",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookDataReceived"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Diterima."
                    }
                }
            }
        },
        "ping": {
            "post": {
                "operationId": "webhookPing",
                "summary": "Uji dari halaman API & Webhook",
                "description": "Header: X-RuangIoT-Event (jenis), X-RuangIoT-Event-Id (ID peristiwa), X-RuangIoT-Delivery (ID pengiriman), X-RuangIoT-Timestamp (detik Unix), X-RuangIoT-Signature: v1=<hex HMAC-SHA256(rahasia, \"<timestamp>.<badan mentah>\")>. Tolak stempel waktu yang lebih lama dari 5 menit. Jawab 2xx dalam 6 detik; selain itu dicoba ulang (10 dtk, 1 mnt, 5 mnt, 30 mnt).",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookPing"
                            }
                        }
                    }
                },
                "responses": {
                    "2XX": {
                        "description": "Diterima."
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "rk_…",
                "description": "Authorization: Bearer rk_… (API key workspace, tampil sekali saat dibuat)."
            },
            "apiKeyHeader": {
                "type": "apiKey",
                "in": "header",
                "name": "X-API-Key",
                "description": "Alternatif untuk klien yang tidak bisa mengatur header Authorization."
            }
        },
        "responses": {
            "E400": {
                "description": "Permintaan salah (mis. API key di alamat URL).",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "E401": {
                "description": "API key tidak ada, tidak dikenal, dicabut, kedaluwarsa, atau pembuatnya tidak lagi mengelola workspace.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "E403": {
                "description": "Cakupan API key kurang, atau kendali perangkat tidak diizinkan.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "E404": {
                "description": "Data tidak ditemukan atau bukan milik workspace API key.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "E415": {
                "description": "Badan permintaan harus JSON.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "E422": {
                "description": "Data permintaan tidak valid (rincian per kolom di error.details).",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "E429": {
                "description": "Batas laju terlampaui (per API key, per perangkat, atau percobaan key salah per IP). Lihat header Retry-After.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "E503": {
                "description": "Broker MQTT tidak dapat dihubungi.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "object",
                        "required": [
                            "status",
                            "code",
                            "message"
                        ],
                        "properties": {
                            "status": {
                                "type": "integer"
                            },
                            "code": {
                                "type": "string",
                                "description": "Kode mesin, mis. invalid_key, key_revoked, key_expired, insufficient_scope, project_not_found, device_not_found, validation_failed, rate_limited, control_not_allowed."
                            },
                            "message": {
                                "type": "string"
                            },
                            "details": {
                                "type": "object"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            },
            "PageMeta": {
                "type": "object",
                "required": [
                    "page",
                    "per_page",
                    "total"
                ],
                "properties": {
                    "page": {
                        "type": "integer"
                    },
                    "per_page": {
                        "type": "integer"
                    },
                    "total": {
                        "type": "integer"
                    }
                },
                "additionalProperties": false
            },
            "Project": {
                "type": "object",
                "required": [
                    "id",
                    "name",
                    "description",
                    "category",
                    "public",
                    "devices_count",
                    "created_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "description": "ID proyek = AUTH_TOKEN."
                    },
                    "name": {
                        "type": "string"
                    },
                    "description": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "category": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "public": {
                        "type": "boolean"
                    },
                    "devices_count": {
                        "type": "integer"
                    },
                    "created_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    }
                },
                "additionalProperties": false
            },
            "DeviceSummary": {
                "type": "object",
                "required": [
                    "id",
                    "project_id",
                    "name",
                    "type",
                    "location",
                    "status",
                    "status_label",
                    "last_seen_at",
                    "variables_count"
                ],
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "project_id": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "type": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "location": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "online",
                            "inactive",
                            "offline",
                            "never_connected"
                        ],
                        "description": "online ≤ ambang heartbeat; inactive = Tidak aktif (≤ 24 jam tanpa data); offline > 24 jam; never_connected = belum pernah ada data."
                    },
                    "status_label": {
                        "type": "string"
                    },
                    "last_seen_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "variables_count": {
                        "type": "integer"
                    }
                },
                "additionalProperties": false
            },
            "Variable": {
                "type": "object",
                "required": [
                    "key",
                    "name",
                    "direction",
                    "data_type",
                    "unit",
                    "topic",
                    "minimum",
                    "maximum"
                ],
                "properties": {
                    "key": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "direction": {
                        "type": "string",
                        "enum": [
                            "telemetry",
                            "command",
                            "status"
                        ],
                        "description": "telemetry = Sensor, command = Perintah, status = Status."
                    },
                    "data_type": {
                        "type": "string",
                        "enum": [
                            "integer",
                            "float",
                            "boolean",
                            "string",
                            "json"
                        ]
                    },
                    "unit": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "topic": {
                        "type": "string"
                    },
                    "minimum": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "maximum": {
                        "type": [
                            "number",
                            "null"
                        ]
                    }
                },
                "additionalProperties": false
            },
            "DeviceDetail": {
                "type": "object",
                "required": [
                    "id",
                    "project_id",
                    "name",
                    "type",
                    "location",
                    "status",
                    "status_label",
                    "last_seen_at",
                    "variables"
                ],
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "project_id": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "type": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "location": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "online",
                            "inactive",
                            "offline",
                            "never_connected"
                        ],
                        "description": "online ≤ ambang heartbeat; inactive = Tidak aktif (≤ 24 jam tanpa data); offline > 24 jam; never_connected = belum pernah ada data."
                    },
                    "status_label": {
                        "type": "string"
                    },
                    "last_seen_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "variables": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Variable"
                        }
                    }
                },
                "additionalProperties": false
            },
            "LatestValue": {
                "type": "object",
                "required": [
                    "key",
                    "name",
                    "direction",
                    "unit",
                    "value",
                    "display",
                    "received_at",
                    "quality"
                ],
                "properties": {
                    "key": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "direction": {
                        "type": "string",
                        "enum": [
                            "telemetry",
                            "command",
                            "status"
                        ]
                    },
                    "unit": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "value": {
                        "description": "Nilai bertipe: angka, true/false (ON/OFF), teks, atau objek JSON; null bila belum ada data."
                    },
                    "display": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "received_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "quality": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                },
                "additionalProperties": false
            },
            "LatestMeta": {
                "type": "object",
                "required": [
                    "device_id",
                    "status"
                ],
                "properties": {
                    "device_id": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "online",
                            "inactive",
                            "offline",
                            "never_connected"
                        ]
                    }
                },
                "additionalProperties": false
            },
            "RawPoint": {
                "type": "object",
                "required": [
                    "t",
                    "value"
                ],
                "properties": {
                    "t": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "value": {
                        "description": "Nilai bertipe."
                    }
                },
                "additionalProperties": false
            },
            "AggregatePoint": {
                "type": "object",
                "required": [
                    "t",
                    "avg",
                    "min",
                    "max",
                    "sum",
                    "count"
                ],
                "properties": {
                    "t": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Awal ember waktu (WIB)."
                    },
                    "avg": {
                        "type": "number"
                    },
                    "min": {
                        "type": "number"
                    },
                    "max": {
                        "type": "number"
                    },
                    "sum": {
                        "type": "number"
                    },
                    "count": {
                        "type": "integer"
                    }
                },
                "additionalProperties": false
            },
            "HistorySeries": {
                "type": "object",
                "required": [
                    "key",
                    "name",
                    "data_type",
                    "unit",
                    "points"
                ],
                "properties": {
                    "key": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "data_type": {
                        "type": "string"
                    },
                    "unit": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "points": {
                        "type": "array",
                        "items": {
                            "oneOf": [
                                {
                                    "$ref": "#/components/schemas/RawPoint"
                                },
                                {
                                    "$ref": "#/components/schemas/AggregatePoint"
                                }
                            ]
                        }
                    }
                },
                "additionalProperties": false
            },
            "HistoryMeta": {
                "type": "object",
                "required": [
                    "device_id",
                    "from",
                    "to",
                    "timezone",
                    "interval"
                ],
                "properties": {
                    "device_id": {
                        "type": "string"
                    },
                    "from": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "to": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "timezone": {
                        "type": "string"
                    },
                    "interval": {
                        "type": "string",
                        "enum": [
                            "raw",
                            "minute",
                            "hour",
                            "day",
                            "month"
                        ]
                    },
                    "limit": {
                        "type": "integer"
                    },
                    "truncated": {
                        "type": "boolean",
                        "description": "true bila titik lebih banyak dari limit; lanjutkan dengan from = next_from."
                    },
                    "next_from": {
                        "type": "string",
                        "format": "date-time"
                    }
                },
                "additionalProperties": false
            },
            "IngestRequest": {
                "type": "object",
                "description": "Bentuk {\"values\": {...}, \"timestamp\": ...} atau langsung pasangan variabel: nilai.",
                "properties": {
                    "values": {
                        "type": "object",
                        "additionalProperties": {
                            "type": [
                                "number",
                                "integer",
                                "boolean",
                                "string",
                                "object",
                                "array"
                            ]
                        }
                    },
                    "timestamp": {
                        "type": [
                            "string",
                            "integer"
                        ],
                        "description": "Opsional. ISO 8601 (tanpa zona = WIB) atau Unix detik; paling lama 7 hari lalu, paling jauh 5 menit ke depan."
                    }
                }
            },
            "IngestResult": {
                "type": "object",
                "required": [
                    "device_id",
                    "accepted",
                    "rejected",
                    "stored",
                    "unchanged",
                    "received_at"
                ],
                "properties": {
                    "device_id": {
                        "type": "string"
                    },
                    "accepted": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "rejected": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string"
                        },
                        "description": "Variabel yang ditolak beserta alasannya."
                    },
                    "stored": {
                        "type": "integer",
                        "description": "Baris riwayat baru (kebijakan riwayat variabel tetap berlaku)."
                    },
                    "unchanged": {
                        "type": "integer"
                    },
                    "received_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                },
                "additionalProperties": false
            },
            "CommandRequest": {
                "type": "object",
                "required": [
                    "variable",
                    "value"
                ],
                "properties": {
                    "variable": {
                        "type": "string"
                    },
                    "value": {
                        "type": [
                            "boolean",
                            "number",
                            "integer",
                            "string",
                            "object",
                            "array"
                        ],
                        "description": "ON/OFF: true/false atau 1/0; angka; teks ≤ 1.000 karakter; JSON."
                    }
                },
                "additionalProperties": false
            },
            "CommandResult": {
                "type": "object",
                "required": [
                    "device_id",
                    "variable",
                    "value",
                    "topic",
                    "broker",
                    "virtual_lab",
                    "sent_at"
                ],
                "properties": {
                    "device_id": {
                        "type": "string"
                    },
                    "variable": {
                        "type": "string"
                    },
                    "value": {
                        "type": "string",
                        "description": "Nilai yang diterbitkan ke topik command (bentuk teks, sama dengan dashboard)."
                    },
                    "topic": {
                        "type": "string"
                    },
                    "broker": {
                        "type": "boolean"
                    },
                    "virtual_lab": {
                        "type": "boolean"
                    },
                    "sent_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                },
                "additionalProperties": false
            },
            "AlertEvent": {
                "type": "object",
                "required": [
                    "id",
                    "rule",
                    "status",
                    "severity",
                    "trigger_type",
                    "device_id",
                    "variable",
                    "unit",
                    "trigger_value",
                    "started_at",
                    "acknowledged_at",
                    "resolved_at",
                    "repeat_count"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "rule": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "active",
                            "acknowledged",
                            "resolved",
                            "info"
                        ]
                    },
                    "severity": {
                        "type": "string"
                    },
                    "trigger_type": {
                        "type": "string"
                    },
                    "device_id": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "variable": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "unit": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "trigger_value": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "started_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "acknowledged_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "resolved_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "repeat_count": {
                        "type": "integer"
                    }
                },
                "additionalProperties": false
            },
            "WebhookAlertTriggered": {
                "type": "object",
                "required": [
                    "id",
                    "type",
                    "created_at",
                    "test",
                    "workspace",
                    "project",
                    "data"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "ID peristiwa — sama untuk setiap percobaan ulang; pakai untuk mengabaikan duplikat."
                    },
                    "type": {
                        "type": "string",
                        "const": "alert.triggered"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "test": {
                        "type": "boolean"
                    },
                    "workspace": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            }
                        },
                        "additionalProperties": false
                    },
                    "project": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            }
                        ]
                    },
                    "data": {
                        "type": "object",
                        "required": [
                            "rule",
                            "event",
                            "device",
                            "variable",
                            "message"
                        ],
                        "properties": {
                            "rule": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            },
                            "event": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "status",
                                    "severity",
                                    "trigger_type",
                                    "trigger_value",
                                    "resolve_value",
                                    "started_at",
                                    "resolved_at"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "status": {
                                        "type": "string"
                                    },
                                    "severity": {
                                        "type": "string"
                                    },
                                    "trigger_type": {
                                        "type": "string"
                                    },
                                    "trigger_value": {
                                        "type": [
                                            "string",
                                            "null"
                                        ]
                                    },
                                    "resolve_value": {
                                        "type": [
                                            "string",
                                            "null"
                                        ]
                                    },
                                    "started_at": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "date-time"
                                    },
                                    "resolved_at": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "date-time"
                                    }
                                },
                                "additionalProperties": false
                            },
                            "device": {
                                "oneOf": [
                                    {
                                        "type": "null"
                                    },
                                    {
                                        "type": "object",
                                        "required": [
                                            "id",
                                            "name"
                                        ],
                                        "properties": {
                                            "id": {
                                                "type": "string"
                                            },
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            }
                                        },
                                        "additionalProperties": false
                                    }
                                ]
                            },
                            "variable": {
                                "oneOf": [
                                    {
                                        "type": "null"
                                    },
                                    {
                                        "type": "object",
                                        "required": [
                                            "key",
                                            "name",
                                            "unit"
                                        ],
                                        "properties": {
                                            "key": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            },
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            },
                                            "unit": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            }
                                        },
                                        "additionalProperties": false
                                    }
                                ]
                            },
                            "message": {
                                "type": "string"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            },
            "WebhookAlertRecovered": {
                "type": "object",
                "required": [
                    "id",
                    "type",
                    "created_at",
                    "test",
                    "workspace",
                    "project",
                    "data"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "ID peristiwa — sama untuk setiap percobaan ulang; pakai untuk mengabaikan duplikat."
                    },
                    "type": {
                        "type": "string",
                        "const": "alert.recovered"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "test": {
                        "type": "boolean"
                    },
                    "workspace": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            }
                        },
                        "additionalProperties": false
                    },
                    "project": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            }
                        ]
                    },
                    "data": {
                        "type": "object",
                        "required": [
                            "rule",
                            "event",
                            "device",
                            "variable",
                            "message"
                        ],
                        "properties": {
                            "rule": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            },
                            "event": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "status",
                                    "severity",
                                    "trigger_type",
                                    "trigger_value",
                                    "resolve_value",
                                    "started_at",
                                    "resolved_at"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "status": {
                                        "type": "string"
                                    },
                                    "severity": {
                                        "type": "string"
                                    },
                                    "trigger_type": {
                                        "type": "string"
                                    },
                                    "trigger_value": {
                                        "type": [
                                            "string",
                                            "null"
                                        ]
                                    },
                                    "resolve_value": {
                                        "type": [
                                            "string",
                                            "null"
                                        ]
                                    },
                                    "started_at": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "date-time"
                                    },
                                    "resolved_at": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "date-time"
                                    }
                                },
                                "additionalProperties": false
                            },
                            "device": {
                                "oneOf": [
                                    {
                                        "type": "null"
                                    },
                                    {
                                        "type": "object",
                                        "required": [
                                            "id",
                                            "name"
                                        ],
                                        "properties": {
                                            "id": {
                                                "type": "string"
                                            },
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            }
                                        },
                                        "additionalProperties": false
                                    }
                                ]
                            },
                            "variable": {
                                "oneOf": [
                                    {
                                        "type": "null"
                                    },
                                    {
                                        "type": "object",
                                        "required": [
                                            "key",
                                            "name",
                                            "unit"
                                        ],
                                        "properties": {
                                            "key": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            },
                                            "name": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            },
                                            "unit": {
                                                "type": [
                                                    "string",
                                                    "null"
                                                ]
                                            }
                                        },
                                        "additionalProperties": false
                                    }
                                ]
                            },
                            "message": {
                                "type": "string"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            },
            "WebhookDeviceOnline": {
                "type": "object",
                "required": [
                    "id",
                    "type",
                    "created_at",
                    "test",
                    "workspace",
                    "project",
                    "data"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "ID peristiwa — sama untuk setiap percobaan ulang; pakai untuk mengabaikan duplikat."
                    },
                    "type": {
                        "type": "string",
                        "const": "device.online"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "test": {
                        "type": "boolean"
                    },
                    "workspace": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            }
                        },
                        "additionalProperties": false
                    },
                    "project": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            }
                        ]
                    },
                    "data": {
                        "type": "object",
                        "required": [
                            "device",
                            "status",
                            "previous_status",
                            "last_seen_at"
                        ],
                        "properties": {
                            "device": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            },
                            "status": {
                                "type": "string",
                                "enum": [
                                    "online",
                                    "inactive"
                                ]
                            },
                            "previous_status": {
                                "type": "string",
                                "enum": [
                                    "online",
                                    "inactive"
                                ]
                            },
                            "last_seen_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            },
            "WebhookDeviceInactive": {
                "type": "object",
                "required": [
                    "id",
                    "type",
                    "created_at",
                    "test",
                    "workspace",
                    "project",
                    "data"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "ID peristiwa — sama untuk setiap percobaan ulang; pakai untuk mengabaikan duplikat."
                    },
                    "type": {
                        "type": "string",
                        "const": "device.inactive"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "test": {
                        "type": "boolean"
                    },
                    "workspace": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            }
                        },
                        "additionalProperties": false
                    },
                    "project": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            }
                        ]
                    },
                    "data": {
                        "type": "object",
                        "required": [
                            "device",
                            "status",
                            "previous_status",
                            "last_seen_at"
                        ],
                        "properties": {
                            "device": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            },
                            "status": {
                                "type": "string",
                                "enum": [
                                    "online",
                                    "inactive"
                                ]
                            },
                            "previous_status": {
                                "type": "string",
                                "enum": [
                                    "online",
                                    "inactive"
                                ]
                            },
                            "last_seen_at": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            },
            "WebhookDataReceived": {
                "type": "object",
                "required": [
                    "id",
                    "type",
                    "created_at",
                    "test",
                    "workspace",
                    "project",
                    "data"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "ID peristiwa — sama untuk setiap percobaan ulang; pakai untuk mengabaikan duplikat."
                    },
                    "type": {
                        "type": "string",
                        "const": "data.received"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "test": {
                        "type": "boolean"
                    },
                    "workspace": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            }
                        },
                        "additionalProperties": false
                    },
                    "project": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            }
                        ]
                    },
                    "data": {
                        "type": "object",
                        "required": [
                            "device",
                            "values",
                            "source"
                        ],
                        "properties": {
                            "device": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            },
                            "values": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "required": [
                                        "key",
                                        "value",
                                        "unit",
                                        "received_at"
                                    ],
                                    "properties": {
                                        "key": {
                                            "type": "string"
                                        },
                                        "value": {
                                            "description": "Nilai bertipe."
                                        },
                                        "unit": {
                                            "type": [
                                                "string",
                                                "null"
                                            ]
                                        },
                                        "received_at": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "additionalProperties": false
                                }
                            },
                            "source": {
                                "type": "string",
                                "enum": [
                                    "mqtt",
                                    "http_api",
                                    "mixed"
                                ],
                                "description": "mqtt, http_api, atau mixed (keduanya dalam satu jendela)."
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            },
            "WebhookPing": {
                "type": "object",
                "required": [
                    "id",
                    "type",
                    "created_at",
                    "test",
                    "workspace",
                    "project",
                    "data"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "ID peristiwa — sama untuk setiap percobaan ulang; pakai untuk mengabaikan duplikat."
                    },
                    "type": {
                        "type": "string",
                        "const": "ping"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "test": {
                        "type": "boolean"
                    },
                    "workspace": {
                        "type": "object",
                        "required": [
                            "id"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            }
                        },
                        "additionalProperties": false
                    },
                    "project": {
                        "oneOf": [
                            {
                                "type": "null"
                            },
                            {
                                "type": "object",
                                "required": [
                                    "id",
                                    "name"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "additionalProperties": false
                            }
                        ]
                    },
                    "data": {
                        "type": "object",
                        "required": [
                            "message"
                        ],
                        "properties": {
                            "message": {
                                "type": "string"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "additionalProperties": false
            }
        }
    }
}