MT Cloud API
Build an MT5 workflow you can inspect.
Provision accounts, deploy hosted terminals, copy trades, read terminal state, and manage risk through a tenant-scoped HTTPS API.
https://api.mtcloudapi.com/api/v1Formatapplication/jsonPublic limit300 requests/minuteStart here
Quickstart
Create an account, copy the API key shown once, then use it to create an MT5 account record. The example below does not deploy or bill the terminal by itself.
curl -X POST https://api.mtcloudapi.com/api/v1/accounts \
-H "Authorization: Bearer $MT_CLOUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"login": "5001234",
"password": "your-mt5-password",
"server": "Broker-Live",
"platform": "mt5",
"role": "master",
"label": "Primary master",
"accessMode": "full",
"autoDeploy": false,
"allowDirectTrading": false
}'Success
201 Created returns the saved account and a Location header.
Server discovery
202 Accepted can return an account plus broker-server search state. Inspect that state before deployment.
Next
Deploy the returned account ID, then poll connection status until the terminal is connected.
Access
Authentication & scopes
Send the key as a Bearer token on every protected request. Keys begin with mtc_; only their hash is stored and plaintext is shown once on create or rotate.
Authorization: Bearer mtc_your_key| Scope | Purpose |
|---|---|
accounts:read | Accounts, terminal state, stats, equity, usage, events, and streams. |
accounts:write | Create, edit, deploy, undeploy, delete, and protect accounts. |
relationships:read | Copy relationships, strategies, risk state, and risk events. |
relationships:write | Create, update, delete, or protect copy relationships. |
trade:read / trade:write | Read command outcomes / submit direct trade commands. |
keys:manage | List, create, rotate, and revoke API keys. |
webhooks:manage | List, create, remove, and replay webhook deliveries. |
Account lifecycle
Accounts
An account record holds the encrypted MT5 credentials and operating choices. Creating a record does not necessarily mean the hosted terminal is deployed.
/accountsaccounts:writeCreates an MT5 account. Required: login, password, and server. Role is master or slave; access mode is full or investor.
/accountsaccounts:readLists account views for the current tenant.
/accounts/{id}accounts:writeUpdates label, role, auto-deploy, access mode, and direct-trading permission.
/accounts/{id}accounts:writeUndeploys and permanently removes the account record. Confirm this action in your application.
Broker server lookup
Use GET /servers?q=xm for saved matches. If automatic detection cannot resolve the broker, the API also accepts an uploaded provisioning profile.
Hosted terminal
Deployment
curl -X POST \
https://api.mtcloudapi.com/api/v1/accounts/$ACCOUNT_ID/deploy \
-H "Authorization: Bearer $MT_CLOUD_API_KEY"200 deployed
The response includes the action and resulting state.
202 searching
The broker server is still resolving. Respect the Retry-After header.
402 payment required
The balance does not cover one hour. Open the returned top-up URL, then deploy again. A deployed terminal costs $0.02 per hour.
403 verification required
Confirm the tenant email before the first deployment.
/accounts/{id}/undeployaccounts:writeStops the hosted terminal but keeps the account record.
/accounts/{id}/redeployaccounts:writeRestarts a deployed terminal. Billing checks still apply.
/accounts/{id}/connection-statusaccounts:readReturns connection state and the latest available heartbeat information.
Terminal snapshots
Account information, positions & history
Terminal endpoints require a synchronized snapshot. Responses include synchronization metadata where applicable; 409 terminal_not_synchronized means the terminal is not ready yet.
GET /accounts/{id}/account-informationBalance, equity, margin, currency, and account metadata.GET /accounts/{id}/positionsOpen positions and synchronization state.GET /accounts/{id}/ordersPending orders and synchronization state.GET /accounts/{id}/dealsPaginated deals with date, ticket, and position filters.GET /accounts/{id}/history-ordersPaginated historical orders.GET /accounts/{id}/symbolsAvailable symbols, specifications, and latest ticks.Scope: accounts:read
Realtime
Live stream
Open wss://api.mtcloudapi.com/api/v1/stream with the same API key. Server-side clients send the Authorization: Bearer header. Browser clients pass the key as a WebSocket subprotocol: new WebSocket(url, ["mtc", "mtc-key.mtc_..."]), which keeps it out of URLs and logs. The older ?api_key= query form still works but is deprecated. The first message is session. Then send commands as text frames.
{ "type": "sync", "accountId": "..." }
{ "type": "subscribeQuotes", "accountId": "...", "symbols": [] }
{ "type": "resume", "after": 120 }syncreturnssnapshotwith account information, positions, orders, and recent deals.- An empty
symbolslist subscribes to every quote. A list subscribes to those symbols only, up to 20. - Live frames use
eventType:Snapshot,Quote,Heartbeat,Disconnected, plus trade and copy events. Each hassequence. resumereplays a short buffer.resyncRequiredmeans callsyncagain.
Trade routing
Copy relationships
curl -X POST https://api.mtcloudapi.com/api/v1/relationships \
-H "Authorization: Bearer $MT_CLOUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"masterAccountId": "MASTER_UUID",
"slaveAccountId": "SLAVE_UUID",
"volumeMode": "multiplier",
"volumeMultiplier": 1,
"sideFilter": "all",
"copyStops": true,
"copyMode": "all",
"unsubscribeAction": "leave"
}'Master and slave must be different accounts owned by the same tenant. Optional controls include fixed volume, symbol and magic filters, symbol mapping, reverse direction, leverage/SL filters, signal delay, and trading hours.
GET /relationshipsList routes with relationships:read.PATCH /relationships/{id}Enable, pause, or update route settings.DELETE /relationships/{id}Remove the route and apply unsubscribe behavior.POST /strategiesCreate strategy metadata for a master account.PUT /relationships/{id}/strategyAssign or clear a route strategy.POST /signalsPush an idempotent external-strategy signal.Measurement & protection
Analytics & risk
GET /accounts/{id}/statsTrades, win rate, profit factor, expectancy, drawdown, equity curve, and breakdowns.GET /accounts/{id}/equityRecorded equity samples ordered by time.PUT /relationships/{id}/riskRelationship-level daily, weekly, monthly, lifetime, drawdown, lot, and target limits.GET /relationships/{id}/risk/eventsInspect recorded risk events for a route.GET /accounts/{id}/riskAccount-level rules plus live status: status (active or paused), reason, pausedAt, equity, openPositions.PUT /accounts/{id}/riskApply the same protection model at account level, plus equityFloor and equityFloorPercent.POST /accounts/{id}/kill-switchDisable every copy route into the account, pause it, and close every open position now.POST /accounts/{id}/risk/resetClear a pause and restart the measurement period. Routes stay disabled until you enable them.POST /blackoutsCreate a symbol-specific blackout window.{
"dailyLoss": 500,
"drawdownAmount": 1200,
"maxLot": 1,
"maxOpenLots": 3,
"profitTarget": 2500,
"equityFloor": 9500,
"equityFloorPercent": 5
}Equity kill switch
The equity floor is a hard stop at account level. equityFloor is an absolute equity in account currency; equityFloorPercent is a drop from the equity recorded when the account started copying. The hub checks connected accounts every few seconds, and the moment equity is under either floor it fires the same action as the manual kill switch: every copy route into the account is disabled, the account is marked paused with reason equity_floor or equity_floor_percent, and every open position and pending order is closed through the terminal. The pause also blocks new copies on the fast path until you call the reset endpoint.
curl -X POST https://api.mtcloudapi.com/api/v1/accounts/{id}/kill-switch \
-H "Authorization: Bearer $MT_CLOUD_KEY" -H "Content-Type: application/json" \
-d '{"closePositions": true, "reason": "manual_kill"}'
{ "accountId": "…", "status": "paused", "reason": "manual_kill",
"relationshipsDisabled": 2, "closeCommands": 5, "equity": 9842.10 }Set closePositions to false to pause copying without flattening. The call needs the accounts:write scope; reading GET /accounts/{id}/risk needs accounts:read. Every kill switch, whether manual or automatic, is recorded as a KillSwitch event with one KillSwitchClose or KillSwitchCancel event per ticket, so GET /events and webhooks show exactly what was closed.
Proof
Public status
GET /api/v1/status needs no API key and returns the numbers behind the status page: 30-day and 24-hour uptime, p50 and p95 copy latency over the last 24 hours, terminals connected, and trades copied. Latency is measured inside the hub from the moment a master trade event arrives until the slave command is on the wire (dispatch) and until the slave terminal acknowledges the fill (ack). Responses are cacheable for 60 seconds and allow cross-origin reads.
curl https://api.mtcloudapi.com/api/v1/status
{ "healthy": true,
"uptime": { "percent30d": 99.98, "percent24h": 100, "minutesTracked30d": 43200, "trackingSince": "…" },
"copyLatencyMs": { "dispatchP50": 4, "dispatchP95": 11, "ackP50": 92, "ackP95": 240, "samples24h": 318, "window": "24h" },
"terminals": { "connected": 12, "deployed": 14 },
"tradesCopied": { "last24h": 318, "last30d": 6210, "total": 48102 } }Optional execution
Direct trading
Direct trading is available only when the account is not investor-only and allowDirectTrading is enabled. Every write requires an Idempotency-Key header.
curl -X POST https://api.mtcloudapi.com/api/v1/accounts/$ACCOUNT_ID/trade \
-H "Authorization: Bearer $MT_CLOUD_TRADE_KEY" \
-H "Idempotency-Key: order-2026-10-21-001" \
-H "Content-Type: application/json" \
-d '{
"action": "open",
"symbol": "EURUSD",
"side": "BUY",
"orderType": "MARKET",
"volume": 0.1
}'202 Accepted returns a command that is pending or sent. Poll GET /trade-commands/{commandId} with trade:read. Reusing an idempotency key with a different payload returns 409 idempotency_key_conflict.
Operations
API keys & webhooks
Key lifecycle
Use keys:manage to list, create, rotate, and revoke keys. A create request accepts a label, scopes, and optional future expiry. The plaintext key appears once.
GET /api-keysPOST /api-keysPOST /api-keys/{keyId}/rotateDELETE /api-keys/{keyId}
Webhook lifecycle
Use webhooks:manage. The URL must be absolute HTTP(S); events can contain account, trade, and copy. Store the signing secret returned once.
GET /webhooksPOST /webhooksDELETE /webhooks/{webhookId}POST /webhooks/deliveries/{deliveryId}/replay
Reading safely
Pagination, filtering & synchronization
- Deals and history orders: send
cursorfrom the previousnextCursor; optional filters includefrom,to,ticket,positionId, andlimit. - Tenant trades: including the
cursorquery returns the paged object withitemsandnextCursor. - Tenant events: pass the last event cursor to continue backwards through the timeline.
- Terminal reads: inspect synchronization metadata and retry only when the terminal is connected and a snapshot is available.
Failure handling
Errors & safe retries
Non-success responses use one stable envelope. Log the request ID when contacting support.
{
"error": {
"code": "terminal_not_synchronized",
"message": "The terminal has not synchronized yet.",
"requestId": "0HN...",
"details": null
}
}| Status | Meaning | Client action |
|---|---|---|
400 | Invalid request or missing idempotency key. | Fix the request; do not retry unchanged. |
401 | Missing, invalid, expired, or revoked key. | Use a valid server-side key. |
402 | Deployment needs payment. | Complete the returned invoice, then retry. |
403 | Scope, verification, or direct-trading restriction. | Change permission/state; do not loop. |
404 | Tenant-scoped resource not found. | Check the ID and tenant. |
409 | State conflict, unsynchronized terminal, or reused idempotency key. | Inspect the error code before retrying. |
429 | Rate limit reached. | Back off and retry after the indicated window. |
Reference map
Endpoint index
This page explains common workflows. The machine-readable schemas, complete request models, and response definitions live in the OpenAPI explorer.
Accounts & terminal
GET/POST /accounts · GET/PATCH/DELETE /accounts/{id} · POST /accounts/{id}/deploy|undeploy|redeploy · GET /accounts/{id}/connection-status|account-information|positions|orders|deals|history-orders|symbols|stats|equity · GET /servers
Risk & kill switch
GET/PUT /accounts/{id}/risk · POST /accounts/{id}/risk/reset · POST /accounts/{id}/kill-switch · PUT /relationships/{id}/risk · POST /relationships/{id}/risk/reset · GET /relationships/{id}/risk/events
Copier & strategy
GET/POST /relationships · GET/PATCH/DELETE /relationships/{id} · relationship risk and strategy endpoints · GET/POST /strategies · POST /signals · POST /blackouts
Public (no key)
GET /api/v1/status · GET /healthz
Trading & activity
POST /accounts/{id}/trade · GET /trade-commands/{commandId} · GET /trades · GET /events · GET /stream
Developer management
API key create/list/rotate/revoke · webhook create/list/delete/replay · GET /usage · provisioning profile upload.
Need the exact schema?
Use the OpenAPI explorer as the canonical contract.