Skip to main content

Cancel an Order

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

API Reference: /api/Order/cancel

Description


Cancel an order.

Parameters


NameTypeDescriptionRequiredNullable
accountIdintegerThe account ID.Requiredfalse
orderIdintegerThe order id.Requiredfalse

Error Codes


errorCodeNameMeaning
0SuccessThe cancellation was accepted.
1AccountNotFoundThe account does not exist or is not owned by the caller.
2OrderNotFoundThe order does not exist or does not belong to the account.
3RejectedThe trading engine rejected the cancellation.
4PendingThe cancellation is still being processed.
5UnknownErrorAn unexpected error occurred.
6AccountRejectedThe account is not allowed to cancel orders. See below.

errorCode 6 (AccountRejected)

This code is returned for more than one reason. Use errorMessage to tell them apart.

errorMessageCause
Follower accounts cannot cancel ordersThe account is a copy-trading follower. Follower accounts mirror a leader and cannot cancel orders directly.
Live accounts not supportedThe account is a live or brokerage account. This endpoint only supports simulated accounts.

Only simulated accounts that are not following another account can cancel orders through this endpoint.

Example Usage


Example Request

curl -X 'POST' \
'https://api.topstepx.com/api/Order/cancel' \
-H 'accept: text/plain' \
-H 'Content-Type: application/json' \
-d '{
"accountId": 465,
"orderId": 26974
}'

Example Response

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