Skip to main content

Cancel Order V3 Sandbox Enabled

API to cancel an open or pending order which can be applied to both After Market Orders (AMO) and regular orders.

Additionally this API includes latency information in the meta data object of the response, providing insight into the time Upstox took to process your request.

Request

curl --location --request DELETE 'https://api-hft.upstox.com/v3/order/cancel?order_id=240108010445130' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'

For additional samples in various languages, please refer to the Sample code section on this page.


Query Parameters

NameRequiredTypeDescription
order_idtruestringThe order ID for which the order must be cancelled. For the regex pattern applicable to this field, see the Field Pattern Appendix.
Responses

Response Body

{
"status": "success",
"data": {
"order_id": "1644490272000"
},
"metadata": {
"latency": 30
}
}
NameTypeDescription
statusstringA string indicating the outcome of the request. Typically success for successful operations.
dataobjectResponse data for Cancel order request
data.order_idstringReference order ID
metadataobjectOrder metadata associated with successful cancelled order.
metadata.latencyintegerThe overall time taken by API platform to process the order cancellation request, measured in milliseconds.

Sample Code

Cancel an open order

import requests

url = 'https://api-hft.upstox.com/v3/order/cancel?order_id=240108010445130'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}

response = requests.delete(url, headers=headers)

print(response.text)
Loading...