# Order Cancel

This API cancels open or pending orders, including AMO and regular orders, and assists in exiting COs, offering traders a streamlined solution for order management.

**Endpoint**

{% code title="Base URL" overflow="wrap" fullWidth="false" %}

```
https://connects.torusdigital.com/api/v1/order/cancel
```

{% endcode %}

#### Header Parameters <a href="#header-parameters" id="header-parameters"></a>

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

#### **Request Parameter**

<table><thead><tr><th width="148">Parameter</th><th width="105">Value</th><th width="89">Mandatory</th><th>Remarks</th></tr></thead><tbody><tr><td>txn_type</td><td>B/S</td><td>Y</td><td>The type of transaction, where "B" typically stands for Buy and "S" stands for SELL.</td></tr><tr><td>exchange</td><td>NSE</td><td>Y</td><td>The exchange where the transaction takes place, it can be NSE/BSE.</td></tr><tr><td>segment</td><td>E</td><td>Y</td><td>The market segment, where "E" might stand for "Equity".</td></tr><tr><td>product</td><td>I</td><td>Y</td><td>The product type is intraday.</td></tr><tr><td>security_id</td><td>14366</td><td>Y</td><td>The unique identifier for the security being traded.</td></tr><tr><td>quantity</td><td>2</td><td>Y</td><td>Non-zero integer value</td></tr><tr><td>price</td><td>0.00</td><td>Y</td><td>Float value, cannot be zero when ORDER_TYPE is LMT/SL</td></tr><tr><td>validity</td><td>DAY</td><td>Y</td><td>The validity of the order, indicating it is valid for the day.</td></tr><tr><td>order_type</td><td>MKT</td><td>Y</td><td>The type of order, where "MKT" stands for a market order.</td></tr><tr><td>disc_quantity</td><td>0</td><td>N</td><td>The disclosed quantity of the order.</td></tr><tr><td>trigger_price</td><td>0.00</td><td>N</td><td>The price at which a stop order is triggered. "0.00" indicates no stop price.</td></tr><tr><td>off_mkt_flag</td><td>false</td><td>Y</td><td>true for Aftermarket order, false for normal order</td></tr><tr><td>remarks</td><td>502929</td><td>N</td><td>Additional remarks or reference number for the transaction.</td></tr><tr><td>mkt_type</td><td>NL</td><td>Y</td><td>Default value is NL</td></tr><tr><td>good_till_days_date</td><td>2019-03-29 (yyyy-MM-dd)</td><td>N</td><td>Mandatory when validity is GTD</td></tr><tr><td>order_no</td><td>1234567890</td><td>Y</td><td>Order number</td></tr><tr><td>serial_no</td><td>1</td><td>Y</td><td>Serial number</td></tr><tr><td>group_id</td><td>1</td><td>Y</td><td>Group Id</td></tr><tr><td>ip</td><td>192.168.0.101</td><td>Y</td><td>IP address of client device</td></tr><tr><td>uu_id</td><td>12345678</td><td>Y</td><td>This random ID is to be generated and persisted on a device when a user installs or initializes the app (Mobile or EXE) for the first time</td></tr><tr><td>app_id</td><td>12345678</td><td>Y</td><td>App ID of client device</td></tr></tbody></table>

#### **Request**

{% tabs %}
{% tab title="curl" %}
{% code title="cURL" overflow="wrap" lineNumbers="true" %}

