Liquidate Positions

View as Markdown
### Cancel working orders and flatten multiple positions. **Available to:** All authenticated users **Environments:** Demo, Live **[Rate Limit](/api/authentication#request-rate-limits-and-time-penalties):** 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`](/api/rest-api-endpoints/orders/liquidate-position) 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. <Warning> Set `isAutomated` to `true` when this is triggered by code or an automated process, and `false` only when a human triggers it directly. </Warning> 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** - `admin` is `true` but 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 `customTag50` is missing or unregistered. **Error Messages** | `errorText` | Trigger | |-------------|---------| | Non-empty `errorText` | At least one position failed to liquidate; the field reports the first failure's reason. | When `ok` is `true`, `errorText` is empty and all positions were flattened.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Request

This endpoint expects an object.
positionslist of longsRequired
adminbooleanRequired
customTag50stringOptional<=64 characters
isAutomatedbooleanOptional

Response

SimpleResponse
okboolean
errorTextstring<=8192 characters

Non-empty if the request failed