API Reference — Sites
Endpoint untuk mengelola Site (lokasi fisik), hierarki parent-child, penetapan stream, dan pembaruan batch.
← Kembali ke Sites
Panduan operator: tambah, edit, hapus, hierarki, dan tree view site.
Streams
Kelola stream kamera dan tetapkan ke site untuk pengelompokan lokasi.
Semua endpoint memerlukan header Authorization: Bearer <token>. Basis URL mengikuti variabel lingkungan VITE_API_URL yang dikonfigurasi pada instalasi Lenz. Jika Anda belum punya token, lihat halaman Otentikasi.
CRUD Site
Endpoint utama untuk membuat, membaca, memperbarui, dan menghapus site. Site diidentifikasi secara unik oleh id (integer) yang bersifat permanen setelah site dibuat.
Authorization
bearerAuth In: header
Query Parameters
ID instance tertentu pada mode Federation. Kosongkan untuk instance lokal.
Jika true, agregasi site dari seluruh instance Federation.
Response Body
application/json
curl -X GET "https://lenz.example.com/api/sites"{ "ok": true, "message": "success", "sites": [ { "id": 1, "name": "Gedung Utama", "parent_id": null, "order": 0, "created_at": "2025-01-15T08:00:00Z", "created_by": 10, "updated_at": "2025-01-15T08:00:00Z", "instance": "local" }, { "id": 2, "name": "Lantai 1", "parent_id": 1, "order": 0, "created_at": "2025-01-15T08:05:00Z", "created_by": 10, "updated_at": "2025-01-15T08:05:00Z", "instance": "local" }, { "id": 3, "name": "Lobby Depan", "parent_id": 2, "order": 0, "created_at": "2025-01-15T08:10:00Z", "created_by": 10, "updated_at": "2025-01-15T08:10:00Z", "instance": "local" } ]}Authorization
bearerAuth In: header
Query Parameters
ID instance pada mode Federation.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://lenz.example.com/api/sites" \ -H "Content-Type: application/json" \ -d '{ "name": "Lantai 1", "parent_id": 1 }'{ "ok": true, "message": "string", "site": { "id": 3, "name": "Lobby Depan", "parent_id": 2, "order": 0, "created_at": "2025-01-15T08:10:00Z", "created_by": 10, "updated_at": "2025-01-15T08:10:00Z", "instance": "local" }}Authorization
bearerAuth In: header
Path Parameters
ID numerik site
Query Parameters
ID instance pada mode Federation (opsional).
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X PUT "https://lenz.example.com/api/sites/2" \ -H "Content-Type: application/json" \ -d '{ "name": "Lantai 1 (Revisi)" }'{ "ok": true, "message": "string", "site": { "id": 3, "name": "Lobby Depan", "parent_id": 2, "order": 0, "created_at": "2025-01-15T08:10:00Z", "created_by": 10, "updated_at": "2025-01-15T08:10:00Z", "instance": "local" }}Authorization
bearerAuth In: header
Path Parameters
ID numerik site
Query Parameters
ID instance pada mode Federation (opsional).
Response Body
application/json
curl -X DELETE "https://lenz.example.com/api/sites/2"{ "ok": true, "message": "Site berhasil dihapus"}Hierarki & Pembaruan Batch
Endpoint untuk memperbarui beberapa site sekaligus — berguna untuk reorganisasi hierarki skala besar, pemindahan parent massal, atau pembaruan urutan tampilan antar sibling.
Authorization
bearerAuth In: header
Query Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X PATCH "https://lenz.example.com/api/sites/batch" \ -H "Content-Type: application/json" \ -d '{ "sites": [ { "id": 2, "order": 0 }, { "id": 4, "order": 1 }, { "id": 5, "parent_id": 2, "order": 0 } ] }'{ "ok": true, "message": "success"}Penetapan & Pengurutan Stream
Endpoint untuk menetapkan stream ke site tertentu dan mengatur urutan tampilan stream di dalam sebuah site. Stream yang ditetapkan ke child site otomatis ditampilkan (rolled up) pada parent site-nya di halaman monitoring.
Authorization
bearerAuth In: header
Path Parameters
ID site tujuan
Query Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
ID stream yang akan ditetapkan ke site ini.
Response Body
application/json
curl -X POST "https://lenz.example.com/api/sites/3/assign-stream" \ -H "Content-Type: application/json" \ -d '{ "stream_id": "abc123def456" }'{ "ok": true, "message": "success"}Authorization
bearerAuth In: header
Path Parameters
ID site yang stream-nya akan diurutkan
Query Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X PUT "https://lenz.example.com/api/sites/3/streams/order" \ -H "Content-Type: application/json" \ -d '{ "stream_ids": [ "abc123", "def456", "ghi789" ] }'{ "ok": true, "message": "success"}