```javascript
curl --location 'https://connects.torusdigital.com/api/v1/order/cancel' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data '{
    "source": "N",
    "data": {
        "txn_type": "B",
        "exchange": "NSE",
        "segment": "E",
        "product": "I",
        "security_id": "14366",
        "quantity": "3",
        "price": "0.00",
        "validity": "DAY",
        "order_type": "MKT",
        "disc_quantity": "0",
        "trigger_price": "0",
        "off_mkt_flag": "false",
        "remarks": "Trail",
        "mkt_type": "null",
        "settlor": "X",
        "group_id": "1",
        "order_no": "1141240610104",
        "serial_no": "2",
        "ip": "192.168.0.101",
        "uu_id": "12345678",
        "app_id": "12345678"
    }
}'
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code title="Java-Unirest" fullWidth="false" %}

```java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://connects.torusdigital.com/api/v1/order/cancel")
  .header("Authorization", "Bearer {{token}}")
  .header("Content-Type", "application/json")
  .body("{\r\n" +
        "    \"source\": \"N\",\r\n" +
        "    \"data\": {\r\n" +
        "        \"txn_type\": \"B\",\r\n" +
        "        \"exchange\": \"NSE\",\r\n" +
        "        \"segment\": \"E\",\r\n" +
        "        \"product\": \"I\",\r\n" +
        "        \"security_id\": \"14366\",\r\n" +
        "        \"quantity\": \"3\",\r\n" +
        "        \"price\": \"0.00\",\r\n" +
        "        \"validity\": \"DAY\",\r\n" +
        "        \"order_type\": \"MKT\",\r\n" +
        "        \"disc_quantity\": \"0\",\r\n" +
        "        \"trigger_price\": \"0\",\r\n" +
        "        \"off_mkt_flag\": \"false\",\r\n" +
        "        \"remarks\": \"Trail\",\r\n" +
        "        \"mkt_type\": \"null\",\r\n" +
        "        \"settlor\": \"X\",\r\n" +
        "        \"group_id\": \"1\",\r\n" +
        "        \"order_no\": \"1141240610104\",\r\n" +
        "        \"serial_no\": \"2\",\r\n" +
        "        \"ip\": \"192.168.0.101\",\r\n" +
        "        \"uu_id\": \"12345678\",\r\n" +
        "        \"app_id\": \"12345678\"\r\n" +
        "    }\r\n" +
        "}")
  .asString();
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code title="Go-Native" overflow="wrap" lineNumbers="true" fullWidth="true" %}

```go
go
Copy code
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
)

func main() {
	url := "https://connects.torusdigital.com/api/v1/order/cancel"
	method := "POST"

	payload := strings.NewReader(`
{
	"source": "N",
	"data": {
		"txn_type": "B",
		"exchange": "NSE",
		"segment": "E",
		"product": "I",
		"security_id": "14366",
		"quantity": "3",
		"price": "0.00",
		"validity": "DAY",
		"order_type": "MKT",
		"disc_quantity": "0",
		"trigger_price": "0",
		"off_mkt_flag": "false",
		"remarks": "Trail",
		"mkt_type": "null",
		"settlor": "X",
		"group_id": "1",
		"order_no": "1141240610104",
		"serial_no": "2",
		"ip": "192.168.0.101",
		"uu_id": "12345678",
		"app_id": "12345678"
	}
}
`)

	client := &http.Client{}
	req, err := http.NewRequest(method, url, payload)
	if err != nil {
		fmt.Println(err)
		return
	}
	req.Header.Add("Authorization", "Bearer {{token}}")
	req.Header.Add("Content-Type", "application/json")

	res, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer res.Body.Close()

	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(body))
}
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code title="JavaScript-jQuery" overflow="wrap" lineNumbers="true" %}

```javascript
var settings = {
  "url": "https://connects.torusdigital.com/api/v1/order/cancel",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer {{token}}",
    "Content-Type": "application/json"
  },
  "data": JSON.stringify({
    "source": "N",
    "data": {
      "txn_type": "B",
      "exchange": "NSE",
      "segment": "E",
      "product": "I",
      "security_id": "14366",
      "quantity": "3",
      "price": "0.00",
      "validity": "DAY",
      "order_type": "MKT",
      "disc_quantity": "0",
      "trigger_price": "0",
      "off_mkt_flag": "false",
      "remarks": "Trail",
      "mkt_type": "null",
      "settlor": "X",
      "group_id": "1",
      "order_no": "1141240610104",
      "serial_no": "2",
      "ip": "192.168.0.101",
      "uu_id": "12345678",
      "app_id": "12345678"
    }
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "data": [
    {
      "order_no": "1122031118517"
    }
  ],
  "status": "success",
  "message": "Order cancellation request submitted successfully. Your Order Ref No. 1122031118517"
}

```

{% endtab %}
{% endtabs %}

&#x20;   **Response Parameter**

<table><thead><tr><th width="309">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>Status</td><td>“success”/”error”</td></tr><tr><td>Message</td><td>“Some Message”</td></tr><tr><td>Data</td><td>An object containing the details of the order.</td></tr><tr><td>order_no</td><td>Order specific identification number.</td></tr></tbody></table>
