Skip to content

Export Accounts By Filter

MngExportAccountsByFilter

Description: Exports account records selected by the same filter model as MngGetAccountsByFilter into a file stored in the server storage directory.

The method does not return account rows in JSON. Instead, it creates a file and returns only its generated name.

The export always contains the full filtered result set.

Access Control

🛡️ Access Level Required: SESSION_MANAGER, SESSION_ADMIN, SESSION_DEALER

Request Parameters

Name Type Required Description
groupFilter string Yes Group mask used to select accounts, for example STD-* or *
format string Yes Output format: csv or excel
where array No Additional filter rules
whereNot array No Negated filter rules
whereIn array No Inclusion filter rules in [[field, [value1, value2, ...]], ...] format
whereNotIn array No Exclusion filter rules in [[field, [value1, value2, ...]], ...] format
whereBetween array No Range filter rules in [[field, [from, to]], ...] format
whereNotBetween array No Negative range filter rules in [[field, [from, to]], ...] format
orderBy array No Sort instructions
select array No List of fields to export. If omitted or empty, the default account export layout is used
total array No List of numeric fields for the bottom Total: row. If omitted or empty, no total row is added

Supported Filter Keys

  • where: [[field, operator, value], ...]
  • whereNot: [[field, value], ...]
  • whereIn: [[field, [value1, value2, ...]], ...]
  • whereNotIn: [[field, [value1, value2, ...]], ...]
  • whereBetween: [[field, [from, to]], ...]
  • whereNotBetween: [[field, [from, to]], ...]

Supported where Operators

  • =
  • ==
  • !=
  • >
  • <
  • >=
  • <=
  • like

Supported select Fields

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

  • login
  • enable
  • enable_read_only
  • enable_change_password
  • leverage
  • currency
  • group
  • email
  • country
  • phone
  • comment
  • address
  • city
  • zipcode
  • name
  • regdate
  • prevbalance
  • prevmonthbalance
  • balance
  • credit
  • profit
  • net_profit
  • storage
  • commission
  • margin
  • margin_free
  • margin_level
  • equity
  • online
  • magic
  • customer_id
  • update_time

Aliases accepted in select:

  • status -> enable
  • read_only -> enable_read_only
  • free_margin -> margin_free
  • registration_date -> regdate

password is not supported and is never exported.

Supported total Fields

If total is passed and not empty, the export adds a bottom row with Total: in the first column. Totals are written only under columns that are both present in select and listed in total.

Supported fields:

  • balance
  • credit
  • profit
  • net_profit
  • storage
  • commission
  • margin
  • margin_free
  • equity
  • prevbalance
  • prevmonthbalance

Default Export Layout

If select is omitted or empty, the export contains the following columns in this exact order:

Login   Name    Group   Email   Country City    Address Phone   Status  Read only   Currency    Balance Leverage    Credit  Margin  Free margin Margin level    Equity  Registration date   Comment

Export Formatting Notes

  • regdate is exported as a UTC datetime string
  • profit is gross floating profit
  • net_profit is calculated as profit + storage + commission
  • prevbalance, prevmonthbalance, balance, credit, profit, net_profit, storage, commission, margin, margin_free, margin_level, and equity are exported with 2 digits after the decimal point
  • total row values use compact numeric formatting, for example 12500 instead of 12500.00
  • enable is exported as Enable or Disable
  • enable_read_only is exported as Yes or No
  • leverage is exported in x100 format
  • exported values follow the same order as the selected columns
  • exported column headers are human-readable, for example Margin level instead of margin_level

Request Example

{
  "groupFilter": "STD-*",
  "format": "csv",
  "select": ["login", "group", "currency", "balance", "equity", "online", "regdate"],
  "total": ["balance", "equity"],
  "where": [
    ["enable", "=", 1]
  ],
  "whereNot": [],
  "orderBy": ["balance", "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 contains only the generated file name with extension
  • the export always contains the full filtered result set
  • password values are not included in account exports
  • limit and offset are not supported by this method

Errors

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