API Reference — Alert History
Endpoint untuk mengambil daftar alert, detail, memperbarui status follow-up, dan mengekspor data Alert History.
← Kembali ke Alert History
Panduan operator: filter, follow-up, dan ekspor data alert.
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 memiliki token, lihat halaman Otentikasi.
Daftar & Detail Alert
Endpoint utama untuk mengambil daftar alert yang telah ter-trigger dan detail satu alert berdasarkan ID-nya.
Authorization
bearerAuth In: header
Query Parameters
Kursor pagination untuk memuat halaman berikutnya atau sebelumnya. Ambil dari field next_cursor atau prev_cursor di respons sebelumnya. Hilangkan parameter ini untuk halaman pertama.
Jumlah item per halaman. Maksimum: 100.
201 <= value <= 100Jika true, respons akan menyertakan total keseluruhan data yang cocok. Mengaktifkan mode cursor dan membutuhkan query COUNT tambahan.
falseNomor halaman untuk mode offset-based pagination (1-indexed). Digunakan saat mode cursor tidak diaktifkan.
11 <= valueSet ke cursor untuk secara eksplisit menggunakan cursor-based pagination.
"cursor"Urutan berdasarkan waktu pembuatan alert.
"desc""asc" | "desc"Urutan berdasarkan tingkat keparahan alert.
"asc" | "desc"Pencarian teks bebas pada alertable_id, nama Alert Rule, atau nama stream.
Batas awal rentang waktu dalam format ISO 8601 / RFC 3339.
date-timeBatas akhir rentang waktu dalam format ISO 8601 / RFC 3339.
date-timeFilter tingkat keparahan. Dapat berisi beberapa nilai dipisahkan koma.
Filter status follow-up. Dapat berisi beberapa nilai dipisahkan koma.
Filter berdasarkan ID Alert Rule tertentu.
Filter berdasarkan satu atau beberapa Stream ID, dipisahkan koma.
Filter berdasarkan ID site. Akan menampilkan alert dari semua stream yang berada di site tersebut.
Filter berdasarkan tipe sumber alert.
"event" | "manual" | "system" | "scheduled" | "external"Timezone klien (identifikasi IANA) untuk interpretasi filter tanggal.
"UTC"ID instance Raisa Gateway. Digunakan dalam mode Federation untuk mengambil alert dari instance tertentu.
Response Body
application/json
application/json
application/json
application/json
curl -X GET "https://lenz.example.com/api/alert-history"{ "ok": true, "message": "successfully get alert history list", "data": [ { "id": 1042, "alertable_id": "event_stream-uuid-xyz_1746000898", "alertable_type": "event", "alert_rule_id": 7, "severity": "critical", "follow_up_status": "not_followed_up", "follow_up_notes": null, "created_at": "2025-04-30T08:15:00Z", "updated_at": null, "instance": null, "alert_rule": { "id": 7, "name": "Deteksi Wajah Tidak Dikenal", "description": "Alert untuk wajah yang tidak terdaftar di enrollment", "active": true, "analytic_id": "FR" }, "event": { "id": 5801, "analytic_id": "FR", "stream_id": "stream-uuid-xyz", "stream_name": "Pintu Masuk Utama", "primary_image": "<base64-encoded-image>", "label": "Unknown", "result": "unknown", "event_time": "2025-04-30T08:14:58Z", "created_at": "2025-04-30T08:14:59Z" } } ], "pagination": { "limit": 20, "has_next": true, "has_prev": false, "next_cursor": "eyJ0IjoiMjAyNS0wNC0zMFQwODoxNTowMFoiLCJpZCI6IjEwMzAifQ==", "prev_cursor": null, "total": null }}{ "ok": false, "code": "bad-request", "errors": [ "invalid cursor format" ], "message": "Invalid query parameters"}{ "ok": false, "code": "unauthorized", "message": "Authentication required"}{ "ok": false, "code": "forbidden", "message": "Access denied: alert_history permission required"}Authorization
bearerAuth In: header
Path Parameters
ID numerik alert history.
Query Parameters
ID instance Raisa Gateway. Digunakan dalam mode Federation.
Response Body
application/json
application/json
curl -X GET "https://lenz.example.com/api/alert-history/1042"{ "ok": true, "message": "successfully get alert history detail", "data": { "id": 1042, "alertable_id": "event_stream-uuid-xyz_1746000898", "alertable_type": "event", "alert_rule_id": 7, "severity": "critical", "follow_up_status": "not_followed_up", "follow_up_notes": null, "created_at": "2025-04-30T08:15:00Z", "updated_at": null, "instance": null, "alert_rule": { "id": 7, "name": "Deteksi Wajah Tidak Dikenal", "description": "Alert untuk wajah yang tidak terdaftar di enrollment", "active": true, "analytic_id": "FR" }, "event": { "id": 5801, "analytic_id": "FR", "stream_id": "stream-uuid-xyz", "stream_name": "Pintu Masuk Utama", "stream_latitude": -6.2088, "stream_longitude": 106.8456, "primary_image": "<base64-encoded-image>", "secondary_image": null, "label": "Unknown", "result": "unknown", "location": "Lantai 1, Gedung A", "status": "active", "logic": "face_recognition", "event_time": "2025-04-30T08:14:58Z", "created_at": "2025-04-30T08:14:59Z", "pipeline_event_id": "event_stream-uuid-xyz_1746000898" } }}{ "ok": false, "code": "not-found", "message": "Alert history record not found"}Authorization
bearerAuth In: header
Path Parameters
Tipe entitas alertable.
"event" | "manual" | "system" | "scheduled" | "external"ID unik entitas yang memicu alert.
Query Parameters
Timezone klien (identifikasi IANA).
"UTC"Response Body
application/json
application/json
application/json
curl -X GET "https://lenz.example.com/api/alert-history/by-alertable/event/event_stream-uuid-xyz_1746000898"{ "ok": true, "message": "successfully get alert history detail by alertable", "data": { "id": 1042, "alertable_id": "event_stream-uuid-xyz_1746000898", "alertable_type": "event", "alert_rule_id": 7, "severity": "critical", "follow_up_status": "not_followed_up", "follow_up_notes": null, "created_at": "2025-04-30T08:15:00Z", "updated_at": null, "instance": null, "alert_rule": { "id": 7, "name": "Deteksi Wajah Tidak Dikenal", "description": "Alert untuk wajah yang tidak terdaftar di enrollment", "active": true, "analytic_id": "FR" }, "event": { "id": 5801, "analytic_id": "FR", "stream_id": "stream-uuid-xyz", "stream_name": "Pintu Masuk Utama", "label": "Unknown", "result": "unknown", "event_time": "2025-04-30T08:14:58Z", "created_at": "2025-04-30T08:14:59Z" } }}{ "ok": false, "code": "bad-request", "errors": [ "invalid alertable_type" ], "message": "Invalid alertable_type. Must be one of: event, manual, system, scheduled, external"}{ "ok": false, "code": "not-found", "message": "Alert history record not found for the specified alertable_id and alertable_type"}Follow-up
Endpoint untuk memperbarui status follow-up satu alert history. Digunakan baik untuk menandai alert sebagai sudah ditangani maupun membatalkan tanda tersebut.
Authorization
bearerAuth In: header
Path Parameters
ID numerik alert history.
Query Parameters
ID instance Raisa Gateway. Digunakan dalam mode Federation.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
curl -X PATCH "https://lenz.example.com/api/alert-history/1042/follow-up-status" \ -H "Content-Type: application/json" \ -d '{ "follow_up_status": "followed_up", "follow_up_notes": "Sudah diperiksa oleh tim keamanan pukul 09.00 WIB" }'{ "ok": true, "message": "follow up status updated successfully"}{ "ok": false, "code": "bad-request", "message": "Invalid follow_up_status value"}{ "ok": false, "code": "not-found", "message": "Alert history record not found"}Ekspor
Endpoint untuk mengekspor data alert history secara asinkron ke format PDF atau Excel. Alur ekspor:
- Panggil Mulai Job Ekspor untuk memulai proses di sisi server. Respons berisi
job_id. - Polling Status Job Ekspor menggunakan
job_idhinggastatusbernilaicompleted. - Panggil Unduh Hasil Ekspor untuk mengunduh file binary.
- (Opsional) Panggil Batalkan Job Ekspor untuk membatalkan proses yang masih berjalan.
Ekspor dalam jumlah besar (ribuan alert dengan opsi include_images: true) dapat membutuhkan waktu lebih lama dan menghasilkan file berukuran signifikan. Gunakan filter rentang tanggal untuk membatasi cakupan data sebelum mengekspor.
Authorization
bearerAuth In: header
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/alert-history/export" \ -H "Content-Type: application/json" \ -d '{ "format": "excel", "scope": "all", "timezone": "Asia/Jakarta", "include_images": false, "filters": { "created_from": "2025-04-01T00:00:00Z", "created_to": "2025-04-30T23:59:59Z", "severities": [ "critical", "warning" ] } }'{ "ok": true, "message": "Export job started", "data": { "job_id": "export-job-uuid-abc123", "status": "pending", "estimated_time_seconds": 30, "total_records": 500 }}Authorization
bearerAuth In: header
Path Parameters
ID job ekspor yang dikembalikan oleh endpoint Mulai Job Ekspor.
Response Body
application/json
curl -X GET "https://lenz.example.com/api/alert-history/export/status/export-job-uuid-abc123"{ "ok": true, "message": "success", "data": { "job_id": "export-job-uuid-abc123", "status": "completed", "progress": { "processed": 500, "total": 500, "percent": 100 }, "file_ready": true, "error_message": null, "created_at": "2025-04-30T08:00:00Z", "completed_at": "2025-04-30T08:00:45Z" }}Authorization
bearerAuth In: header
Path Parameters
ID job ekspor.
Response Body
application/json
curl -X GET "https://lenz.example.com/api/alert-history/export/download/export-job-uuid-abc123""string"{ "ok": false, "code": "not-found", "message": "Export job not found or file not ready"}Authorization
bearerAuth In: header
Path Parameters
ID job ekspor yang akan dibatalkan.
Response Body
application/json
curl -X DELETE "https://lenz.example.com/api/alert-history/export/export-job-uuid-abc123"{ "ok": true, "message": "Export job cancelled"}