Trading API

Open an account position

post/rest/api/v1/accounts/{accountId}/positions

Path parameters

accountIdstring uuid required

Request body

commentstring

Max 31 characters (broker limit). When opening a position via /rest/api/v1/accounts/{accountId}/positions, an 'API|YOUR_REQUEST_ID|' prefix (5-8 chars) is prepended, so the effective user comment is ~23 chars before truncation. For modify requests, the full 31 characters are available.

magicNumberstring

At the moment, only numbers as string are supported

openPricenumber required

Used for pending orders (buy limit, stop limit, ...). For buy or sell you can enter 0.

orderType'Buy' | 'Sell' | 'BuyLimit' | 'SellLimit' | 'BuyStop' | 'SellStop' required
pendingExpirySecondsinteger

Native pending order expiry, in seconds from now. Only applies to pending orders (buyLimit, sellLimit, buyStop, sellStop) on MT4/MT5. The broker cancels the order automatically if it has not been filled within this time. Ignored for market orders and unsupported account types. Note: enforcement is broker-dependent; some brokers require a minimum expiry (e.g. at least a few minutes) or reject order expiry entirely. 0 or omitted means good-till-cancelled (no expiry).

relativeTpSlboolean

When true, stop loss and take profit values are interpreted as distance in points from the fill price. The position will be opened first, then automatically modified with the calculated absolute SL/TP prices. For cTrader accounts, the platform handles this natively. For all other account types (MT4, MT5, etc.), the SL/TP is set via a fire-and-forget modify order after the position is opened.

requestIdinteger required

A client request ID to avoid the request being executed multiple times due to network or client errors. The IDs start at 0 and increment up to 999, then begin again at 0.

stopLossnumber required

A value of 0 means no stop loss

symbolstring required
takeProfitnumber required

A value of 0 means no take profit

volumenumber required

In lots. The volume will be automatically adjusted according to the symbol data.

Response

No Content