Skip to content

Notify Record Reference | ScaleTrade

NotifyRecord

Field Type Description
id int Autoincrement in DB
user_id int Manager ID or Account login (default = 0)
token string Notification type, see Tokens. Not unique
message string Notification message in AST format
description string Notification description in AST format
data string Serialized JSON object with structured data, see Tokens
create_time time_t Time when the notification was created
open_time time_t Time when the notification was opened
update_time time_t Time when the notification was last updated
exp_time time_t Expiration time. 0 means the notification does not expire automatically
level int Message level: INFO, WARNING, ERROR, PROMO, MARKETING, NEWS
type int Message type: AST_MSG, TXT_MSG, TOKEN_MSG, AST_DESC
access int Access scope: MANAGER, CLIENT, CLIENT_BROADCAST, MANAGER_BROADCAST
status int Status: WAITING, SENT, READ, FAILED, DELIVERED, DELETED
target int Application a manager notification is for: COMMON, CRM, BACKOFFICE, see target. 0 for account notifications

Enums

level

  • 0 — INFO
  • 1 — WARNING
  • 2 — ERROR
  • 3 — PROMO
  • 4 — MARKETING
  • 5 — NEWS

type

  • 0 — AST_MSG
  • 1 — TXT_MSG
  • 2 — TOKEN_MSG
  • 3 — AST_DESC

access

  • 0 — MANAGER
  • 1 — CLIENT (trading account)
  • 2 — MANAGER_BROADCAST. Stored as a separate MANAGER record for every enabled manager
  • 3 — CLIENT_BROADCAST

status

  • 0 — WAITING
  • 1 — SENT
  • 2 — READ
  • 3 — FAILED
  • 4 — DELIVERED
  • 5 — DELETED

target

  • 0 — COMMON. Shown in both CRM and back office: one record with one read status
  • 1 — CRM
  • 2 — BACKOFFICE

target applies to manager notifications. It decides where a notification is shown and which sessions receive the real-time notify event:

  • MngGetNotifyList called with target returns the records of that application and the common ones;
  • the event is sent to the sessions subscribed to notify:crm or notify:backoffice.

A notification for an application is not created for a manager who has no access to it (access_crm for CRM, access_backoffice for back office). A super admin has access to both.

Tokens

token names the kind of a notification. An interface chooses the title, the layout and the navigation target by token and reads the details from data. New tokens are added over time; an unknown token should be shown as plain text (message, description).

Manager notifications

Token Level Target Recipients When
CASHIER_DEPOSIT_CREATED INFO CRM Assigned manager of the customer, admins of the customer brand, super admins A Cashier deposit request is created, by the client or by a manager
CASHIER_WITHDRAWAL_CREATED INFO CRM Same A Cashier withdrawal request is created
CLIENT_CREATED / LEAD_CREATED INFO CRM Same A client or a lead is created. A guest record is announced when the guest registers
CLIENT_UPDATED / LEAD_UPDATED INFO CRM Same; after a reassignment the new assigned manager A significant field of the record changed, see Changes
MARGIN_CALL WARNING CRM Assigned manager of the customer, admins of the customer brand, super admins The account of a customer entered Margin Call
MARGIN_CALL WARNING BACKOFFICE Back office managers who may see account balances and the group of the account The account entered Margin Call
STOP_OUT ERROR CRM, BACKOFFICE Same as MARGIN_CALL, for each application The account entered Stop Out
WORKFLOW_RUN_FAILED ERROR CRM Admins of the rule brand, super admins A workflow rule run ended with an error
CUSTOMER_IMPORT_FAILED ERROR CRM The manager who ran the import An import reported with MngReportClientsImport or MngReportLeadsImport has failed rows
BULK_OPERATION_COMPLETED INFO, WARNING when failed > 0 CRM The manager who ran the operation A bulk Mng*ByFilter operation on clients or leads was applied. A preview (confirm = false) gives no notification
WORKFLOW_NOTIFY Set by the rule CRM The manager named in the rule. Without one: the assigned manager of the customer, admins of the customer brand, super admins; for an event without a customer - admins of the rule brand, super admins Workflow action notify.manager
GROUP_ADD / GROUP_UPDATE / GROUP_DELETE INFO BACKOFFICE Every enabled manager with back office access A trading group changed
Set by the feeder INFO BACKOFFICE, or target passed by the feeder Every enabled manager with access to that application A feeder message
Set by the sender Set by the sender target of MngAddNotify, COMMON by default user_id, or every enabled manager when access = 2 A notification created manually

An admin of a brand is an enabled manager with admin = 1 whose brand equals the brand of the event. A super admin is an enabled manager with super_admin = 1. A manager who matches several roles gets one record. A manager also gets notifications about his own actions.

Nothing is merged or suppressed: an import of N rows gives N *_CREATED notifications, and a bulk operation gives a *_UPDATED notification for every changed record plus one BULK_OPERATION_COMPLETED.

