POST /organization/trading-accounts/{accountId}/flatten. To cancel working
orders and leave positions open, see
Cancel orders without closing.
Requires manage permission on traders.
Close a position
Whole or partial close
A whole-position close does for one contract what flatten does for the
whole account.
Response
side is the position’s direction before the close. remainingQuantity is
what is left open on the contract; closed is true when nothing is.
What else happens
The close is an ordinary market order. It fills at the market price with the usual commissions and updates the balance and rules like any other close.- Real-time stream: the usual
OrderSubmitted,OrderFilled,PositionUpdateandAccountUpdatemessages, andOrderCancelledfor each cancelled order. - Order history: the orders carry reason
Admin flatten: <who> — <your reason>and triggeradmin_flatten, like a flatten. - Event log and webhooks: an
ACCOUNT_UPDATEDevent with triggeradmin_position_close, who closed it, the contract, the quantity closed, what remains and the number of cancelled orders, sent toaccount.updatedwebhook subscribers.
Market hours
A close is refused with409 MARKET_CLOSED while the contract’s market is
closed, for example during the daily break, at the weekend or on a
holiday. Nothing is closed; send it again once the market is open.
Retries
Send anIdempotency-Key header. A retry with the same key and body returns
the first response and never closes twice. Without a key, repeating a
whole-position close is safe: once the position is gone it answers
404 NO_POSITION. Repeating a partial close without a key closes more.
If the call ends with 504 CLOSE_OUTCOME_UNKNOWN, the position may or may
not have been closed: read the account’s positions
(GET /organization/trading-accounts/{accountId}/positions) before you
retry.
Errors
Cancel orders without closing
Cancel an account’s working orders and leave every position open, for example to stop new entries while a trade is reviewed. The account keeps its status and the trader can keep trading.
The default matches a trader’s “Cancel all”. Requires manage permission on
traders. Unlike a close, it also works while the market is closed.
ordersCancelled counts the orders this call cancelled; exitsKept the
take-profit and stop-loss orders left working.
- Real-time stream: an
OrderCancelledmessage for each cancelled order. - Order history: the orders carry reason
Admin cancel: <who> — <your reason>and triggeradmin_flatten. - Event log and webhooks: when anything was cancelled, an
ACCOUNT_UPDATEDevent with triggeradmin_orders_cancel, who cancelled, the contract filter,include_exitsand the counts, sent toaccount.updatedwebhook subscribers.
ordersCancelled: 0. On 504 CANCEL_OUTCOME_UNKNOWN, some orders may have
been cancelled; send the call again.