Skip to content

staff.balance ​

3 methods on staff.balance. Each returns the answer's data and throws NoviqaError on a failed answer.

bulk ​

POST/admin/v1/balance/bulk

Money operation for many accounts

Posts one money operation per item, all with the same action (balance, credit, bonus, charge, correction, commission, dividend, tax). items holds 1-1000 accounts, each with its login, amount (+ in, - out) and its own request_id (a new UUID, unique in the request; the same id sent again never pays twice). An item's comment falls back to the top-level comment; comments at most 64 characters. Each item runs and is journaled on its own: an account out of scope, unknown or short of money fails alone with status rejected and a code (forbidden, not_found, trade.no_money, invalid_input...); done rows carry the new deal_id. Actions: balance, credit, charge, correction, bonus, commission, dividend, dividend_franked (MT5 franked dividends), tax. skip_margin_check true is MT5's "Conduct balance operation without checking the free margin and the current balance on the account" (same rights). With the confirm_actions right the request needs confirm_token and confirm_code from POST /admin/v1/confirmations, else 403 confirmation_required (nothing runs).

More details

Rights: the staff member needs every one of: accounts.balance.

Request body
actionDealAction
DealAction is the kind of deal: a trade or a money operation. - balance: deposit (+) or withdrawal (-) - bonus: moves credit - correction: may leave the account short - dividend_franked: MT5 franked dividend: a dividend with tax already paid - interest: the month's interest paid on free margin - agent: agent commission paid to the agent account; Value is the amount in the client's currency
buy sell balance credit bonus charge correction commission dividend dividend_franked tax swap interest agent
commentstring
used where an item has none
confirm_codestring
the code as the user typed it
confirm_tokenstring
from POST /admin/v1/confirmations
itemsobject[]
skip_margin_checkboolean
MT5: without checking the free margin and the current balance
Returns
Promise<BalanceRow[]>
The answer's data.
Errors
400invalid_input: invalid input
401auth.session_expired: session expired, sign in again
403auth.csrf_invalid: request refused: reload the page and try again
403auth.invalid_terminal: this terminal cannot be used here
403auth.otp_enrol_required: your group requires one-time codes: set them up to continue
403auth.password_change_required: you must change your password first
403confirmation_required: confirm this action with the code shown
403forbidden: you do not have access to this action
500internal: something went wrong
ts
import { staff } from "@/lib/noviqa"

const data = await staff.balance.bulk({
  action: "bonus",
  comment: "September promo",
  items: [
    {
      amount: "50.00",
      login: 100234,
      request_id: "0b8e2f4a-6c1d-4e3b-9a7f-5d2c1b0a9e8f"
    },
    {
      amount: "50.00",
      comment: "VIP",
      login: 100235,
      request_id: "1c9f3a5b-7d2e-4f4c-8b6a-6e3d2c1b0a9f"
    }
  ]
})
bash
curl -X POST "$NOVIQA_API_URL/admin/v1/balance/bulk" \
  -H "Authorization: Bearer $NOVIQA_TOKEN" \
  -H "Content-Type: application/json" \
  --data-raw '{
  "action": "bonus",
  "comment": "September promo",
  "items": [
    {
      "amount": "50.00",
      "login": 100234,
      "request_id": "0b8e2f4a-6c1d-4e3b-9a7f-5d2c1b0a9e8f"
    },
    {
      "amount": "50.00",
      "comment": "VIP",
      "login": 100235,
      "request_id": "1c9f3a5b-7d2e-4f4c-8b6a-6e3d2c1b0a9f"
    }
  ]
}'
json
{
  "success": true,
  "code": "ok",
  "message": "done",
  "data": [
    {
      "amount": "1.08452",
      "code": "ok",
      "deal_id": 1,
      "login": 1001,
      "message": "string",
      "request_id": "3f2a9c1e-8b7d-4e6f-a5c4-1b2d3e4f5a6b",
      "status": "done"
    }
  ],
  "request_id": "5b7f2c1e"
}
ts
staff.balance.bulk(body: account.BulkBalance, options?: RequestOptions): Promise<account.BalanceRow[]>