MARGIN_CALL and STOP_OUT are two separate notifications with different recipients and different data. A manager who receives both, for example a brand admin with back office access, gets one record in each application; they are read independently. An account that belongs to no customer gives only the back office record. In CRM a manager who is not an admin gets Margin Call and Stop Out only for the customers assigned to him.

A manager with notifications_enabled = 0 gets no notifications with the CRM target, see UpdateManagerProfile. Back office and common notifications are created regardless of this switch.

data by token

Common keys of client and lead notifications:

Key Type Description
event string Machine name of the event
brand string Brand of the customer
customer_id int Customer id; opens the client or lead card
customer_kind int 0 - lead, 1 - client
customer_name string Full name, or first and last name
occurred_at int64 Unix timestamp of the event

CASHIER_DEPOSIT_CREATED, CASHIER_WITHDRAWAL_CREATED — event is cashier.deposit.created or cashier.withdrawal.created:

{
  "event": "cashier.deposit.created",
  "brand": "main",
  "customer_id": 4521,
  "customer_kind": 1,
  "customer_name": "John Smith",
  "transaction_id": 9031,
  "transaction_type": 0,
  "login": 100500,
  "amount": 250.0,
  "currency": "USD",
  "status": 0,
  "occurred_at": 1763553600
}

transaction_type: 0 - deposit, 1 - withdrawal. status is the Cashier transaction status at creation. When the customer of the transaction cannot be resolved, brand, customer_kind and customer_name are absent and only super admins are notified.

CLIENT_CREATED, LEAD_CREATED:

{
  "event": "customer.created",
  "brand": "main",
  "customer_id": 4521,
  "customer_kind": 0,
  "customer_name": "John Smith",
  "occurred_at": 1763553600
}

CLIENT_UPDATED, LEAD_UPDATED:

{
  "event": "customer.updated",
  "brand": "main",
  "customer_id": 4521,
  "customer_kind": 1,
  "customer_name": "John Smith",
  "changes": [
    { "field": "sales_status", "old": 2, "new": 5 },
    { "field": "phone", "old": "+35799000001", "new": "+35799000002" }
  ],
  "occurred_at": 1763553600
}

MARGIN_CALL, STOP_OUT for CRM (target = 1):

{
  "margin_level": 48.7,
  "margin_type": 0,
  "login": 100500,
  "balance": 1200.0,
  "bonus": 0.0,
  "equity": 312.4,
  "brand": "main",
  "customer_id": 4521,
  "customer_kind": 1,
  "customer_name": "John Smith"
}

balance, bonus and equity are present only in the record of a recipient who has the see_accounts_balance permission. message names the customer: Margin call: John Smith.

MARGIN_CALL, STOP_OUT for back office (target = 2) and for the trading account itself:

{
  "margin_level": 48.7,
  "margin_type": 0,
  "login": 100500,
  "balance": 1200.0,
  "bonus": 0.0,
  "equity": 312.4
}

The back office record describes the account and has no customer keys.

WORKFLOW_RUN_FAILED:

{
  "event": "workflow.run_failed",
  "brand": "main",
  "run_id": 88214,
  "rule_id": 12,
  "rule_code": "FTD_BONUS",
  "rule_name": "First deposit bonus",
  "trigger": "cashier.deposit.approved",
  "entity_type": "cashier_transaction",
  "entity_id": 9031,
  "error": "VALID_BALANCE_IN_REQUIRED_FOR_BONUS",
  "occurred_at": 1763553600
}

error is cut to 500 bytes.

CUSTOMER_IMPORT_FAILED:

{
  "event": "customer.import_completed",
  "brand": "main",
  "customer_kind": 0,
  "total": 250,
  "created": 247,
  "failed": 3,
  "errors": [
    "Row 14: email: Invalid email",
    "Row 97: RET_DUPLICATE_RECORD",
    "Row 180: desk: INVALID_DESK"
  ],
  "occurred_at": 1763553600
}

BULK_OPERATION_COMPLETED:

{
  "event": "customer.bulk_completed",
  "brand": "main",
  "command": "MngUpdateLeadsStatusesByFilter",
  "customer_kind": 0,
  "matched": 120,
  "updated": 118,
  "skipped": 0,
  "failed": 2,
  "occurred_at": 1763553600
}

customer_kind is -1 for the deprecated commands that work on both kinds. For delete commands updated is the number of deleted records. skipped is 0 for commands that do not count skipped records.

Changes

CLIENT_UPDATED and LEAD_UPDATED are created only when at least one of these fields changes, and changes lists only them:

Group Fields
Assignment assigned_manager_id, desk
Statuses status, sales_status, risk_status, finance_status, crm_stage, customer_kind, lifecycle_flags
Contacts first_name, last_name, email, phone, country_of_residence, address_of_residence
Access enable, deposit_allowed, withdrawal_allowed
Compliance kyc_status, risk_level, aml_status

Each item is { "field", "old", "new" }. Numeric fields carry numbers, text fields carry strings. A change of any other field (login and contact times, sources, service data) gives no notification.