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.
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
Name
In
Type
Required
Description
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.
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
Name
In
Type
Required
Description
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.
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
Name
In
Type
Required
Description
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.
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.
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.
Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.
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.
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.
Response metadata. ActivityId identifies the request — quote it when you contact support. Paging is present only on paginated list responses; otherwise it is omitted.
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.
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.
Property
Type
Description
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.
Property
Type
Description
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.