Skip to content

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.

Supported Segments

Smart Orders (GTT) 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:

  1. Parent Order — The primary order (MARKET or LIMIT) 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).
  2. 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- or DRV- 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:

JSON
{
  "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/modify with the parent order_id (e.g. DRV-28131451) to modify the parent.
  • Use /smart/order/modify with the child order_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

Text Only
POST /smart/order

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"
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".
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 once triggered.
tgt_limit_price number The limit price for the target order once triggered.

Example Request

Bash
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"
}'

Validations

  • QtyMustBeAboveZero: Qty must be specified and greater than zero
  • LimitPriceMustBeAboveZero: Limit price must be specified and greater than zero
  • 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

Modify Smart Order

This API allows you to modify a pending smart order.

Endpoint

Text Only
POST https://api.indstocks.com/smart/order/modify

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.
qty integer The quantity of the instrument to trade
limit_price number The price for the main LIMIT order
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

Bash
curl --location 'https://api.indstocks.com/smart/order/modify' \
--header 'Authorization: YOUR_ACCESS_TOKEN' \
--data '{
  "order_id": "DRV-123",
  "segment": "DERIVATIVE",
  "algo_id": "99999",
  "qty": 20,
  "limit_price": 0.35,
  "sl_trigger_price": 0.15,
  "tgt_trigger_price": 41,
  "sl_limit_price": 0.1,
  "tgt_limit_price": 42
}'


Cancel Smart Order

This API allows you to cancel a pending smart order.

Endpoint

Text Only
POST /smart/order/cancel

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

Bash
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