CPlugin

MT5 v2 :: Dealer

API v2 (current) · MT5 · 3 operations · base URL https://cloud.mywebapi.com · OpenAPI v2 (JSON) · Redoc

Every call needs Authorization: Bearer $TOKEN — an OAuth 2.0 client-credentials token (scope webapi). The token server belongs to the environment: for the Sandbox call https://pre.mywebapi.com and take the token from https://pre.auth.cplugin.net/connect/token; for Production take it from https://auth.cplugin.net/connect/token. Clients and tokens of the two are separate — a token from one answers 401 on the other. $TRADE_PLATFORM_ID is the id of a trade platform registered in Toolbox. A failed operation is also answered with HTTP 200: check error before using data. Access and transport failures use HTTP codes — see Errors.

Operations

Send a trade request on behalf of the dealer

POST /api/v2/MT5/{tradePlatform}/DealerSend

Sends a trade request to the trade server as a dealer and waits for the server answer. Only dealer request types (200–255, the Dealer* actions) are accepted; any other request type is rejected by the server with the corresponding platform error, which is returned in the error envelope.

The call blocks while the dealer answer is awaited. When the answer does not arrive before the server timeout, the platform error MT_RET_ERR_TIMEOUT is returned. The response carries the request as the server processed it, including the assigned request identifier and the resulting order and deal references.

An uncertain result code — network loss, timeout, accepted or still processed — is answered as OutcomeUnknown: the request may have been executed or may still be, so check the platform state instead of repeating it. MT_RET_REQUEST_DONE and MT_RET_REQUEST_DONE_PARTIAL are reported the same way, with a wording that the operation was executed.

Timeout: 5 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 5 s (trade operation). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

MT5Request (application/json) — Dealer request to send.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerSend" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "symbol": "", "action": "Price", "type": "Buy", "volume": 0, "priceOrder": 0 }'

Send a balance operation on behalf of the dealer

POST /api/v2/MT5/{tradePlatform}/DealerBalance

Credits or debits the balance of the account with the given login, creating a balance deal on the server. When the request type is omitted the balance operation is used; buy and sell types make no sense here. The comment is stored with the deal.

The operation is validated by the server against the standard credit and margin rules. On success the response carries the identifier of the created deal; a rejection is returned as the platform error that explains it.

MT_RET_REQUEST_DONE is success: this is the normal answer of a created balance deal and it carries the identifier of that deal. MT_RET_REQUEST_DONE_PARTIAL is answered as OutcomeUnknown with a wording that the operation was executed; check the account before repeating the request. A repeat with the same idempotency key answers that the request is still in progress, so once the account has been checked a deliberate retry needs a new key.

Timeout: 5 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 5 s (trade operation). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

DealerBalanceRequest (application/json) — Balance operation to perform.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerBalance" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "value": 0, "type": "Buy", "comment": "" }'

Send a balance operation without the standard validation checks

POST /api/v2/MT5/{tradePlatform}/DealerBalanceRaw

Performs the same balance operation as the validated variant, but the trade server skips the standard credit and margin checks. Intended for administrative corrections, where the resulting account state is deliberately allowed to fall outside the usual limits.

On success the response carries the identifier of the created deal; a rejection is returned as the platform error that explains it.

MT_RET_REQUEST_DONE is success: this is the normal answer of a created balance deal and it carries the identifier of that deal. MT_RET_REQUEST_DONE_PARTIAL is answered as OutcomeUnknown with a wording that the operation was executed; check the account before repeating the request. A repeat with the same idempotency key answers that the request is still in progress, so once the account has been checked a deliberate retry needs a new key.

Timeout: 5 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: The operation may still be completed by the server (X-Request-Outcome: unknown): check its result before repeating it.

Parameters

NameInTypeRequiredDescription
tradePlatform path string (uuid) yes Trade platform identifier (GUID).
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 5 s (trade operation). The query parameter requestTimeout does the same for clients that cannot set headers. The applied value is returned in the X-Request-Timeout-Applied response header.

Request body

