Cancel Order
Cancel an open spot order.
HTTP
| Method | DELETE |
| Endpoint | /trade/api/v2/order |
Request Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
order_id | string | Yes | The order_id to cancel. |
Example
- Python
- Java
- Go
- Node.js
import requests
body = {"order_id": "698ed406-8ef5-4664-9779-f7978702a447"}
headers, path = sign_request("DELETE", "/trade/api/v2/order")
response = requests.delete(BASE_URL + path, headers=headers, json=body)
print(response.json())
HttpResponse<String> resp = client.send(
"DELETE", "/trade/api/v2/order", null,
Map.of("order_id", "698ed406-8ef5-4664-9779-f7978702a447"));
System.out.println(resp.body());
body := map[string]any{
"order_id": "698ed406-8ef5-4664-9779-f7978702a447",
}
bodyJSON, _ := json.Marshal(body)
headers, p, err := SignRequest("DELETE", "/trade/api/v2/order", nil)
if err != nil { panic(err) }
req, _ := http.NewRequest("DELETE", BaseURL+p, bytes.NewReader(bodyJSON))
for k, v := range headers { req.Header.Set(k, v) }
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
const {signRequest, BASE_URL} = require('./reference-client');
const body = {"order_id": "698ed406-8ef5-4664-9779-f7978702a447"};
const {headers, path} = signRequest('DELETE', '/trade/api/v2/order');
const r = await fetch(BASE_URL + path, {
method: 'DELETE',
headers,
body: JSON.stringify(body),
});
console.log(await r.json());
Response
{
"data": {
"order_id": "698ed406-8ef5-4664-9779-f7978702a447",
"symbol": "BTC/INR",
"price": 2300000,
"average_price": 0,
"orig_qty": 0.00005,
"executed_qty": 0,
"status": "CANCELLED",
"side": "SELL",
"exchange": "coinswitchx",
"order_source": "API_TRADING",
"created_time": 1689661638000,
"updated_time": 1689661639000
}
}
The response shape is the same as Create Order. The cancelled order's status will be CANCELLED once the exchange confirms, or CANCELLATION_RAISED while the cancel is still in flight at the exchange. See Order Lifecycle for the full state machine.
When cancellation isn't possible
- The order has already filled or expired (status is terminal).
- The exchange is in a
CANCELLATION_RAISEDwindow for the order — you must wait for confirmation. - The order is in a brief processing state (e.g. just placed but not yet acknowledged by the exchange).
In all cases, retry after a few hundred milliseconds and check the order's current status with Get Order.