Nodeflux Central
Sites

API Reference — Sites

Endpoint untuk mengelola Site (lokasi fisik), hierarki parent-child, penetapan stream, dan pembaruan batch.

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.

Daftar Site

GET
/api/sites

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

instance?string

ID instance tertentu pada mode Federation. Kosongkan untuk instance lokal.

is_aggregated?boolean

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"    }  ]}

Tambah Site

POST
/api/sites

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

instance?string

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"  }}

Perbarui Site

PUT
/api/sites/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik site

Query Parameters

instance?string

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"  }}

Hapus Site

DELETE
/api/sites/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik site

Query Parameters

instance?string

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.

Pembaruan Batch Site

PATCH
/api/sites/batch

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

instance?string

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.

Tetapkan Stream ke Site

POST
/api/sites/{id}/assign-stream

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID site tujuan

Query Parameters

instance?string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

stream_id*string

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"}

Atur Urutan Stream dalam Site

PUT
/api/sites/{id}/streams/order

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID site yang stream-nya akan diurutkan

Query Parameters

instance?string

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"}

On this page