CPlugin

MT4 v2 :: Plugins

API v2 (beta) · MT4 · 1 operation · 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

Send plugin command (JSON)

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

Plugin custom-command channel with JSON payload in both directions.

Manager (live) call wrapping ExternalCommandJSON. The MT4 server forwards the body to whichever installed plugin claims the command first; the first plugin returning RET_OK wins and its response becomes the v2 payload. The request body is sent verbatim (no field renaming, no schema enforcement) so the plugin author owns the over-the-wire contract on both ends.

The wrapper trio (ExternalCommand<TIn,TOut> for binary marshal, ExternalCommandCustom<T> for caller-supplied serializer) is intentionally not exposed in v2 — those variants require compile-time struct layouts shared between client and plugin, which a REST surface cannot guarantee. Plugin developers who need binary transport should keep using the wrapper directly from the WebAPI process or build a dedicated binary endpoint.

Idempotency-Key is strongly recommended — plugins may have side effects, and the channel itself gives no read-modify-write semantics.

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)
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

any (application/json, required) — The command as JSON, passed to the server plugin verbatim.

Responses

Example

curl -X POST "https://cloud.mywebapi.com/api/v2/MT4/$TRADE_PLATFORM_ID/ExternalCommandJSON" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

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.

JsonNodeApiResponse

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 JsonNode
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.

JsonNode

PropertyTypeDescription
options JsonNodeOptions
parent JsonNode
root JsonNode

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.