CPlugin

MT4 v2 :: Backup (destructive)

API v2 (beta) · 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 from https://auth.cplugin.net/connect/token (scope webapi). $TRADE_PLATFORM_ID is the id of a trade platform registered in Toolbox.

Operations

Restore users from backup

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

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

Manager (live) call to the wrapper'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 (see DTO docs).

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.

Manager (live) call to the wrapper'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 input DTO 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 wrapper 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). HTTP status is always 200.

PropertyTypeDescription
data boolean
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId is the W3C trace-id for correlation in Seq/SigNoz. Paging is present only on paginated list responses; otherwise it is omitted — the global JSON context policy serialises null fields, so we override that here with System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull.

MT4TradeRestoreInput

v2 narrow input DTO 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 wrapper 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 wrapper 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). HTTP status is always 200.

PropertyTypeDescription
data MT4TradeRestoreResult[]
error ApiError v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.
meta ApiMeta Response metadata. ActivityId is the W3C trace-id for correlation in Seq/SigNoz. Paging is present only on paginated list responses; otherwise it is omitted — the global JSON context policy serialises null fields, so we override that here with System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull.

ApiError

v2 error body. Code is the stable transport error code; ManagerCode is the raw MT4 ResultCode (serialized as a string for a known enum member, or as a number for an unrecognised value returned by MT4); Message is a human-readable description.

PropertyTypeDescription
code WebApiErrorCode Stable transport-level error code.
managerCode ResultCode Raw MT4/MT5 manager result code, when the error came from the trading platform; otherwise null.
message string, nullable Human-readable error description.

ApiMeta

Response metadata. ActivityId is the W3C trace-id for correlation in Seq/SigNoz. Paging is present only on paginated list responses; otherwise it is omitted — the global JSON context policy serialises null fields, so we override that here with System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull.

PropertyTypeDescription
activityId string, nullable W3C trace id for correlating this response in logs and tracing (Seq/SigNoz).
paging PagingMeta Pagination info; present only on list responses, omitted otherwise.

TradeCommand

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

MT4TradeRestoreResult

v2 DTO for a single per-order result of a backup-restore operation. Mirrors the wrapper'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