Cancel an Order
API URL: POST https://api.topstepx.com/api/Order/cancel
API Reference: /api/Order/cancel
Description
Cancel an order.
Parameters
| Name | Type | Description | Required | Nullable |
|---|---|---|---|---|
| accountId | integer | The account ID. | Required | false |
| orderId | integer | The order id. | Required | false |
Error Codes
| errorCode | Name | Meaning |
|---|---|---|
| 0 | Success | The cancellation was accepted. |
| 1 | AccountNotFound | The account does not exist or is not owned by the caller. |
| 2 | OrderNotFound | The order does not exist or does not belong to the account. |
| 3 | Rejected | The trading engine rejected the cancellation. |
| 4 | Pending | The cancellation is still being processed. |
| 5 | UnknownError | An unexpected error occurred. |
| 6 | AccountRejected | The 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.
| errorMessage | Cause |
|---|---|
Follower accounts cannot cancel orders | The account is a copy-trading follower. Follower accounts mirror a leader and cannot cancel orders directly. |
Live accounts not supported | The 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 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
- Error
{
"success": true,
"errorCode": 0,
"errorMessage": null
}
{
"success": false,
"errorCode": 6,
"errorMessage": "Follower accounts cannot cancel orders"
}