Nodeflux Central
Notification Channels

API Reference — Notification Channels

Endpoint untuk mengelola Notification Channel, antrian pengiriman notifikasi, dan log pengiriman.

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.


Channel CRUD

Endpoint utama untuk membuat, membaca, memperbarui, dan menghapus Notification Channel.

GET
/api/notification-channels

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

page?integer

Nomor halaman, dimulai dari 1.

Default1
limit?integer

Jumlah data per halaman.

Default20
search?string

Filter berdasarkan nama channel.

provider?string

Filter berdasarkan tipe provider.

Value in"webhook" | "discord" | "telegram" | "email"
is_active?boolean

Filter berdasarkan status aktif channel.

Response Body

application/json

application/json

curl -X GET "https://lenz.example.com/api/notification-channels"
{  "ok": true,  "message": "success",  "result": [    {      "id": 1,      "name": "Alert Tim Security - Telegram",      "provider": "telegram",      "config": {        "bot_token": "123456789:ABCdef...",        "chat_id": "-100123456789"      },      "is_active": true,      "subject_template": null,      "body_template": "*{{severity}}* Alert\n\nLocation: {{stream_name}}\nLabel: {{label}}\nTime: {{timestamp}}\nRule: {{alert_rule}}",      "rate_limit": 0,      "batch_enabled": false,      "batch_window_seconds": 0,      "batch_max_size": 0,      "created_at": "2026-04-01T08:00:00Z",      "updated_at": null,      "deleted_at": null    }  ],  "total": 1}
{  "ok": false,  "message": "invalid request"}
POST
/api/notification-channels

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

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/notification-channels" \  -H "Content-Type: application/json" \  -d '{    "name": "Alert Tim Security - Telegram",    "provider": "telegram",    "config": {      "bot_token": "123456789:ABCdefGHI...",      "chat_id": "-100123456789"    },    "body_template": "*{{severity}}* Alert\\n\\nLocation: {{stream_name}}\\nLabel: {{label}}\\nTime: {{timestamp}}\\nRule: {{alert_rule}}",    "is_active": true  }'
{  "ok": true,  "message": "success",  "result": {    "id": 1,    "name": "Alert Tim Security - Telegram",    "provider": "telegram",    "config": {      "bot_token": "123456789:ABCdefGHI...",      "chat_id": "-100123456789"    },    "is_active": true,    "subject_template": null,    "body_template": "*{{severity}}* Alert\n\nLocation: {{stream_name}}\nLabel: {{label}}\nTime: {{timestamp}}\nRule: {{alert_rule}}",    "rate_limit": 0,    "batch_enabled": false,    "batch_window_seconds": 0,    "batch_max_size": 0,    "created_at": "2026-04-30T10:00:00Z",    "updated_at": null,    "deleted_at": null  }}
{  "ok": false,  "message": "name is required"}
{  "ok": false,  "message": "invalid request"}
GET
/api/notification-channels/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik Notification Channel.

Response Body

application/json

application/json

curl -X GET "https://lenz.example.com/api/notification-channels/0"
{  "ok": true,  "message": "success",  "result": {    "id": 1,    "name": "Alert Tim Security - Telegram",    "provider": "telegram",    "config": {      "bot_token": "123456789:ABCdef...",      "chat_id": "-100123456789"    },    "is_active": true,    "subject_template": null,    "body_template": "*{{severity}}* Alert\n\nLocation: {{stream_name}}\nLabel: {{label}}\nTime: {{timestamp}}\nRule: {{alert_rule}}",    "rate_limit": 0,    "batch_enabled": false,    "batch_window_seconds": 0,    "batch_max_size": 0,    "created_at": "2026-04-01T08:00:00Z",    "updated_at": "2026-04-30T10:30:00Z",    "deleted_at": null  }}
{  "ok": false,  "message": "channel not found"}
PUT
/api/notification-channels/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik Notification Channel.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X PUT "https://lenz.example.com/api/notification-channels/0" \  -H "Content-Type: application/json" \  -d '{    "name": "Alert Tim Security - Telegram (Updated)",    "is_active": false,    "body_template": "{{severity}} di {{stream_name}} — {{timestamp}}"  }'
{  "ok": true,  "message": "success",  "result": {    "id": 1,    "name": "Alert Tim Security - Telegram (Updated)",    "provider": "telegram",    "config": {      "bot_token": "123456789:ABCdef...",      "chat_id": "-100123456789"    },    "is_active": false,    "subject_template": null,    "body_template": "{{severity}} di {{stream_name}} — {{timestamp}}",    "rate_limit": 0,    "batch_enabled": false,    "batch_window_seconds": 0,    "batch_max_size": 0,    "created_at": "2026-04-01T08:00:00Z",    "updated_at": "2026-04-30T11:00:00Z",    "deleted_at": null  }}
{  "ok": false,  "message": "invalid request"}
{  "ok": false,  "message": "invalid request"}
DELETE
/api/notification-channels/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik Notification Channel.

Response Body

application/json

application/json

