Skip to main content

Place an Order

API URL: POST https://api.topstepx.com/api/Order/place

API Reference: /api/Order/place

Description


Place an order.

Parameters


NameTypeDescriptionRequiredNullable
accountIdintegerThe account ID.Requiredfalse
contractIdstringThe contract ID.Requiredfalse
typeintegerThe order type:
1 = Limit
2 = Market
4 = Stop
5 = TrailingStop
6 = JoinBid
7 = JoinAsk
Requiredfalse
sideintegerThe side of the order:
0 = Bid (buy)
1 = Ask (sell)
Requiredfalse
sizeintegerThe size of the order.Requiredfalse
limitPricedecimalThe limit price for the order, if applicable.Optionaltrue
stopPricedecimalThe stop price for the order, if applicable.Optionaltrue
trailPricedecimalTrailingStop (type 5) only, and required for that type. The absolute price level the trailing stop starts at, not a distance. See trailPrice.Optionaltrue
customTagstringAn optional custom tag for the order. Must be unique across the account.Optionaltrue
stopLossBracketobjectStop loss bracket configuration.Optionaltrue
takeProfitBracketobjectTake profit bracket configuration.Optionaltrue

Bracket Objects

stopLossBracket

NameTypeDescriptionRequiredNullable
ticksintegerNumber of ticks for stop lossRequiredfalse
typeintegerType of stop loss bracket. Uses same OrderType enum values:
1 = Limit
2 = Market
4 = Stop
5 = TrailingStop
6 = JoinBid
7 = JoinAsk
Requiredfalse

takeProfitBracket

NameTypeDescriptionRequiredNullable
ticksintegerNumber of ticks for take profitRequiredfalse
typeintegerType of take profit bracket. Uses same OrderType enum values:
1 = Limit
2 = Market
4 = Stop
5 = TrailingStop
6 = JoinBid
7 = JoinAsk
Requiredfalse

Bracket mode

Each account has a bracket mode, set in the trading platform under Settings > Risk Settings:

  • Position Brackets (default). Brackets are managed at the position level by the platform. stopLossBracket and takeProfitBracket are not accepted on this endpoint.
  • Auto OCO Brackets. Brackets attach to each order. stopLossBracket and takeProfitBracket are accepted on this endpoint.

Sending either bracket object while the account is in Position Brackets mode rejects the order with errorCode 2 and the message Brackets cannot be used with Position Brackets. You must enable Auto OCO Brackets. The rejected order is still created and its ID is returned in orderId. To fix this, switch the account to Auto OCO Brackets, or omit the bracket objects.

trailPrice (TrailingStop orders)

trailPrice applies only to order type 5 (TrailingStop) and is required for that type. It is an absolute price level, not a trail distance. When the request arrives, the server measures the gap between the contract's last traded price and trailPrice and converts it to a whole number of ticks:

trailDistanceTicks = |lastTradedPrice - trailPrice| / tickSize
  • The last traded price is read on the server at the moment the order is received. In a fast-moving market the same trailPrice can produce a different tick distance than you expected.
  • Fractions of a tick are dropped.
  • Once accepted, the distance is fixed in ticks and the stop price trails the market by that many ticks.
  • trailPrice must be aligned to the contract's tick size.

Example. A contract with a 0.01 tick size last traded at 70.50. For a trailing stop 6 ticks away, send the price level 6 ticks from the market: 70.44 for a sell stop (side 1), or 70.56 for a buy stop (side 0). Do not send the distance itself. A trailPrice of 0.06 is read as a price level near zero, which works out to a distance of 7044 ticks and is rejected.

A rejected trailPrice returns errorCode 2 with one of these messages:

errorMessageCause
Trail Distance not set.type is 5 but trailPrice is null.
Invalid trail price. Price is not aligned to tick size.trailPrice is not a multiple of the contract's tick size.
Cannot trail without a last priceThe contract has no last traded price yet, so there is nothing to measure the distance from.
Invalid symbolNo quote is available for the contract.
Trail Distance exceeds maximum (1000)The computed distance is more than 1000 ticks. The usual cause is sending a distance instead of a price level.

When a trailing stop is returned by the order search endpoints, its trailPrice holds the trail distance expressed in price (ticks x tickSize), not the price level that was submitted. Using the example above, the order reads back with trailPrice 0.06. See Search for Orders.

Error Codes


errorCodeNameMeaning
0SuccessThe order was accepted.
1AccountNotFoundThe account does not exist or is not owned by the caller.
2OrderRejectedThe order was rejected. errorMessage states the reason.
3InsufficientFundsThe account does not have enough funds for the order.
4AccountViolationThe account is in violation and cannot place orders.
5OutsideTradingHoursThe market is not open for the contract.
6OrderPendingThe order is still being processed.
7UnknownErrorAn unexpected error occurred.
8ContractNotFoundThe contract ID is not recognized.
9ContractNotActiveThe contract is not the currently active contract.
10AccountRejectedThe account is not allowed to place orders.

errorCode 2 covers every validation rejection, including unsupported order type, invalid side or size, an invalid trailPrice, a duplicate customTag, and bracket rules. Always read errorMessage to identify the specific cause.

Example Usage


Example Request

curl -X 'POST' \
'https://api.topstepx.com/api/Order/place' \
-H 'accept: text/plain' \
-H 'Content-Type: application/json' \
-d '{
"accountId": 465,
"contractId": "CON.F.US.DA6.M25",
"type": 2,
"side": 1,
"size": 1,
"limitPrice": null,
"stopPrice": null,
"trailPrice": null,
"customTag": null,
"stopLossBracket": {
"ticks": 10,
"type": 4
},
"takeProfitBracket": {
"ticks": 20,
"type": 1
}
}'

Example Response

{
"orderId": 9056,
"success": true,
"errorCode": 0,
"errorMessage": null
}