DealerBalanceRequest (application/json) — Balance operation to perform.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerBalanceRaw" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "login": 0, "value": 0, "type": "Buy", "comment": "" }'

Schemas

Types the operations above take and return, with their first-level properties; * marks a required one. The full graph is in the OpenAPI specification.

MT5Request

PropertyTypeDescription
id integer (int32), nullable Read-only: the trade server does not let this value be changed. request id
login * integer (int64) client login
group string, nullable Read-only: the trade server does not let this value be changed.
symbol * string symbol
digits integer (int32), nullable price digits
action * TradeActions TradeActions
timeExpiration string (date-time), nullable order expiration
type * OrderType order type OrderType
typeFill OrderFilling OrderFilling
typeTime OrderTime OrderTime
flags TradeActionFlags additional flags TradeActionFlags
volume * integer (int64) 1 lot = 10_000
order integer (int64), nullable order ticket
orderExternalID string, nullable order ticket in external system (exchange, ECN, etc)
priceOrder * number (double) order price
priceTrigger number (double), nullable order trigger price
priceSL number (double), nullable order SL price
priceTP number (double), nullable order TP price
priceDeviation integer (int64), nullable price deviation details
priceDeviationTop number (double), nullable
priceDeviationBottom number (double), nullable
comment string, nullable comment
resultRetCode MT5Result Read-only: the trade server does not let this value be changed. request result information
resultDealer integer (int64), nullable request result deal request dealer
resultDeal integer (int64), nullable Read-only: the trade server does not let this value be changed. request result deal
resultOrder integer (int64), nullable Read-only: the trade server does not let this value be changed. request result order
resultVolume integer (int64), nullable Read-only: the trade server does not let this value be changed. request result confirmed volume
resultPrice number (double), nullable Read-only: the trade server does not let this value be changed. request result confirmed price
resultDealerBid number (double), nullable Read-only: the trade server does not let this value be changed. request result dealer prices
resultDealerAsk number (double), nullable Read-only: the trade server does not let this value be changed.
resultDealerLast number (double), nullable Read-only: the trade server does not let this value be changed.
resultMarketBid number (double), nullable Read-only: the trade server does not let this value be changed. request result market prices
resultMarketAsk number (double), nullable Read-only: the trade server does not let this value be changed.
resultMarketLast number (double), nullable Read-only: the trade server does not let this value be changed.
resultComment string, nullable Read-only: the trade server does not let this value be changed. request result comment
externalAccount string, nullable external system trade account (exchange, ECN, etc)
idClient integer (int32), nullable Read-only: the trade server does not let this value be changed. client side request id
ip string, nullable source request ip
sourceLogin integer (int64), nullable source dealer login (for dealer transaction)
position integer (int64), nullable position ticket
positionBy integer (int64), nullable position ticket for close-by
positionExternalID string, nullable position ticket in external system (exchange, ECN, etc)
positionByExternalID string, nullable position ticket in external system (exchange, ECN, etc)
volumeExt integer (int64), nullable volume with extended accuracy, 1 lot = 100_000_000
resultVolumeExt integer (int64), nullable Read-only: the trade server does not let this value be changed. request result confirmed volume with extended accuracy
volumeCurrent integer (int64), nullable current order volume
volumeCurrentExt integer (int64), nullable current order volume
reason integer (int32), nullable request reason, as the platform stores it
spreadDiff integer (int32), nullable spread difference for the request
spreadDiffBalance integer (int32), nullable spread difference for the balance operation of the request
symbolOriginal string, nullable symbol name as it was sent by the client, before the server resolved it

MT5RequestApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). A call that reaches an operation answers HTTP 200 — only transport failures (401, 403, 404, 400, 5xx) use other status codes.

PropertyTypeDescription
data MT5Request
error ApiError v2 error body, present when a call failed even though it answered HTTP 200. Code is the stable error category. ManagerCode is the raw result code of the trade server on MT4 (null otherwise: on MT5 the result name is in Message). Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

DealerBalanceRequest

