CPlugin

MT4 v2 :: Backup (destructive)

API v2 (current) · MT4 · 2 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

Restore users from backup

POST /api/v2/MT4/{tradePlatform}/BackupRestoreUsers

Restore user records into the live MT4 database. Destructive — requires ?confirm=true.

Server-side call to the platform's BackupRestoreUsers(UserRecord[] users). Each input MT4UserRestoreInput is mapped to a fresh UserRecord with the narrow restore field set — secrets, OTP, server-managed timestamps, and reserved blobs are NOT carried (the §MT4User fields are listed on the users page).

Idempotency-Key header is strongly recommended: a network blip during a multi-user restore can leave the client uncertain whether the write happened. Without the key, retry will double-write.

Batch cap: 10000 records per call. Larger restores must be split.

Timeout: 60 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 id (GUID)
confirm query boolean no Required deliberateness flag — must equal true
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 60 s (server maintenance). 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

MT4UserRestoreInput[] (application/json) — Array of users to restore (1..10000 records)

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/BackupRestoreUsers" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[{ "login": 0, "group": "", "name": "", "email": "", "country": "", "leverage": 0 }]'

Restore orders from backup

POST /api/v2/MT4/{tradePlatform}/BackupRestoreOrders

Restore order records into the live MT4 database. Destructive — requires ?confirm=true.

Server-side call to the platform's BackupRestoreOrders(TradeRecord[] trades). Returns MT4TradeRestoreResult[] — one entry per input trade, with Order (ticket) and Res (0 = error, 1 = restored). Position in the response array matches position in the request.

Idempotency-Key header is strongly recommended. Batch cap: 10000 records per call.

Timeout: 60 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 id (GUID)
confirm query boolean no Required deliberateness flag — must equal true
X-Request-Timeout header number (double) no How long to wait for the trade server, in seconds (1–300). Default for this operation: 60 s (server maintenance). 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

MT4TradeRestoreInput[] (application/json) — Array of trades to restore (1..10000 records)

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/BackupRestoreOrders" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[{ "order": 0, "login": 0, "symbol": "", "tradeCommand": {}, "volume": 0, "openPrice": 0 }]'

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.

MT4UserRestoreInput

v2 narrow request for BackupRestoreUsers. Carries the account identity + persistent metadata + money/leverage state that a disaster-recovery flow needs to recreate.

PropertyTypeDescription
login integer (int32) Account login (record key)
group string, nullable Group name
name string, nullable Account holder display name
email string, nullable Email address
country string, nullable Country
leverage integer (int32) Trading leverage (e.g. 100 for 1:100)
balance number (double) Account balance (broker base currency)
credit number (double) Account credit (e.g. promotional bonus)
enable integer (int32) Account enabled flag (0 = disabled, 1 = enabled — raw platform int)
enableReadOnly integer (int32) Read-only flag (1 = cannot open positions)

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.

PropertyTypeDescription
data boolean
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.

MT4TradeRestoreInput

v2 narrow request for BackupRestoreOrders. Carries the trade identity + economic state that a disaster-recovery flow needs.

PropertyTypeDescription
order integer (int32) Order ticket (the input array position is the binding key for the result)
login integer (int32) Owner's login
symbol string, nullable Symbol (e.g. EURUSD; max 12 ASCII chars on the platform side)
tradeCommand TradeCommand Trade command (buy / sell / pending / balance / etc.)
volume integer (int32) Volume in 1/100 lots (15 = 0.15 lot)
openPrice number (double) Open price
sl number (double) Stop loss
tp number (double) Take profit
closePrice number (double) Close price (0 for still-open trades)
profit number (double) Trade profit/loss
storage number (double) Swap (rollover charge)
commission number (double) Commission
openTime string (date-time) Open time (UTC)
closeTime string (date-time) Close time (UTC; default for still-open)
expiration string (date-time) Expiration time (UTC; default for non-pending orders)
magic integer (int32) Magic number (EA identifier)
comment string, nullable Free-form comment (max ~31 ASCII chars on the platform side)

MT4TradeRestoreResultListApiResponse

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 MT4TradeRestoreResult[]
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.

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.

TradeCommand

Values: Buy, Sell, BuyLimit, SellLimit, BuyStop, SellStop, Balance, Credit

MT4TradeRestoreResult

v2 record for a single per-order result of a backup-restore operation. Mirrors the platform's TradeRestoreResult — order ticket plus a 1-byte status flag.

PropertyTypeDescription
order integer (int64) Order ticket from the input array (matches by position)
res integer (int32) Per-order restore status: 0 = error, 1 = restored