curl -X DELETE "https://lenz.example.com/api/notification-channels/0"
{  "ok": true,  "message": "success"}
{  "ok": false,  "message": "invalid request"}

Test Notifikasi

Kirim notifikasi uji ke channel menggunakan data sampel untuk memverifikasi konfigurasi sebelum digunakan pada Alert Rule.

POST
/api/notification-channels/{id}/test

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik Notification Channel yang akan diuji.

Response Body

application/json

application/json

application/json

curl -X POST "https://lenz.example.com/api/notification-channels/0/test"
{  "ok": true,  "message": "test notification sent successfully"}
{  "ok": false,  "message": "channel is not active"}
{  "ok": false,  "message": "invalid request"}

Variabel Template

Ambil daftar variabel dinamis yang tersedia untuk digunakan dalam template pesan notifikasi.

GET
/api/notification-channels/template-variables

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

event_type?string

Filter variabel berdasarkan tipe event tertentu, misalnya alert_history.

Response Body

application/json

curl -X GET "https://lenz.example.com/api/notification-channels/template-variables?event_type=alert_history"
{  "ok": true,  "message": "success",  "data": {    "event_types": [      {        "type": "alert_history",        "label": "Alert History",        "description": "Dipicu saat sebuah alert rule menghasilkan event baru.",        "groups": [          {            "name": "Alert Info",            "variables": [              {                "key": "severity",                "description": "Tingkat keparahan alert",                "type": "string",                "example": "CRITICAL"              },              {                "key": "stream_name",                "description": "Nama stream atau kamera",                "type": "string",                "example": "Gate A - Main Entrance"              },              {                "key": "label",                "description": "Label event yang terdeteksi",                "type": "string",                "example": "VIP Detected"              },              {                "key": "timestamp",                "description": "Waktu kejadian",                "type": "datetime",                "example": "2026-01-26 14:30:00"              },              {                "key": "alert_rule",                "description": "Nama alert rule yang terpicu",                "type": "string",                "example": "VIP Detection"              },              {                "key": "event_id",                "description": "ID unik event",                "type": "string",                "example": "evt_123456"              },              {                "key": "status",                "description": "Status event",                "type": "string",                "example": "match"              }            ]          }        ]      }    ]  }}

Antrian & Monitoring

Endpoint untuk memantau status antrian notifikasi dan mengelola item yang gagal dikirim.

GET
/api/notification-queue/stats

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Response Body

application/json

curl -X GET "https://lenz.example.com/api/notification-queue/stats"
{  "ok": true,  "message": "success",  "result": {    "pending": 3,    "processing": 1,    "sent_today": 142,    "failed_today": 2,    "dead_letter": 0  }}
GET
/api/notification-queue/dead-letter

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

page?integer

Nomor halaman.

Default1
limit?integer

Jumlah data per halaman.

Default20

Response Body

application/json

curl -X GET "https://lenz.example.com/api/notification-queue/dead-letter"
{  "ok": true,  "message": "success",  "result": [    {      "id": 500,      "channel_id": 2,      "event_type": "alert_history",      "payload": {        "severity": "HIGH",        "stream_name": "Gate B",        "label": "Unauthorized Person",        "timestamp": "2026-04-30 07:00:00"      },      "status": "dead",      "attempts": 5,      "max_attempts": 5,      "next_retry_at": null,      "error_message": "connection refused: dial tcp 10.0.0.5:465: connect: connection refused",      "created_at": "2026-04-30T07:00:01Z",      "processed_at": null    }  ]}
POST
/api/notification-queue/{id}/retry

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID item outbox yang akan di-retry.

Response Body

application/json

application/json

curl -X POST "https://lenz.example.com/api/notification-queue/0/retry"
{  "ok": true,  "message": "success"}
{  "ok": false,  "message": "invalid request"}

Log Notifikasi

Riwayat lengkap setiap upaya pengiriman notifikasi beserta status, kode respons, dan durasi pengiriman.

GET
/api/notification-logs

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

page?integer

Nomor halaman.

Default1
limit?integer

Jumlah data per halaman.

Default20
filter[channel_id]?integer

Filter berdasarkan ID channel.

filter[status]?string

Filter berdasarkan status pengiriman.

Value in"sent" | "failed" | "dead"
filter[provider]?string

Filter berdasarkan tipe provider.

Value in"webhook" | "discord" | "telegram" | "email"
filter[event_type]?string

Filter berdasarkan tipe event.

Response Body

application/json

curl -X GET "https://lenz.example.com/api/notification-logs?filter%5Bevent_type%5D=alert_history"
{  "ok": true,  "message": "success",  "result": [    {      "id": 1001,      "outbox_id": 500,      "channel_id": 1,      "provider": "telegram",      "event_type": "alert_history",      "status": "sent",      "response_code": 200,      "response_body": "{\"ok\":true,\"result\":{\"message_id\":42}}",      "duration_ms": 312,      "created_at": "2026-04-30T08:15:23Z"    }  ],  "total": 1}

On this page