API Reference — Notification Channels
Endpoint untuk mengelola Notification Channel, antrian pengiriman notifikasi, dan log pengiriman.
← Kembali ke Notification Channels
Panduan operator: tambah, konfigurasi, dan kelola channel notifikasi.
Otentikasi
Cara memperoleh dan menggunakan Bearer token JWT.
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.
Authorization
bearerAuth In: header
Query Parameters
Nomor halaman, dimulai dari 1.
1Jumlah data per halaman.
20Filter berdasarkan nama channel.
Filter berdasarkan tipe provider.
"webhook" | "discord" | "telegram" | "email"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"}Authorization
bearerAuth 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"}Authorization
bearerAuth In: header
Path Parameters
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"}Authorization
bearerAuth In: header
Path Parameters
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"}Authorization
bearerAuth In: header
Path Parameters
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.
Authorization
bearerAuth In: header
Path Parameters
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.
Authorization
bearerAuth In: header
Query Parameters
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.
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 }}Authorization
bearerAuth In: header
Query Parameters
Nomor halaman.
1Jumlah data per halaman.
20Response 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 } ]}Authorization
bearerAuth In: header
Path Parameters
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.
Authorization
bearerAuth In: header
Query Parameters
Nomor halaman.
1Jumlah data per halaman.
20Filter berdasarkan ID channel.
Filter berdasarkan status pengiriman.
"sent" | "failed" | "dead"Filter berdasarkan tipe provider.
"webhook" | "discord" | "telegram" | "email"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}Notification Channels
Konfigurasi tujuan pengiriman alert — Email, Webhook, Telegram, dan Discord — untuk sistem notifikasi Lenz Dashboard.
Search (Smart Search)
Cari event, stream, site, dan resource lain secara terpadu menggunakan bahasa alami — lintas kamera dan seluruh sistem — beserta referensi API endpoint Smart Search.