Place an Order
API URL: POST https://api.topstepx.com/api/Order/place
API Reference: /api/Order/place
Description
Place an order.
Parameters
| Name | Type | Description | Required | Nullable |
|---|---|---|---|---|
| accountId | integer | The account ID. | Required | false |
| contractId | string | The contract ID. | Required | false |
| type | integer | The order type: 1 = Limit 2 = Market 4 = Stop 5 = TrailingStop 6 = JoinBid 7 = JoinAsk | Required | false |
| side | integer | The side of the order: 0 = Bid (buy) 1 = Ask (sell) | Required | false |
| size | integer | The size of the order. | Required | false |
| limitPrice | decimal | The limit price for the order, if applicable. | Optional | true |
| stopPrice | decimal | The stop price for the order, if applicable. | Optional | true |
| trailPrice | decimal | TrailingStop (type 5) only, and required for that type. The absolute price level the trailing stop starts at, not a distance. See trailPrice. | Optional | true |
| customTag | string | An optional custom tag for the order. Must be unique across the account. | Optional | true |
| stopLossBracket | object | Stop loss bracket configuration. | Optional | true |
| takeProfitBracket | object | Take profit bracket configuration. | Optional | true |
Bracket Objects
stopLossBracket
| Name | Type | Description | Required | Nullable |
|---|---|---|---|---|
| ticks | integer | Number of ticks for stop loss | Required | false |
| type | integer | Type of stop loss bracket. Uses same OrderType enum values: 1 = Limit 2 = Market 4 = Stop 5 = TrailingStop 6 = JoinBid 7 = JoinAsk | Required | false |
takeProfitBracket
| Name | Type | Description | Required | Nullable |
|---|---|---|---|---|
| ticks | integer | Number of ticks for take profit | Required | false |
| type | integer | Type of take profit bracket. Uses same OrderType enum values: 1 = Limit 2 = Market 4 = Stop 5 = TrailingStop 6 = JoinBid 7 = JoinAsk | Required | false |
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.
stopLossBracketandtakeProfitBracketare not accepted on this endpoint. - Auto OCO Brackets. Brackets attach to each order.
stopLossBracketandtakeProfitBracketare 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
trailPricecan 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.
trailPricemust 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:
| errorMessage | Cause |
|---|---|
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 price | The contract has no last traded price yet, so there is nothing to measure the distance from. |
Invalid symbol | No 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
| errorCode | Name | Meaning |
|---|---|---|
| 0 | Success | The order was accepted. |
| 1 | AccountNotFound | The account does not exist or is not owned by the caller. |
| 2 | OrderRejected | The order was rejected. errorMessage states the reason. |
| 3 | InsufficientFunds | The account does not have enough funds for the order. |
| 4 | AccountViolation | The account is in violation and cannot place orders. |
| 5 | OutsideTradingHours | The market is not open for the contract. |
| 6 | OrderPending | The order is still being processed. |
| 7 | UnknownError | An unexpected error occurred. |
| 8 | ContractNotFound | The contract ID is not recognized. |
| 9 | ContractNotActive | The contract is not the currently active contract. |
| 10 | AccountRejected | The 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 Request
- cURL Request (TrailingStop)
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
}
}'
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.MCLE.Z26",
"type": 5,
"side": 1,
"size": 1,
"limitPrice": null,
"stopPrice": null,
"trailPrice": 70.44,
"customTag": null,
"stopLossBracket": null,
"takeProfitBracket": null
}'
Example Response
- Success
- Error
{
"orderId": 9056,
"success": true,
"errorCode": 0,
"errorMessage": null
}
{
"orderId": 9057,
"success": false,
"errorCode": 2,
"errorMessage": "Brackets cannot be used with Position Brackets. You must enable Auto OCO Brackets."
}