PropertyTypeDescription
login * integer (int64)
value * number (double)
type EnDealAction if none specified - it will be Balance operation. Buy/Sell actions here - pointless.
comment string, nullable

UInt64ApiResponse

Unified v2 response envelope: data is the payload (null on error); error is the error object (null on success, always serialised); meta contains response metadata (activityId and optional paging). A call that reaches an operation answers HTTP 200 — only transport failures (401, 403, 404, 400, 5xx) use other status codes.

PropertyTypeDescription
data integer (int64)
error ApiError v2 error body, present when a call failed even though it answered HTTP 200. Code is the stable error category. ManagerCode is the raw result code of the trade server on MT4 (null otherwise: on MT5 the result name is in Message). Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

TradeActions

Values: Price, Request, Instant, Market, Exchange, Pending, SLTP, Modify, Remove, Transfer, CloseBy, Activate, ActivateSL, ActivateTP, ActivateStopLimit, StopOutOrder, StopOutPosition, Expiration, DealerPosExecute, DealerOrdPending, DealerPosModify, DealerOrdModify, DealerOrdRemove, DealerOrdActivate, DealerBalance, DealerOrdSLimit, DealerCloseBy, End

OrderType

Values: Buy, Sell, BuyLimit, SellLimit, BuyStop, SellStop, BuyStopLimit, SellStopLimit, CloseBy

OrderFilling

Values: FoK, IoC, Return, BoC

OrderTime

Values: GtC, Day, Specified, SpecifiedDay

TradeActionFlags

Flags: names of the set bits joined by ", " ("Close, Market"), "None" when none is set; a set bit without a name is "Bit<n>" (bit number). Bits: Close = 0x1, Market = 0x2, ChangedPrice = 0x4, ChangedTrigger = 0x8, ChangedSL = 0x10, ChangedTP = 0x20, ChangedExpType = 0x40, ChangedExpTime = 0x80, Expert = 0x100, Signal = 0x200, SkipMarginCheck = 0x400. Accepted on input, never written: All = Close, Market, ChangedPrice, ChangedTrigger, ChangedSL, ChangedTP, ChangedExpType, ChangedExpTime, Expert, Signal, SkipMarginCheck.

MT5Result

