Cancel Multi Orderโ
Use this API to cancel all open orders in one go. You can filter by segment or tag to cancel specific orders, or cancel all open orders with a single request. This applies to both AMO and regular orders. The order_ids of the cancelled orders will be returned in the response.
A maximum of 50 orders can be cancelled in a single request. Any request exceeding this limit will be rejected. The Cancel Multi Order API is subject to a different rate limit compared to the standard limits applied across the system. For more information on the rate limits for this API, please check here.
Requestโ
curl --location --request DELETE 'https://api.upstox.com/v2/order/multi/cancel' \
--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โ
| Name | Required | Type | Description |
|---|---|---|---|
| segment | false | string | The segment associated with the open orders. Possible values: NSE_EQ, BSE_EQ, NSE_FO, BSE_FO, MCX_FO, NCD_FO, BCD_FO, NSE_COM. |
| tag | false | string | The tag associated with the open orders. |
Responses
- 2XX
- 4XX
Response Bodyโ
- Success (200)
- Partial Success (207)
{
"status": "success",
"data": {
"order_ids": [
"1644490272000",
"1644490272001",
"1644490272003"
]
},
"errors": null,
"summary": {
"total": 3,
"success": 3,
"error": 0
}
}
| Name | Type | Description |
|---|---|---|
| status | string | A string indicating the outcome of the request. Possible values: success, partial_success, error.success - when all the cancel order request are successful. partial_success - when some cancel order request encountered errors. error - when all the cancel order request encountered errors. |
| data | object | Successful response data for cancel multi order request. |
| data.order_ids | array | List of reference order IDs associated with successfully cancelled orders. |
| errors | array | An array containing the main content of the error response for partial_success and error scenarios. |
| errors[].error_code | string | A specific error code. |
| errors[].message | string | Descriptive error message. |
| errors[].property_path | string | Indicates which part of the request triggered the error. It can be null. |
| errors[].invalid_value | string | Shows the value causing the error. It can be null. |
| errors[].instrument_key | string | A Key of instrument for a specific order. |
| errors[].order_id | string | Order ID associated to specific order. It can be null. |
| summary | object | A summary of the outcomes for the batch of orders processed, detailing total orders, successful completions, and errors. |
| summary.total | integer | The total number of order present in the payload for cancel multi orders. |
| summary.success | integer | Indicates the successful cancelled orders. |
| summary.error | integer | Indicates the unsuccessful cancelled orders. |
{
"status": "partial_success",
"data": {
"order_ids": [
"1644490272000",
"1644490272001",
"1644490272003"
]
},
"errors": [
{
"error_code": "UDAPI100500",
"message": "Something went wrong... please contact us",
"property_path": null,
"invalid_value": null,
"order_id": "240923010689802",
"instrument_key": "MCX_FO|436245"
}
],
"summary": {
"total": 4,
"success": 3,
"error": 1
}
}
| Name | Type | Description |
|---|---|---|
| status | string | A string indicating the outcome of the request. Possible values: success, partial_success, error.success - when all the cancel order request are successful. partial_success - when some cancel order request encountered errors. error - when all the cancel order request encountered errors. |
| data | object | Successful response data for cancel multi order request. |
| data.order_ids | array | List of reference order IDs associated with successfully cancelled orders. |
| errors | array | An array containing the main content of the error response for partial_success and error scenarios. |
| errors[].error_code | string | A specific error code. |
| errors[].message | string | Descriptive error message. |
| errors[].property_path | string | Indicates which part of the request triggered the error. It can be null. |
| errors[].invalid_value | string | Shows the value causing the error. It can be null. |
| errors[].instrument_key | string | A Key of instrument for a specific order. |
| errors[].order_id | string | Order ID associated to specific order. It can be null. |
| summary | object | A summary of the outcomes for the batch of orders processed, detailing total orders, successful completions, and errors. |
| summary.total | integer | The total number of order present in the payload for cancel multi orders. |
| summary.success | integer | Indicates the successful cancelled orders. |
| summary.error | integer | Indicates the unsuccessful cancelled orders. |
{
"status": "error",
"data": null,
"errors": [
{
"error_code": "UDAPI100500",
"message": "Something went wrong... please contact us.",
"property_path": null,
"invalid_value": null,
"order_id": "240923010689802",
"instrument_key": "NSE_EQ|INE528G01035"
}
],
"summary": {
"total": 1,
"success": 0,
"error": 1
}
}
{
"status": "error",
"errors": [
{
"error_code": "UDAPI1109",
"message": "No open or pending order available",
"property_path": null,
"invalid_value": null
}
]
}
| Name | Type | Description |
|---|---|---|
| status | string | A string indicating the outcome of the request. Possible values: success, partial_success, error.success - when all the cancel order request are successful. partial_success - when some cancel order request encountered errors. error - when all the cancel order request encountered errors. |
| data | object | Successful response data for cancel multi order request. |
| data.order_ids | array | List of reference order IDs associated with successfully cancelled orders. |
| errors | array | An array containing the main content of the error response for partial_success and error scenarios. |
| errors[].error_code | string | A specific error code. |
| errors[].message | string | Descriptive error message. |
| errors[].property_path | string | Indicates which part of the request triggered the error. It can be null. |
| errors[].invalid_value | string | Shows the value causing the error. It can be null. |
| errors[].instrument_key | string | A Key of instrument for a specific order. |
| errors[].order_id | string | Order ID associated to specific order. It can be null. |
| summary | object | A summary of the outcomes for the batch of orders processed, detailing total orders, successful completions, and errors. |
| summary.total | integer | The total number of order present in the payload for cancel multi orders. |
| summary.success | integer | Indicates the successful cancelled orders. |
| summary.error | integer | Indicates the unsuccessful cancelled orders. |
Error codesโ
| Error code | Description |
|---|---|
| UDAPI1108 | Invalid segment. - Please ensure that segment provided in query param is correct. |
| UDAPI1109 | No open or pending order available. - Please ensure that there are open or pending orders available. |
| UDAPI1110 | Available open or pending orders should not be more than 50. - Please ensure that available open or pending should be within the limit. |
Sample Codeโ
Cancel all the open ordersโ
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location --request DELETE 'https://api.upstox.com/v2/order/multi/cancel' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/order/multi/cancel'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.delete(url, headers=headers)
print(response.text)
const axios = require('axios');
const url = 'https://api.upstox.com/v2/order/multi/cancel';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}', // Replace {your_access_token} with the actual access token
};
axios.delete(url, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response ? error.response.data : error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.upstox.com/v2/order/multi/cancel";
// Replace with your actual values
String acceptHeader = "application/json";
String authorizationHeader = "Bearer {your_access_token}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", acceptHeader)
.header("Authorization", authorizationHeader)
.DELETE()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
}
}
<?php
$url = 'https://api.upstox.com/v2/order/multi/cancel';
// Replace with your actual values
$acceptHeader = 'application/json';
$authorizationHeader = 'Bearer {your_access_token}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: ' . $acceptHeader,
'Authorization: ' . $authorizationHeader
));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo 'Response Code: ' . $httpCode . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = "{your_access_token}"
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
try:
api_response = api_instance.cancel_multi_order()
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->cancel all: %s\n" % e.body)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.OrderApi();
apiInstance.cancelMultiOrder(null, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.CancelOrExitMultiOrderResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.OrderApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
OrderApi apiInstance = new OrderApi();
try {
CancelOrExitMultiOrderResponse result = apiInstance.cancelMultiOrder(null,null);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#cancelMultiOrder= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Cancel all the open orders for a given segmentโ
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location --request DELETE 'https://api.upstox.com/v2/order/multi/cancel?segment=NSE_FO' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/order/multi/cancel?segment=NSE_FO'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.delete(url, headers=headers)
print(response.text)
const axios = require('axios');
const url = 'https://api.upstox.com/v2/order/multi/cancel?segment=NSE_FO';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}', // Replace {your_access_token} with the actual access token
};
axios.delete(url, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response ? error.response.data : error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.upstox.com/v2/order/multi/cancel?segment=NSE_FO";
// Replace with your actual values
String acceptHeader = "application/json";
String authorizationHeader = "Bearer {your_access_token}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", acceptHeader)
.header("Authorization", authorizationHeader)
.DELETE()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
}
}
<?php
$url = 'https://api.upstox.com/v2/order/multi/cancel?segment=NSE_FO';
// Replace with your actual values
$acceptHeader = 'application/json';
$authorizationHeader = 'Bearer {your_access_token}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: ' . $acceptHeader,
'Authorization: ' . $authorizationHeader
));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo 'Response Code: ' . $httpCode . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = "{your_access_token}"
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
param = {
'segment': "NSE_FO"
}
try:
api_response = api_instance.cancel_multi_order(**param)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->cancel all: %s\n" % e.body)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.OrderApi();
opts = {
'segment': 'NSE_FO'
}
apiInstance.cancelMultiOrder(opts, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.CancelOrExitMultiOrderResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.OrderApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
OrderApi apiInstance = new OrderApi();
try {
CancelOrExitMultiOrderResponse result = apiInstance.cancelMultiOrder(null,"NSE_FO");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#cancelMultiOrder= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Cancel all the open orders for a given tagโ
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location --request DELETE 'https://api.upstox.com/v2/order/multi/cancel?tag=xyz' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/order/multi/cancel?tag=xyz'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.delete(url, headers=headers)
print(response.text)
const axios = require('axios');
const url = 'https://api.upstox.com/v2/order/multi/cancel?tag=xyz';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}', // Replace {your_access_token} with the actual access token
};
axios.delete(url, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response ? error.response.data : error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.upstox.com/v2/order/multi/cancel?tag=xyz";
// Replace with your actual values
String acceptHeader = "application/json";
String authorizationHeader = "Bearer {your_access_token}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", acceptHeader)
.header("Authorization", authorizationHeader)
.DELETE()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
}
}
<?php
$url = 'https://api.upstox.com/v2/order/multi/cancel?tag=xyz';
// Replace with your actual values
$acceptHeader = 'application/json';
$authorizationHeader = 'Bearer {your_access_token}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: ' . $acceptHeader,
'Authorization: ' . $authorizationHeader
));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo 'Response Code: ' . $httpCode . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = "{your_access_token}"
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
param = {
'tag': "xyz"
}
try:
api_response = api_instance.cancel_multi_order(**param)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->cancel all: %s\n" % e.body)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.OrderApi();
opts = {
'tag': 'xyz'
}
apiInstance.cancelMultiOrder(opts, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.CancelOrExitMultiOrderResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.OrderApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
OrderApi apiInstance = new OrderApi();
try {
CancelOrExitMultiOrderResponse result = apiInstance.cancelMultiOrder("xyz",null);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi#cancelMultiOrder= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Loading...