Trading
Place and manage orders on a connected account.
- Every write needs both a full-scope API key (
403 insufficient_scopeotherwise) and an account on a full slot (403 account_readonlyotherwise). The account must be connected (409 account_not_connected). - Volume and stops are validated against the symbol spec before anything is sent: off-step volumes return
422 invalid_volume(never rounded), stops on the wrong side or insidestops_levelreturn422 invalid_stops, and a symbol whosetrade_modeforbids the side returns422 symbol_not_tradeable. - Broker refusals return
422with status"rejected"and the raw MT5 retcode — never a5xx.
Market orders time out after 10 seconds
Market orders are synchronous with a hard 10 s cap. A 504 terminal_timeout does not mean the order failed — it may still have filled. Check the account’s positions before placing it again.
Send an Idempotency-Key on every write
Repeating a request with the same Idempotency-Key header within 24 hours replays the original response with HTTP 200 and Idempotent-Replayed: true, without touching the terminal — so a retried network call can never place a second order.
Place order
/v1/accounts/{id}/ordersOpen a market position, or place a limit/stop order. price is required for limit and stop, ignored for market. A limit buys below / sells above the market and a stop buys above / sells below; the price must be at least stops_level points away. expiration (ISO 8601) applies to pending orders only; omitted means good-till-cancelled. Response status is filled (market) or placed (pending). position_ticket equals the order ticket on hedging accounts.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
Idempotency-Key | header | No | Your own id for this order, e.g. the idea/signal id. Strongly recommended. |
{
"symbol": "XAUUSD.m",
"side": "buy",
"type": "market",
"volume": 0.12,
"price": null,
"sl": 2310.50,
"tp": 2362.00,
"deviation": 20,
"comment": "TickerAI idea 7f3a",
"expiration": null
}curl https://api.metakit.cloud/v1/accounts/123/orders \
-H "Authorization: Bearer stk_live_..." \
-H "Content-Type: application/json" \
-X POST \
-d '{
"symbol": "XAUUSD.m",
"side": "buy",
"type": "market",
"volume": 0.12,
"price": null,
"sl": 2310.50,
"tp": 2362.00,
"deviation": 20,
"comment": "TickerAI idea 7f3a",
"expiration": null
}'{
"status": "filled",
"order_ticket": 48812231,
"position_ticket": 48812231,
"deal_ticket": 91002817,
"fill_price": 2331.42,
"volume": 0.12,
"sl": 2310.50,
"tp": 2362.00,
"retcode": 10009,
"retcode_message": "Request completed",
"time": "2026-09-22T14:03:11.000Z"
}
// Broker refusal — 422:
{
"error": { "code": "order_rejected", "message": "There is not enough money to complete the request" },
"status": "rejected",
"retcode": 10019,
"retcode_message": "There is not enough money to complete the request"
}Modify position
/v1/accounts/{id}/positions/{ticket}Move the stop loss and/or take profit of an open position. A field you omit keeps its value; 0 or null clears it. Stops are checked against the current close price and stops_level before sending.
{ "sl": 2320.0, "tp": 2362.0 }curl https://api.metakit.cloud/v1/accounts/123/positions/123 \
-H "Authorization: Bearer stk_live_..." \
-H "Content-Type: application/json" \
-X PATCH \
-d '{ "sl": 2320.0, "tp": 2362.0 }'{
"status": "modified",
"order_ticket": null,
"position_ticket": 48812231,
"deal_ticket": null,
"fill_price": null,
"volume": 0.12,
"sl": 2320.0,
"tp": 2362.0,
"retcode": 10009,
"retcode_message": "Request completed",
"time": "2026-09-22T14:20:05.000Z"
}Close position
/v1/accounts/{id}/positions/{ticket}Close a position fully (no body, or no volume) or partially. A partial volume must be a multiple of volume_step and at most the open volume. Status is closed or partially_closed (with remaining_volume).
{ "volume": 0.06, "deviation": 20 }curl https://api.metakit.cloud/v1/accounts/123/positions/123 \
-H "Authorization: Bearer stk_live_..." \
-H "Content-Type: application/json" \
-X DELETE \
-d '{ "volume": 0.06, "deviation": 20 }'{
"status": "partially_closed",
"order_ticket": 48812902,
"position_ticket": 48812231,
"deal_ticket": 91003377,
"fill_price": 2340.10,
"volume": 0.06,
"remaining_volume": 0.06,
"sl": 2320.0,
"tp": 2362.0,
"retcode": 10009,
"retcode_message": "Request completed",
"time": "2026-09-22T14:41:30.000Z"
}Cancel order
/v1/accounts/{id}/orders/{ticket}Cancel a pending (limit/stop) order that has not filled.
curl https://api.metakit.cloud/v1/accounts/123/orders/123 \
-H "Authorization: Bearer stk_live_..." \
-X DELETE{
"status": "cancelled",
"order_ticket": 48813001,
"position_ticket": null,
"deal_ticket": null,
"fill_price": null,
"volume": 0.10,
"sl": 2340.0,
"tp": 2400.0,
"retcode": 10009,
"retcode_message": "Request completed",
"time": "2026-09-22T14:50:12.000Z"
}