Values: Ok, OkNone, Error, ErrParams, ErrData, ErrDisk, ErrMem, ErrNetwork, ErrPermissions, ErrTimeout, ErrConnection, ErrNoService, ErrFrequent, ErrNotfound, ErrPartial, ErrShutdown, ErrCancel, ErrDuplicate, AuthClientInvalid, AuthAccountInvalid, AuthAccountDisabled, AuthAdvanced, AuthCertificate, AuthCertificateBad, AuthNotConfirmed, AuthServerInternal, AuthServerBad, AuthUpdateOnly, AuthClientOld, AuthManagerNoConfig, AuthManagerIPBlock, AuthGroupInvalid, AuthCaDisabled, AuthInvalidID, AuthInvalidIp, AuthInvalidType, AuthServerBusy, AuthServerCert, AuthAccountUnknown, AuthServerOld, AuthServerLimit, AuthMobileDisabled, AuthManagerType, AuthDemoDisabled, AuthResetPassword, AuthOTPInvalid, AuthOTPNeedSecret, AuthMigrationMT4, AuthMigrationMT5, AuthInvalidVerify, AuthVerifyBadEmail, AuthVerifyBadPhone, AuthAPIDisabled, CfgLastAdmin, CfgLastAdminGroup, CfgNotEmpty, CfgInvalidRange, CfgNotManagerLogin, CfgBuiltin, CfgDuplicate, CfgLimitReached, CfgNoAccessToMain, CfgDealerIDExist, CfgBindAddressExist, CfgWorkingTrade, CfgGatewayNameExist, CfgSwitchToBackup, CfgNoBackupModule, CfgNoTradeModule, CfgNoHistoryModule, CfgAnotherSwitch, CfgNoLicenseFile, CfgGatewayLoginExist, CfgInvalidCompany, UsrLastAdmin, UsrLoginExhausted, UsrLoginProhibited, UsrLoginExist, UsrSuicide, UsrInvalidPassword, UsrLimitReached, UsrHasTrades, UsrDifferentServers, UsrDifferentCurrency, UsrImportBalance, UsrImportGroup, UsrAccountExist, UsrImportAccount, UsrImportPositions, UsrImportOrders, UsrImportDeals, UsrImportHistory, UsrAPILimitReached, TradeLimitReached, TradeOrderExist, TradeOrderExhausted, TradeDealExhausted, TradeMaxMoney, TradeDealExist, TradeOrderProhibited, TradeDealProhibited, TradeSplitVolume, ReportSnapshot, ReportNotSupported, ReportNodata, ReportTemplateBad, ReportTemplateEnd, ReportInvalidRow, ReportLimitRepeat, ReportLimitReport, HstSymbolNotfound, RequestInWay, RequestAccepted, RequestProcess, RequestRequote, RequestPrices, RequestReject, RequestCancel, RequestPlaced, RequestDone, RequestDonePartial, RequestError, RequestTimeout, RequestInvalid, RequestInvalidVolume, RequestInvalidPrice, RequestInvalidStops, RequestTradeDisabled, RequestMarketClosed, RequestNoMoney, RequestPriceChanged, RequestPriceOff, RequestInvalidExp, RequestOrderChanged, RequestTooMany, RequestNoChanges, RequestAtDisabledServer, RequestAtDisabledClient, RequestLocked, RequestFrozen, RequestInvalidFill, RequestConnection, RequestOnlyReal, RequestLimitOrders, RequestLimitVolume, RequestInvalidOrder, RequestPositionClosed, RequestExecutionSkipped, RequestInvalidCloseVolume, RequestCloseOrderExist, RequestLimitPositions, RequestRejectCancel, RequestLongOnly, RequestShortOnly, RequestCloseOnly, RequestProhibitedByFifo, RequestHedgeProhibited, RequestReturn, RequestDoneCancel, RequestRequoteReturn, ErrNotImplement, ErrNotMain, ErrNotSupported, ErrDeadlock, ErrLocked, MessengerInvalidPhone, MessengerNotMobile, SubsNotFound, SubsNotFoundCfg, SubsNotFoundUser, SubsDisabled, SubsPermissionUser, SubsPermissionSubscribe, SubsPermissionUnsubscribe, SubsRealOnly, SubsPaymentMethod, PayRealOnly, PayInvalidAmount, PayNotAllowedDeposit, PayNotAllowedWithdrawal, PayNotAllowedGroup, PayNotAllowedCountry, PayDeclineByRules, PayDeclineByAml, PayLimitDepositMin, PayLimitDepositMax, PayLimitWithdrawalMin, PayLimitWithdrawalMax, PayProviderPayment, PayProviderStatus, PayConversion, PayNotWaiting, PayVerification, PayInvoice, PayInvalidCurrency, PayLimitReached, PayProviderRefund, PayDeclineByCardholderName

ApiError

v2 error body, present when a call failed even though it answered HTTP 200. Code is the stable error category. ManagerCode is the raw result code of the trade server on MT4 (null otherwise: on MT5 the result name is in Message). Message is a human-readable description.

PropertyTypeDescription
code WebApiErrorCode Stable transport-level error code.
managerCode ResultCode Raw MT4 result code when ApiError.Code is MT4Error; null otherwise. On MT5 the result name is in ApiError.Message.
message string, nullable Human-readable error description.

ApiMeta

Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.

PropertyTypeDescription
activityId string, nullable W3C trace id of the request. Quote it when you contact support: it finds this exact call in the server logs.
paging PagingMeta Pagination info; present only on list responses, omitted otherwise.

EnDealAction

Action

Values: Buy, Sell, Balance, Credit, Charge, Correction, Bonus, Commission, CommissionDaily, CommissionMonthly, AgentDaily, AgentMonthly, InterestRate, BuyCanceled, SellCanceled, Dividend, DividendFranked, Tax, Agent, SOCompensation