Nodeflux Central
Alert History

API Reference — Alert History

Endpoint untuk mengambil daftar alert, detail, memperbarui status follow-up, dan mengekspor data Alert History.

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.

GET
/api/alert-history

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

cursor?string

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.

limit?integer

Jumlah item per halaman. Maksimum: 100.

Default20
Range1 <= value <= 100
include_total?boolean

Jika true, respons akan menyertakan total keseluruhan data yang cocok. Mengaktifkan mode cursor dan membutuhkan query COUNT tambahan.

Defaultfalse
page?integer

Nomor halaman untuk mode offset-based pagination (1-indexed). Digunakan saat mode cursor tidak diaktifkan.

Default1
Range1 <= value
pagination_mode?string

Set ke cursor untuk secara eksplisit menggunakan cursor-based pagination.

Value in"cursor"
sort[created_at]?string

Urutan berdasarkan waktu pembuatan alert.

Default"desc"
Value in"asc" | "desc"
sort[severity]?string

Urutan berdasarkan tingkat keparahan alert.

Value in"asc" | "desc"
search?string

Pencarian teks bebas pada alertable_id, nama Alert Rule, atau nama stream.

filter[created_from]?string

Batas awal rentang waktu dalam format ISO 8601 / RFC 3339.

Formatdate-time
filter[created_to]?string

Batas akhir rentang waktu dalam format ISO 8601 / RFC 3339.

Formatdate-time
filter[severity]?string

Filter tingkat keparahan. Dapat berisi beberapa nilai dipisahkan koma.

filter[follow_up_status]?string

Filter status follow-up. Dapat berisi beberapa nilai dipisahkan koma.

filter[alert_rule_id]?integer

Filter berdasarkan ID Alert Rule tertentu.

filter[stream_id]?string

Filter berdasarkan satu atau beberapa Stream ID, dipisahkan koma.

filter[site_id]?integer

Filter berdasarkan ID site. Akan menampilkan alert dari semua stream yang berada di site tersebut.

filter[alertable_type]?string

Filter berdasarkan tipe sumber alert.

Value in"event" | "manual" | "system" | "scheduled" | "external"
timezone?string

Timezone klien (identifikasi IANA) untuk interpretasi filter tanggal.

Default"UTC"
instance?string

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"}
GET
/api/alert-history/{id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik alert history.

Query Parameters

instance?string

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"}
GET
/api/alert-history/by-alertable/{alertable_type}/{alertable_id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

alertable_type*string

Tipe entitas alertable.

Value in"event" | "manual" | "system" | "scheduled" | "external"
alertable_id*string

ID unik entitas yang memicu alert.

Query Parameters

timezone?string

Timezone klien (identifikasi IANA).

Default"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.

PATCH
/api/alert-history/{id}/follow-up-status

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*integer

ID numerik alert history.

Query Parameters

instance?string

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:

  1. Panggil Mulai Job Ekspor untuk memulai proses di sisi server. Respons berisi job_id.
  2. Polling Status Job Ekspor menggunakan job_id hingga status bernilai completed.
  3. Panggil Unduh Hasil Ekspor untuk mengunduh file binary.
  4. (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.

POST
/api/alert-history/export

Authorization

bearerAuth
AuthorizationBearer <token>

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  }}
GET
/api/alert-history/export/status/{job_id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

job_id*string

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"  }}
GET
/api/alert-history/export/download/{job_id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

job_id*string

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"}
DELETE
/api/alert-history/export/{job_id}

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

job_id*string

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

On this page