Liquidate Positions
Cancel working orders and flatten multiple positions.
Available to: All authenticated users
Environments: Demo, Live
Rate Limit: 500 requests per hour, 1-second back-off, counts all requests
Flattens several positions in a single request. For each position in the positions array, the endpoint cancels the working orders tied to that position and closes the remaining position with a market order. To flatten one position at a time by accountId and contractId, use liquidatePosition instead.
The request body requires positions (an array of position IDs, maximum 100 entries) and the admin boolean. Setting admin to true requires admin privileges; non-admin callers must send false. The optional customTag50 carries a registered tag, and isAutomated should be set to true when a code or automated process triggers the request and false only when a human triggers it directly.
Set isAutomated to true when this is triggered by code or an automated process, and false only when a human triggers it directly.
Each position is liquidated independently, so the request can partially succeed: some positions may flatten while others fail. The endpoint returns a SimpleResponse with an ok boolean and an errorText field. ok is true only when every position liquidated without error; if any position fails, ok is false and errorText reports the first failure encountered. Inspect each account’s positions afterward to confirm the final state.
Common Failure Scenarios
administruebut the caller has no admin privileges.- A referenced position’s account is read-only or is not visible to the calling user.
- The trading session is closed or the market lacks the liquidity to close a position.
- A required
customTag50is missing or unregistered.
Error Messages
When ok is true, errorText is empty and all positions were flattened.
Authentication
Bearer authentication of the form Bearer <token>, where token is your auth token.
Request
Operator ID for the order. Send it only if NinjaTrader configured an allow-list of operator IDs for your user. In that case it’s required on every order and must exactly match one approved value. If no allow-list is configured, omit it: a supplied value is denied. Organizations using passthrough also omit it, and NinjaTrader fills it in. Up to 64 characters. See Operator ID (customTag50) and Passthrough.
Response
Non-empty if the request failed