Skip to content

Export logs by filter

MngExportLogsByFilter

MngExportLogsByFilter

Description: Exports server audit log records selected by the same table-style filter model as GetLogsByFilter. The method creates a CSV or Excel file in the server storage directory and returns the generated file name.

The method does not return log rows in JSON. It exports the full filtered result set without applying limit or offset.

Access Control

🛡️ Access Level Required: SESSION_ADMIN, SESSION_MANAGER, or SESSION_DEALER


Request Parameters

Name Type Required Description
format string Yes Output format: csv or excel
select array No List of fields to export. If omitted or empty, the default log column layout is used
where array No Array of conditions in format [field, operator, value]
whereNot array No Array of negative conditions in format [field, value]
whereIn array No Array of inclusion conditions
whereNotIn array No Array of exclusion conditions
whereBetween array No Array of range conditions in format [field, [from, to]]
whereNotBetween array No Array of negative range conditions
orderBy array No Sorting rule in format [field, direction], where direction is ASC or DESC

If no timestamp filter is provided, the server scans the last 30 days of log files.


Supported select Fields

If select is passed, every item must be one of the fields below. Any unknown field causes 400 INVALID_DATA.

Field Description
timestamp Unix timestamp in seconds
actor_type Actor category
actor_id Actor identifier or -
action Operation name
status Operation status
source Request origin, IP, plugin name, or module name
detail Free-form payload or message

The same fields can be used in filters and sorting.


Default Export Layout

If select is omitted or empty, the export layout is:

Timestamp   Actor type  Actor id    Action  Status  Source  Detail

Request Example

{
  "format": "csv",
  "select": ["timestamp", "actor_type", "actor_id", "action", "status", "source", "detail"],
  "where": [
    ["actor_type", "=", "MANAGER"],
    ["status", "=", "SUCCESS"]
  ],
  "whereBetween": [
    ["timestamp", [1713744000, 1713830399]]
  ],
  "orderBy": ["timestamp", "DESC"]
}

Response Parameters

Name Type Description
file_name string Generated file name stored in storage/

Successful Response Example

{
  "file_name": "550e8400-e29b-41d4-a716-446655440000.csv"
}

Notes

  • format = "csv" generates a .csv file.
  • format = "excel" generates a .xlsx file.
  • The response does not include a host or absolute URL, only the generated file name.
  • The file can be downloaded from the server storage route using the returned name.
  • Exported rows follow the same filter and sorting semantics as GetLogsByFilter.
  • limit and offset are intentionally ignored by this method; export always uses the full filtered result set.

Errors

Code Description
400 Invalid request payload or unsupported field in select
500 Export directory creation or file write failed