check ​

POST/admin/v1/balance/check

Check balances against history

For each login in logins (1-100, repeats counted once, answered in login order) compares the stored balance and credit with what the deals history sums to: balance / balance_valid (from history), credit / credit_valid, ok when both agree. Changes nothing; journals every value: balance of account 'x' has been checked: valid (credit likewise) or a warning account x has invalid balance: a, valid: b. A login that cannot be checked does not fail the request: its item holds only login and error (not found, forbidden, not a trading account for a manager or administrator account, or execution's refusal).

More details

Rights: the staff member needs every one of: accounts.balance.

Request body
loginsinteger[]
Returns
Promise<BalanceItem[]>
The answer's data.
Errors
400invalid_input: invalid input
401auth.session_expired: session expired, sign in again
403auth.csrf_invalid: request refused: reload the page and try again
403auth.invalid_terminal: this terminal cannot be used here
403auth.otp_enrol_required: your group requires one-time codes: set them up to continue
403auth.password_change_required: you must change your password first
403forbidden: you do not have access to this action
403trade.disabled: trading is disabled
500internal: something went wrong
504trade.timeout: request timed out
ts
import { staff } from "@/lib/noviqa"

const data = await staff.balance.check({
  logins: [
    100234,
    100235
  ]
})
bash
curl -X POST "$NOVIQA_API_URL/admin/v1/balance/check" \
  -H "Authorization: Bearer $NOVIQA_TOKEN" \
  -H "Content-Type: application/json" \
  --data-raw '{
  "logins": [
    100234,
    100235
  ]
}'
json
{
  "success": true,
  "code": "ok",
  "message": "done",
  "data": [
    {
      "balance": "1000.00",
      "balance_valid": "1.08452",
      "credit": "0.00",
      "credit_valid": "1.08452",
      "error": "string",
      "login": 1001,
      "ok": true
    }
  ],
  "request_id": "5b7f2c1e"
}
ts
staff.balance.check(body: account.loginList, options?: RequestOptions): Promise<account.BalanceItem[]>

fix ​

POST/admin/v1/balance/fix

Fix balances from history

Like the check, but sets balance and credit to what the deals history sums to and answers the check as it was before the fix. Each fixed value writes a journal line (balance of account 'x' has been fixed from a to b), or one balance of account 'x' is valid, nothing to fix; the change reaches the account's terminals as a correction event. Accounts are fixed one after another; a login that cannot be fixed answers its error and the others still run.

More details

Rights: the staff member needs every one of: accounts.balance.

Request body
loginsinteger[]
Returns
Promise<BalanceItem[]>
The answer's data.
Errors
400invalid_input: invalid input
401auth.session_expired: session expired, sign in again
403auth.csrf_invalid: request refused: reload the page and try again
403auth.invalid_terminal: this terminal cannot be used here
403auth.otp_enrol_required: your group requires one-time codes: set them up to continue
403auth.password_change_required: you must change your password first
403forbidden: you do not have access to this action
403trade.disabled: trading is disabled
500internal: something went wrong
504trade.timeout: request timed out
ts
import { staff } from "@/lib/noviqa"

const data = await staff.balance.fix({
  logins: [
    100234
  ]
})
bash
curl -X POST "$NOVIQA_API_URL/admin/v1/balance/fix" \
  -H "Authorization: Bearer $NOVIQA_TOKEN" \
  -H "Content-Type: application/json" \
  --data-raw '{
  "logins": [
    100234
  ]
}'
json
{
  "success": true,
  "code": "ok",
  "message": "done",
  "data": [
    {
      "balance": "1000.00",
      "balance_valid": "1.08452",
      "credit": "0.00",
      "credit_valid": "1.08452",
      "error": "string",
      "login": 1001,
      "ok": true
    }
  ],
  "request_id": "5b7f2c1e"
}
ts
staff.balance.fix(body: account.loginList, options?: RequestOptions): Promise<account.BalanceItem[]>