Nodeflux Central
Alert Rules

API Reference — Alert

Endpoint untuk mengelola Alert Rule dan Alert Type — buat, baca, perbarui, dan hapus konfigurasi aturan notifikasi berbasis event AI Visionaire.

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.


Alert Rule

Endpoint utama untuk membuat, membaca, memperbarui, dan menghapus Alert Rule. Setiap rule menghubungkan kondisi trigger berbasis event AI dengan satu atau lebih channel notifikasi.

GET
/api/alert-rules

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

page?integer

Nomor halaman, dimulai dari 1

Default1
limit?integer

Jumlah data per halaman

Default10
search?string

Pencarian berdasarkan nama alert rule

filter[active]?string

Filter berdasarkan status aktif: true, false, atau kosong untuk semua

Value in"true" | "false" | ""
instance?string

ID instance pada mode federation (opsional)

Response Body

application/json

application/json

curl -X GET "https://lenz.example.com/api/alert-rules"
{  "ok": true,  "message": "success",  "result": {    "limit": 10,    "current_page": 1,    "total_data": 2,    "total_page": 1,    "offset": 0,    "alert_rules": [      {        "id": 1,        "name": "Deteksi Blacklist Pintu Utama",        "description": "Notifikasi jika wajah blacklist terdeteksi",        "active": true,        "analytic_id": "FR",        "alert_type_id": 1,        "rules": [          {            "attribute": "status",            "operator": "==",            "value": "blacklist",            "streams": [              "stream-uuid-001"            ],            "logic": "AND",            "auto_include_streams": false          }        ],        "notification_channel_ids": [          3,          7        ],        "recipient_rules": null,        "created_at": "2024-06-01T08:00:00Z",        "updated_at": "2024-06-01T09:00:00Z",        "deleted_at": null      }    ]  }}
{  "ok": false,  "message": "unauthorized"}
POST
/api/alert-rules

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

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

application/json

application/json

curl -X POST "https://lenz.example.com/api/alert-rules" \  -H "Content-Type: application/json" \  -d '{    "name": "Deteksi Blacklist Pintu Utama",    "description": "Kirim notifikasi jika wajah dengan status blacklist terdeteksi",    "active": true,    "analytic_id": "FR",    "alert_type_id": 1,    "rules": [      {        "attribute": "status",        "operator": "==",        "value": "blacklist",        "streams": [          "stream-uuid-001",          "stream-uuid-002"        ],        "logic": "AND",        "auto_include_streams": false      }    ],    "notification_channel_ids": [      3    ],    "recipient_rules": null  }'
{  "ok": true,  "message": "alert rule created successfully"}
{  "ok": false,  "message": "invalid request body"}
{  "ok": false,  "message": "unauthorized"}
GET
/api/alert-rules/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik alert rule

Query Parameters

instance?string

ID instance pada mode federation (opsional)

Response Body

application/json

application/json

curl -X GET "https://lenz.example.com/api/alert-rules/0"
{  "ok": true,  "message": "success",  "alert_rule": {    "id": 1,    "name": "Deteksi Blacklist Pintu Utama",    "description": "Notifikasi jika wajah blacklist terdeteksi",    "active": true,    "analytic_id": "FR",    "alert_type_id": 1,    "rules": [      {        "attribute": "status",        "operator": "==",        "value": "blacklist",        "streams": [          "stream-uuid-001"        ],        "logic": "AND",        "auto_include_streams": false      }    ],    "notification_channel_ids": [      3,      7    ],    "recipient_rules": [      {        "attribute": "role_id",        "operator": "==",        "value": "2"      }    ],    "created_at": "2024-06-01T08:00:00Z",    "updated_at": "2024-06-01T09:00:00Z",    "deleted_at": null  }}
{  "ok": false,  "message": "alert rule not found"}
PUT
/api/alert-rules/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik alert rule

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

application/json

curl -X PUT "https://lenz.example.com/api/alert-rules/0" \  -H "Content-Type: application/json" \  -d '{    "active": false  }'
{  "ok": true,  "message": "alert rule updated successfully"}
{  "ok": false,  "message": "alert rule not found"}
DELETE
/api/alert-rules/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik alert rule

Query Parameters

instance?string

ID instance pada mode federation (opsional)

Response Body

application/json

application/json

curl -X DELETE "https://lenz.example.com/api/alert-rules/0"
{  "ok": true,  "message": "alert rule deleted successfully"}
{  "ok": false,  "message": "alert rule not found"}

Alert Type

Endpoint untuk membaca dan memperbarui konfigurasi Alert Type. Alert Type menentukan level keparahan visual (CRITICAL, WARNING, INFORMATION), warna tampilan, durasi notifikasi, dan suara opsional yang diputar saat alert terpicu di dashboard.

GET
/api/alert-type

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

instance?string

ID instance pada mode federation (opsional)

Response Body

application/json

application/json

curl -X GET "https://lenz.example.com/api/alert-type"
{  "ok": true,  "message": "success",  "data": [    {      "id": 1,      "level": "CRITICAL",      "color": "#FF0000",      "duration_ms": 10000,      "sound_data": null,      "sound_updated_at": null,      "instance": "core",      "created_at": "2024-01-01T00:00:00Z",      "updated_at": "2024-01-01T00:00:00Z"    },    {      "id": 2,      "level": "WARNING",      "color": "#FFA500",      "duration_ms": 7000,      "sound_data": null,      "sound_updated_at": null,      "instance": "core",      "created_at": "2024-01-01T00:00:00Z",      "updated_at": "2024-01-01T00:00:00Z"    },    {      "id": 3,      "level": "INFORMATION",      "color": "#0077FF",      "duration_ms": 5000,      "sound_data": null,      "sound_updated_at": null,      "instance": "core",      "created_at": "2024-01-01T00:00:00Z",      "updated_at": "2024-01-01T00:00:00Z"    }  ]}
{  "ok": false,  "message": "unauthorized"}
GET
/api/alert-type/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik Alert Type

Response Body

application/json

application/json

curl -X GET "https://lenz.example.com/api/alert-type/0"
{  "ok": true,  "message": "success",  "data": {    "id": 1,    "level": "CRITICAL",    "color": "#FF0000",    "duration_ms": 10000,    "sound_data": null,    "sound_updated_at": null,    "instance": "core",    "created_at": "2024-01-01T00:00:00Z",    "updated_at": "2024-01-01T00:00:00Z"  }}
{  "ok": false,  "message": "alert type not found"}
PUT
/api/alert-type/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik Alert Type

Request Body

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X PUT "https://lenz.example.com/api/alert-type/0" \  -H "Content-Type: application/json" \  -d '{    "color": "#FF8C00",    "duration_ms": 8000  }'
{  "ok": true,  "message": "alert type updated successfully",  "data": {    "id": 2,    "level": "WARNING",    "color": "#FF8C00",    "duration_ms": 8000,    "sound_data": null,    "sound_updated_at": null,    "instance": "core",    "created_at": "2024-01-01T00:00:00Z",    "updated_at": "2024-06-01T12:00:00Z"  }}

On this page