API v2 (current) · MT5 · 14 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.
Subscribes the connection to the queue of trade requests of the trade server and loads
the requests already waiting in it. From that moment the queue can be read and the
requests can be taken for processing — by this connection only, and the subscription
lives until the queue is closed or the connection is lost.
The call does not take a request and does not answer one: it only enables the queue.
Repeating it on a connection whose queue is already open is harmless.
Timeout: 15 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: 15 s (change). 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.
curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerStart" \
-H "Authorization: Bearer $TOKEN"
Close the queue of trade requests
POST /api/v2/MT5/{tradePlatform}/DealerStop
Stops dealing on the connection: the queue is no longer read or taken from, and the
requests waiting in it stay in the queue for other dealers. Requests already taken for
processing are not returned to the queue — they must still be answered.
The queue applies to the whole connection to the trade platform, so closing it affects
every call that reads or takes requests from it. Repeating the call is harmless.
Timeout: 15 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: 15 s (change). 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.
curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerStop" \
-H "Authorization: Bearer $TOKEN"
Take the first request of the queue for processing
POST /api/v2/MT5/{tradePlatform}/DealerGet
Takes the request at the head of the queue and reserves it for this connection: the
trade server will not hand it to another dealer and waits for the answer. The request
must be answered with DealerAnswer; an unanswered request is not returned to the
queue and is lost.
The call is a write, not a read for all practical purposes: it changes the state of the
queue and cannot be safely repeated — a repeated call takes the next request. When the
queue is empty the platform answers MT_RET_OK_NONE. The queue must be opened with
DealerStart first.
Timeout: 15 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: 15 s (change). 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.
curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerGet" \
-H "Authorization: Bearer $TOKEN"
Take a request with the given identifier for processing
POST /api/v2/MT5/{tradePlatform}/DealerLock/{id}
Reserves the request with the given identifier for this connection, exactly as
DealerGet does for the head of the queue, and returns it. The request must be
answered with DealerAnswer; an unanswered request is not returned to the queue
and is lost.
MT_RET_OK_NONE means that the request is no longer available: it has already been
taken by another dealer or has been processed. The queue must be opened with
DealerStart first.
Timeout: 15 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).
id
path
integer (int32)
yes
Identifier of the trade request.
X-Request-Timeout
header
number (double)
no
How long to wait for the trade server, in seconds (1–300). Default for this operation: 15 s (change). 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.
curl -X POST "https://cloud.mywebapi.com/api/v2/MT5/$TRADE_PLATFORM_ID/DealerLock/$ID" \
-H "Authorization: Bearer $TOKEN"
Answer the trade request taken for processing
POST /api/v2/MT5/{tradePlatform}/DealerAnswer
Completes the request taken with DealerGet or DealerLock: the confirmation
carries the answer code and, depending on the request, the confirmed volume, price and
the identifiers of the order and the deal created in an external trading system. The
request is processed by the trade server immediately and cannot be answered twice.
The answer code (retCode) is required: a confirmation without it is rejected
before the request is answered. The identifier in the confirmation is the identifier of
the original request, not the caller-side one. The queue must be opened with
DealerStart first. A rejected answer is returned as the platform error that
explains it, and the request then stays for the platform to expire.
An uncertain result code is answered as OutcomeUnknown: the request may have been
answered. MT_RET_REQUEST_DONE and MT_RET_REQUEST_DONE_PARTIAL are reported
the same way, with a wording that the operation was executed. The request cannot be
answered twice — check its state instead of repeating the call.
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
MT5Confirm (application/json) — Answer to the trade request.
Returns the trade request with the given identifier as it is known to the connection,
without taking it for processing: the request stays in the queue and can still be handled
by any dealer. Use DealerLock to reserve it for an answer.
The queue must be opened with DealerStart first. An identifier that is not in the
queue is answered with the platform code that states it.
Timeout: 30 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
Parameters
Name
In
Type
Required
Description
tradePlatform
path
string (uuid)
yes
Trade platform identifier (GUID).
id
path
integer (int32)
yes
Identifier of the trade request.
X-Request-Timeout
header
number (double)
no
How long to wait for the trade server, in seconds (1–300). Default for this operation: 30 s (history or report). 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.
Returns the requests waiting in the queue as one list, in the order the trade server
keeps them. Reading does not take a request for processing and does not change the
queue; requests already taken by a dealer are not part of the list.
The whole queue is read at once and then trimmed to the requested window: from
skips that many requests from the head, count limits how many are returned, and
the default of both returns everything. The queue is live, so a repeated call may see a
different set. The queue must be opened with DealerStart first.
Timeout: 30 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
Parameters
Name
In
Type
Required
Description
tradePlatform
path
string (uuid)
yes
Trade platform identifier (GUID).
from
query
integer (int32)
no
Number of requests to skip from the head of the queue; 0 by default.
count
query
integer (int32)
no
Maximum number of requests to return; 0 returns the whole queue.
X-Request-Timeout
header
number (double)
no
How long to wait for the trade server, in seconds (1–300). Default for this operation: 30 s (history or report). 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.
Bring orders, positions and balance of an account in line with an external system
POST /api/v2/MT5/{tradePlatform}/TradeAccountSet
Makes the orders, positions and balance of the account match the passed state. The trade
server compares the lists with its own data and performs the difference as deals with the
sync reason: positions missing on one side are opened or closed, positions whose
direction, price or contract size changed are reopened, a volume change is corrected, and
a balance difference becomes a balance or correction deal. All of it stays in the trading
history of the client.
The operation is heavy and changes money and positions: it must be used by the system that
owns the account, not as a general-purpose edit. An omitted order or position list leaves
that part untouched; an empty list states that the account has none and closes the
existing ones. The call answers as soon as the trade server has accepted it, and the
resulting state of the account is reported to the platform journal.
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.
Calculates the profit a position with the given direction, volume and prices would bring,
in the deposit currency of the group, together with the rate that converts the profit
currency of the symbol into that currency. The calculation uses the current market prices
of the group, so the symbol must be available to that group.
Nothing is created or changed: the result describes a hypothetical position only. The
volume uses four decimal places of a lot; for the extended accuracy use the variant with
the Ext suffix.
Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
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: 10 s (read). 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.
Calculate the profit of a position with extended volume accuracy
POST /api/v2/MT5/{tradePlatform}/TradeProfitExt
The same calculation as TradeProfit, with the volume given in eight decimal places
of a lot instead of four. Nothing is created or changed.
Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
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: 10 s (read). 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.
Check whether an account has the margin an order requires
POST /api/v2/MT5/{tradePlatform}/TradeMarginCheck
Checks whether the given account can place the described order, and returns the state of
the account before and after it. The margin of the hypothetical order is estimated from
the current state of the account and the current prices of its group, so the after state
is approximate.
Nothing is created or changed. An account without enough free margin is a normal answer
(allowed is false) and not an error. The volume uses four decimal places of
a lot; for the extended accuracy use the variant with the Ext suffix.
Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
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: 10 s (read). 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.
Check the margin of an order with extended volume accuracy
POST /api/v2/MT5/{tradePlatform}/TradeMarginCheckExt
The same check as TradeMarginCheck, with the volume given in eight decimal places
of a lot instead of four. Nothing is created or changed; an account without enough free
margin is a normal answer and not an error.
Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
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: 10 s (read). 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.
Calculate the rate of buying a currency for another one
POST /api/v2/MT5/{tradePlatform}/TradeRateBuy
Calculates how much of the calculation currency pays for one unit of the base currency
when it is bought. With a group the spread adjustment of that group is applied; without
it the market prices are used. A symbol and its price replace the market quote of that
symbol in the calculation, unless the symbol is always converted at the market price.
Nothing is created or changed. The rate is built from current market data, so the
connection must have the orders and positions of the platform loaded.
Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
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: 10 s (read). 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
TradeRateRequest (application/json) — Conditions of the calculation.
Calculate the rate of selling a currency for another one
POST /api/v2/MT5/{tradePlatform}/TradeRateSell
The same calculation as TradeRateBuy for a sale: how much of the calculation
currency is received for one unit of the base currency. Nothing is created or changed.
Timeout: 10 s by default, adjustable per request with the X-Request-Timeout header. When the trade server does not answer in time: Nothing was changed; the request is safe to repeat.
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: 10 s (read). 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
TradeRateRequest (application/json) — Conditions of the calculation.
Types the operations above take and return, with their first-level properties; * marks a required one. The full graph is in the OpenAPI specification.
BooleanApiResponse
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.
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.
confirmed volume on gateway with extended accuracy (1/100000000 lot)
MT5RequestListApiResponse
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.
TradeAccountSetRequest
State of an account taken from an external trading system, v2 request record.
Property
Type
Description
requestId
integer (int64), nullable
Caller-side identifier used to tie the call to its completion event; optional.
login
integer (int64)
Login of the account whose data is synchronised.
balance
number (double), nullable
Balance the account must have after the synchronisation.
Direction of the hypothetical position; only buy and sell are meaningful here.
volume
integer (int64)
Position volume; one unit is 1/10000 lot in the standard variant and 1/100000000 in the extended one.
priceOpen
number (double)
Open price of the hypothetical position.
priceClose
number (double)
Close price of the hypothetical position.
TradeProfitResultApiResponse
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.
TradeMarginCheckRequest
Order whose margin requirement is checked, v2 request record.
Property
Type
Description
login
integer (int64)
Login of the account the hypothetical order would be placed on.
Order volume; one unit is 1/10000 lot in the standard variant and 1/100000000 in the extended one.
price
number (double)
Execution price of the hypothetical order.
TradeMarginCheckResultApiResponse
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.
TradeRateRequest
Conditions of a conversion rate calculation, v2 request record.
Property
Type
Description
base
string, nullable
Currency bought or sold, a three-letter code such as EUR.
currency
string, nullable
Currency the base currency is paid with, a three-letter code such as USD.
group
string, nullable
Group whose spread adjustment is applied; omitted means market prices.
symbol
string, nullable
Symbol to use in place of the market one.
price
number (double), nullable
Price of the symbol above; ignored for the symbols always converted at the market price.
TradeRateResultApiResponse
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.
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.
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.
MT5Request
Property
Type
Description
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.
Gets and sets the order placing time in milliseconds, since 1970.01.01 If the value of this field is specified, the TimeSetup value will be filled in automatically.
timeDoneMsc
string (date-time), nullable
Gets and sets the order execution time in milliseconds, since 1970.01.01 If the value of this field is specified, the TimeDone value will be filled in automatically.
rateMargin
number (double), nullable
margin conversion rate (from symbol margin currency to deposit currency)
positionByID
integer (int64), nullable
position by id
modificationFlags
TradeModifyFlags
modification flags
volumeInitialExt
integer (int64), nullable
order initial volume in units of 1/100,000,000 lot
volumeCurrentExt
integer (int64), nullable
order current volume in units of 1/100,000,000 lot
MT5Position
Property
Type
Description
login
integer (int64), nullable
Gets the login of the client, to whom the trade position belongs
symbol
string, nullable
position symbol
action
PositionActions
PositionAction
digits
integer (int32), nullable
price digits
digitsCurrency
integer (int32), nullable
currency digits
contractSize
number (double), nullable
symbol contract size
position
integer (int64), nullable
position ticket
externalId
string, nullable
The ticket of a position in an external trading system
timeCreate
string (date-time), nullable
position create time
timeUpdate
string (date-time), nullable
position last update time
timeCreateMsc
string (date-time), nullable
position create time in msc since 1970.01.01 If the value of this field is specified, the TimeCreate value will be filled in automatically.
timeUpdateMsc
string (date-time), nullable
position last update time in msc since 1970.01.01 If the value of this field is specified, the TimeUpdate value will be filled in automatically.
priceOpen
number (double), nullable
position weighted average open price
priceCurrent
number (double), nullable
position current price
priceSL
number (double), nullable
position SL price
priceTP
number (double), nullable
position TP price
volume
integer (int64), nullable
position volume in units of 1/10,000 lot
volumeExt
integer (int64), nullable
position volume in units of 1/100,000,000 lot
profit
number (double), nullable
position floating profit
storage
number (double), nullable
position accumulated swaps
obsoleteValue
number (double), nullable
obsolete value kept by the platform for compatibility
rateProfit
number (double), nullable
profit conversion rate (from symbol profit currency to deposit currency)
rateMargin
number (double), nullable
margin conversion rate (from symbol margin currency to deposit currency)
expertId
integer (int64), nullable
expert id (filled by expert advisor)
expertPositionId
integer (int64), nullable
expert position id
comment
string, nullable
dealer
integer (int64), nullable
The login of a dealer, who has processed the order that opened the position. 0 means that the order was processed automatically by the server
activationMode
ActivationModes
order activation state, time and price
activationTime
string (date-time), nullable
activationPrice
number (double), nullable
activationFlags
TradeActivationFlags
modificationFlags
TradeModifyFlags
modification flags
reason
PositionReasons
position reason - PositionReason
actionGateway
integer (int32), nullable
action performed on the gateway side
priceGateway
number (double), nullable
position price on gateway
volumeGatewayExt
integer (int64), nullable
volume on gateway with extended accuracy (1/100000000 lot)