Skip to main content
DELETE 

/us/order/cancel

Cancel Order

API to cancel an open US stocks order. Pass the order_id you received when you placed the order. A successful request returns the same order_id. Use Get Order Details to confirm the final status. Cancel Order allows 3 requests per second. See US Stocks rate limits.

  • You can cancel an order whose status is open, scheduled, queued or partially_complete. This includes an after-market order waiting for the next regular session.
  • An order that has already finished (complete, cancelled, cancelled_partially, failed, failed_partially or expired) can't be cancelled. The request returns UDAPI100040.
  • US orders can't be modified. To change an open order, cancel it and place a new order.
  • If the request returns UDAPI1319, the cancellation may still have gone through. Check the order book before you retry.

Query Parameters​

NameRequiredTypeDescription
order_idRequiredstringID of the order to cancel. Accepts alphanumeric characters and -.

Request​

curl --location --request DELETE 'https://api.upstox.com/v2/us/order/cancel?order_id=1a9ecf08-e5f8-475c-a7c0-9056826d4b18' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'

For samples in other languages, see the Sample Code section on this page.

Responses​

Response Body​

{
"status": "success",
"data": {
"order_id": "1a9ecf08-e5f8-475c-a7c0-9056826d4b18"
}
}
NameTypeDescription
statusstringOutcome of the request. Typically success.
dataobjectResponse data for the cancel order request.
data.order_idstringID of the cancelled order.

Sample Code​

Cancel an open order​

import requests

url = 'https://api.upstox.com/v2/us/order/cancel?order_id=1a9ecf08-e5f8-475c-a7c0-9056826d4b18'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}

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

print(response.status_code)
print(response.json())