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 matching rows until the scan is complete or max_rows is reached. limit and offset are not used by this method.

CSV export is written as a stream and is suitable for large log ranges. Excel export is limited to a smaller row count because the XLSX writer keeps rows in memory.

Access Control

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

Manager permissions are resolved from the cached staff manager record. Non-admin managers require BackOffice access; token payload is used only for manager id and session type.


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. Export supports only ["timestamp", "ASC"] or ["timestamp", "DESC"]
grep object No Streaming text search by one log field
max_rows int No Maximum number of rows to export. CSV default: 500000, CSV max: 2000000, Excel max: 50000

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
message Alias for detail

The same fields can be used in filters and grep. Sorting is limited to timestamp ASC/DESC.


grep applies a streaming search after structured filters.

{
  "field": "message",
  "value": "backup",
  "mode": "contains",
  "case_sensitive": false
}

Supported mode values:

  • contains
  • equals
  • starts_with
  • ends_with

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]]
  ],
  "grep": {
    "field": "message",
    "value": "backup",
    "mode": "contains",
    "case_sensitive": false
  },
  "max_rows": 500000,
  "orderBy": ["timestamp", "DESC"]
}

Response Parameters

Name Type Description
file_name string Generated file name stored in storage/
rows int Number of rows written to the file
truncated bool true if export stopped at max_rows
message string Optional message, for example when the row limit is reached

Successful Response Example

{
  "file_name": "550e8400-e29b-41d4-a716-446655440000.csv",
  "rows": 12450,
  "truncated": false
}

Limit reached:

{
  "file_name": "550e8400-e29b-41d4-a716-446655440000.csv",
  "rows": 500000,
  "truncated": true,
  "message": "Export row limit reached"
}

Notes

  • format = "csv" generates a .csv file.
  • format = "excel" generates a .xlsx file and is capped at 50000 rows.
  • 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.
  • Use max_rows to protect the server and the client from extremely large exports.
  • Prefer an explicit whereBetween by timestamp for production exports.

Errors

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