Smart Order APIs (GTT)¶
This section outlines the APIs for placing, modifying, and canceling multi-leg "Good Till Triggered" (GTT) orders, which include simultaneous stop-loss and target legs, as well as Trigger orders.
Supported Segments
Smart Orders (GTT) and Trigger Orders are supported for both Equity and Derivative instruments.
How Smart Orders Work¶
When you place a smart order via /smart/order, the system creates two linked orders:
- Parent Order — The primary order (MARKET, LIMIT, or TRIGGER) that gets sent to the exchange first (except if the entered limit price is outside the circuit bounds, then parent order is placed as a GTT order instead).
- Child Order — A GTT (Good Till Triggered) order containing the stop-loss and/or target legs. It is linked to the parent and only activates once the parent order is successfully executed.
Order ID Prefixes¶
Each order ID carries a prefix that indicates its type:
| Prefix | Meaning | Used For |
|---|---|---|
EQ- | Equity order | Parent orders in the EQUITY segment |
DRV- | Derivative order | Parent orders in the DERIVATIVE segment |
GTT- | Good Till Triggered | Child orders (always), and parent orders when the limit price falls outside the circuit range |
- A parent order normally receives an
EQ-orDRV-prefix depending on the segment. - If the entered limit price is outside the circuit bounds, the parent order is placed as a GTT order instead and receives a
GTT-prefix. - Child orders always carry a
GTT-prefix.
Placement Response¶
The API response returns both order IDs in a single payload:
{
"status": "success",
"data": {
"order_data": [
{
"order_id": "DRV-28131451",
"order_status": "CREATED",
"child_order_details": {
"order_id": "GTT-2914581",
"order_status": "CREATED"
}
}
]
}
}
Modification and Cancellation¶
Parent and child orders are independent entities. To modify or cancel a smart order, you must operate on each order separately using its own order_id:
- Use
/smart/order/modifywith the parentorder_id(e.g.DRV-28131451) to modify the parent. - Use
/smart/order/modifywith the childorder_id(e.g.GTT-2914581) to modify the child. - The same applies to
/smart/order/cancel— each order must be cancelled individually.
Child Order Lifecycle
The child order will not activate until the parent order is successfully executed. If the parent order is cancelled, rejected, or fails, the linked child order remains inactive.
| Request Type | Path | Description |
|---|---|---|
| POST | /smart/order | Place a new multi-leg smart order |
| POST | /smart/order/modify | Modify a pending smart order |
| POST | /smart/order/cancel | Cancel a pending smart order |
Place Smart Order¶
This API allows you to place a new multi-leg smart order (GTT).
Endpoint
Request Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
txn_type | string | ✅ | The transaction type. Enum: "BUY", "SELL" |
exchange | string | ✅ | The exchange to place the order on. Enum: "NSE" |
segment | string | ✅ | The market segment. Enum: "EQUITY", "DERIVATIVE" |
product | string | ✅ | The product type. For Equity: "CNC", "INTRADAY". For Derivative: "MARGIN", "INTRADAY" |
order_type | string | ✅ | The type of order. Enum: "LIMIT", "MARKET", "TRIGGER". Note: MARKET orders are automatically converted to LIMIT at the live price (see note below). |
validity | string | ✅ | The order validity. Enum: "DAY" |
security_id | string | ✅ | The unique identifier for the instrument. |
qty | integer | ✅ | The quantity of the instrument to trade. |
algo_id | string | ✅ | Algo identifier for the smart order. Use "99999" for NSE, "9999999999999999" for BSE orders. |
limit_price | number | ❌ | The price for the main LIMIT order. Required if order_type is "LIMIT". For MARKET orders the live market price is used. Not used for "TRIGGER" orders. |
trigger_price | number | ❌ | The trigger price for the order. Required if order_type is "TRIGGER". Must be a multiple of the instrument's tick size. For BUY: must be strictly greater than CMP. For SELL: must be strictly less than CMP. |
trigger_limit_price | number | ❌ | Optional limit price for a trigger-limit order. If provided alongside trigger_price, the order executes as trigger-limit; otherwise it executes as trigger-market. If omitted, trigger_limit_price is automatically set equal to trigger_price. Must be a multiple of the instrument's tick size. |
sl_trigger_price | number | ❌ | The trigger price for the stop-loss leg. If set, sl_limit_price must also be provided or the order is rejected. |
tgt_trigger_price | number | ❌ | The trigger price for the target (profit) leg. If set, tgt_limit_price must also be provided or the order is rejected. |
sl_limit_price | number | ❌ | The limit price for the stop-loss order once triggered. Required when sl_trigger_price is set. |
tgt_limit_price | number | ❌ | The limit price for the target order once triggered. Required when tgt_trigger_price is set. |
Example Request — LIMIT order (Derivative)
curl --location 'https://api.indstocks.com/smart/order' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"txn_type": "BUY",
"exchange": "NSE",
"segment": "DERIVATIVE",
"product": "MARGIN",
"order_type": "LIMIT",
"validity": "DAY",
"security_id": "51011",
"qty": 75,
"limit_price": 37,
"sl_trigger_price": 34,
"tgt_trigger_price": 41,
"sl_limit_price": 33,
"tgt_limit_price": 38,
"algo_id": "99999"
}'
Example Request — Trigger-Market order (Equity)
curl --location 'https://api.indstocks.com/smart/order' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"txn_type": "BUY",
"exchange": "NSE",
"segment": "EQUITY",
"product": "CNC",
"order_type": "TRIGGER",
"validity": "DAY",
"security_id": "3045",
"qty": 10,
"trigger_price": 1520.00,
"algo_id": "99999"
}'
Example Request — Trigger-Limit order (Derivative)
curl --location 'https://api.indstocks.com/smart/order' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"txn_type": "BUY",
"exchange": "NSE",
"segment": "DERIVATIVE",
"product": "MARGIN",
"order_type": "TRIGGER",
"validity": "DAY",
"security_id": "51011",
"qty": 75,
"trigger_price": 38.50,
"trigger_limit_price": 38.75,
"algo_id": "99999"
}'
Validations
- QtyMustBeAboveZero: Qty must be specified and greater than zero
- LimitPriceMustBeAboveZero: Limit price must be specified and greater than zero (applies to
LIMITorders) - QtyWithinFreezeQty: Qty should be less than freeze qty
- MaxValueOfOption: Max Value of option allowed is enforced
- QtyMultipleOfLotSize: Qty should be multiple of lot size
- MaxSlTriggerPrice: SL Trigger Price should be less than the limit price
- MaxSlLimitPrice: SL Limit Price should be less than the SL trigger price
- MinTgtTriggerPrice: Target Trigger Price should be greater than the limit price
- MinTgtLimitPrice: Target Limit Price should be greater than the target trigger price
- TriggerPriceMustBeAboveZero:
trigger_pricemust be present and greater than zero whenorder_typeis"TRIGGER" - TriggerPriceTickSize:
trigger_pricemust be a multiple of the instrument's tick size - TriggerLimitPriceTickSize:
trigger_limit_price(if provided) must be a multiple of the instrument's tick size - TriggerPriceVsCMP (BUY):
trigger_pricemust be strictly greater than the current market price - TriggerPriceVsCMP (SELL):
trigger_pricemust be strictly less than the current market price
Market Orders Are Converted to Limit Orders
API trading does not support pure MARKET orders. If you submit order_type: "MARKET", the order is automatically converted to a LIMIT order priced at the current live market price before being sent to the exchange.
Similarly, for TRIGGER orders, if trigger_limit_price is omitted it is automatically set equal to trigger_price, so the order executes as a trigger-limit order at the trigger price.
Stop-Loss and Target Legs Require a Limit Price
If you provide sl_trigger_price, you must also provide sl_limit_price. Likewise, if you provide tgt_trigger_price, you must also provide tgt_limit_price. Submitting a stop-loss or target leg without its corresponding limit price will cause the order to be rejected.
Modify Smart Order¶
This API allows you to modify a pending smart order.
Endpoint
Request Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
order_id | string | ✅ | The unique ID of the order to be modified |
segment | string | ✅ | The market segment. Enum: "EQUITY", "DERIVATIVE" |
algo_id | string | ✅ | Algo identifier. Use "99999" for NSE orders. |
order_type | string | ❌ | The type of order. Enum: "LIMIT", "MARKET", "TRIGGER". Must match the existing order type. |
qty | integer | ❌ | The quantity of the instrument to trade |
limit_price | number | ❌ | The price for the main LIMIT order (applies to LIMIT orders only) |
trigger_price | number | ❌ | The trigger price for the order. Required when modifying a TRIGGER order. Must be a multiple of tick size. For BUY: must be strictly greater than CMP. For SELL: must be strictly less than CMP. |
trigger_limit_price | number | ❌ | Optional limit price for a trigger-limit order. Must be a multiple of tick size. |
sl_trigger_price | number | ❌ | The trigger price for the stop-loss leg |
tgt_trigger_price | number | ❌ | The trigger price for the target (profit) leg |
sl_limit_price | number | ❌ | The limit price for the stop-loss order |
tgt_limit_price | number | ❌ | The limit price for the target order |
Example Request — Modify LIMIT order
curl --location 'https://api.indstocks.com/smart/order/modify' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--data '{
"order_id": "DRV-123",
"segment": "DERIVATIVE",
"algo_id": "99999",
"order_type": "LIMIT",
"qty": 20,
"limit_price": 0.35,
"sl_trigger_price": 0.15,
"tgt_trigger_price": 41,
"sl_limit_price": 0.1,
"tgt_limit_price": 42
}'
Example Request — Modify Trigger order
curl --location 'https://api.indstocks.com/smart/order/modify' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--data '{
"order_id": "EQ-456",
"segment": "EQUITY",
"algo_id": "99999",
"order_type": "TRIGGER",
"qty": 10,
"trigger_price": 1530.00,
"trigger_limit_price": 1532.00
}'
Order Type Mismatch
The order_type in the modify request must match the type of the existing order. Sending order_type: "TRIGGER" for a LIMIT order (or vice versa) will be rejected.
Cancel Smart Order¶
This API allows you to cancel a pending smart order.
Endpoint
Request Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
order_id | string | ✅ | The unique ID of the order to be cancelled. |
segment | string | ✅ | The market segment. Enum: "EQUITY", "DERIVATIVE" |
Example Request
curl --location 'https://api.indstocks.com/smart/order/cancel' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--data '{
"segment": "DERIVATIVE",
"order_id": "123456789"
}'
Validations
- OrderIdMissing: Order ID is missing or invalid
- OrderCannotBeCancelled: Order is not eligible for cancellation