Skip to content

Orders

The order management API lets you place a new order, cancel or modify the pending order, retrieve the order status, trade status, order book & tradebook

POST /orders Place a new order
PUT /orders/{order-id} Modify a pending order
DELETE /orders/{order-id} Cancel a pending order
GET /orders Retrieve the list of all orders for the day
GET /orders/{order-id} Retrieve the status of an order
GET /orders/external/{correlation-id} Retrieve the status of an order by correlation id
GET /trades Retrieve the list of all trades for the day.
GET /trades/{order-id} Retrieve the details of trade by an order id

Order Placement

The order request API lets you place new orders.

curl --request POST \
--url https://api.dhan.co/orders \
--header 'Content-Type: application/json' \
--header 'access-token: JWT' \
--data '{Request JSON}'


Request Structure

{
    "dhanClientId":"1000000003",
    "correlationId":"123abc678",
    "transactionType":"BUY",
    "exchangeSegment":"NSE_EQ",
    "productType":"INTRADAY",
    "orderType":"MARKET",
    "validity":"DAY",
    "tradingSymbol":"",
    "securityId":"11536",
    "quantity":"5",
    "disclosedQuantity":"",
    "price":"3424.80",
    "triggerPrice":"",
    "afterMarketOrder":false,
    "amoTime":"",
    "boProfitValue":"",
    "boStopLossValue": "",
    "drvExpiryDate":"string",
    "drvOptionType":"CALL"
    "drvStrikePrice": -3.402823669209385e+38
}


Parameters

Field Type Description
dhanClientId
required
string User specific identification generated by Dhan
correlationId string The user/partner generated id for tracking back.
transactionType
required
enum string The trading side of transaction
BUY   SELL
exchangeSegment
required
enum string Exchange & Segment
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
productType
required
enum string Product type
CNC  INTRADAY  MARGIN  CO BO
orderType
required
enum string Order Type
LIMIT MARKET STOP_LOSS STOP_LOSS_MARKET
validity
required
enum string Validity of Order
DAY IOC
tradingSymbol string Refer Trading Symbol in Tables
securityId
required
string Exchange standard id for each scrip. Refer here
quantity
required
int Number of shares for the order
disclosedQuantity int Number of shares visible (Keep more than 30% of quantity)
price
required
float Price at which order is placed
triggerPrice
conditionally required
float Price at which the order is triggered, in case of SL-M & SL-L
afterMarketOrder
conditionally required
boolean Flag for orders placed after market hours
amoTime
conditionally required
enum sting Timing to pump the after market order
OPEN OPEN_30 OPEN_60
boProfitValue
conditionally required
float Bracket Order Target Price change
boStopLossValue
conditionally required
float Bracket Order Stop Loss Price change
drvExpiryDate
conditionally required
string Contract Expiry Date for F&O
drvOptionType
conditionally required
enum string Type of Option
CALL PUT
drvStrikePrice
conditionally required
float Strike Price for Options


Response Structure

{
    "orderId": "112111182198",
    "orderStatus": "PENDING",
}


Parameters

Field Type Description
orderId string Order specific identification generated by Dhan
orderStatus enum string Last updated status of the order
TRANSIT PENDING REJECTED CANCELLED TRADED EXPIRED

Order Modification

Using this API one can modify pending order in orderbook. The variables that can be modified are price, quantity, order type & validity. The user has to mention the desired value in fields.

curl --request PUT \
--url https://api.dhan.co/orders/{order-id} \
--header 'Content-Type: application/json' \
--header 'access-token: JWT' \
--data '{Request JSON}'


Request Structure

{
    "dhanClientId":"1000000009",
    "orderId":"112111182045",
    "orderType":"LIMIT",
    "legName":"",
    "quantity":"40",
    "price":"3345.8",
    "disclosedQuantity":"10",
    "triggerPrice":"",
    "validity":"DAY"
}


Parameters

Field Type description
dhanClientId
required
string User specific identification generated by Dhan
orderId
required
string Order specific identification generated by Dhan
orderType
required
enum string Order Type
LIMIT MARKET STOP_LOSS STOP_LOSS_MARKET
legName
conditionally required
enum string In case of BO & CO, which leg is modified
ENTRY_LEG TARGET_LEG STOP_LOSS_LEG
quantity
required
int Number of shares for the order
price
required
float Price at which order is placed
disclosedQuantity int Number of shares visible (if opting keep >30% of quantity)
triggerPrice
conditionally required
float Price at which the order is triggered, in case of SL-M & SL-L
validity
required
enum string Validity of Order
DAY IOC


Response Structure

{
    "orderId": "112111182045",
    "orderStatus": "TRANSIT"
}


Parameters

Field Type Description
orderId string Order specific identification generated by Dhan
orderStatus enum string Last updated status of the order
TRANSIT PENDING REJECTED CANCELLED TRADED EXPIRED

Order Cancellation

Users can cancel a pending order in the orderbook using the order id of an order. There is no body for request and response for this call. On successful completion of request ‘202 Accepted’ response status code will appear.

curl --request DELETE \
--url https://api.dhan.co/orders/{order-id} \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

{
"orderId": "112111182045",
"orderStatus": "CANCELLED"
}


Parameters

Field Type Description
orderId string Order specific identification generated by Dhan
orderStatus enum string Last updated status of the order
TRANSIT PENDING REJECTED CANCELLED TRADED EXPIRED

Order Book

This API lets you retrieve an array of all orders requested in a day with their last updated status.

curl --request GET \
--url https://api.dhan.co/orders \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

[
    {
        "dhanClientId": "1000000003",
        "orderId": "112111182198",
        "correlationId":"123abc678",
        "orderStatus": "PENDING",
        "transactionType": "BUY",
        "exchangeSegment": "NSE_EQ",
        "productType": "INTRADAY",
        "orderType": "MARKET",
        "validity": "DAY",
        "tradingSymbol": "",
        "securityId": "11536",
        "quantity": 5,
        "disclosedQuantity": 0,
        "price": 0.0,
        "triggerPrice": 0.0,
        "afterMarketOrder": false,
        "boProfitValue": 0.0,
        "boStopLossValue": 0.0,
        "legName": ,
        "createTime": "2021-11-24 13:33:03",
        "updateTime": "2021-11-24 13:33:03",
        "exchangeTime": "2021-11-24 13:33:03",
        "drvExpiryDate": null,
        "drvOptionType": null,
        "drvStrikePrice": 0.0,
        "omsErrorCode": null,
        "omsErrorDescription": null
    }
]


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
orderId string Order specific identification generated by Dhan
correlationId string The user/partner generated id for tracking back
orderStatus enum string Last updated status of the order
TRANSIT PENDING REJECTED CANCELLED TRADED EXPIRED
transactionType enum string The trading side of transaction
BUY SELL
exchangeSegment enum string Exchange & Segment
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
productType enum string Product type of trade
CNC  INTRADAY  MARGIN  CO BO
orderType enum string Order Type
LIMIT MARKET STOP_LOSS STOP_LOSS_MARKET
validity enum string Validity of Order
DAY IOC
tradingSymbol string Refer Trading Symbol in Tables
securityId string Exchange standard id for each scrip. Refer here
quantity int Number of shares for the order
disclosedQuantity int Number of shares visible
price float Price at which order is placed
triggerPrice float Price at which order is triggered, for SL-M, SL-L, CO & BO
afterMarketOrder boolean The order placed is AMO ?
boProfitValue float Bracket Order Target Price change
boStopLossValue float Bracket Order Stop Loss Price change
legName enum string Leg identification in case of BO
ENTRY_LEG TARGET_LEG STOP_LOSS_LEG
createTime string Time at which the order is created
updateTime string Time at which the last activity happened
exchangeTime string Time at which order reached at exchange
drvExpiryDate int For F&O, expiry date of contract
drvOptionType enum string Type of Option
CALL PUT
drvStrikePrice float For Options, Strike Price
omserroeCode string Error code in case the order is rejected or failed
omsErrorDescription string Description of error in case the order is rejected or failed

Get Order by Order Id

Users can retrieve the details and status of an order from the orderbook placed during the day.

curl --request GET \
--url https://api.dhan.co/orders/{order-id} \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

{
    "dhanClientId": "1000000003",
    "orderId": "112111182198",
    "correlationId":"123abc678",
    "orderStatus": "PENDING",
    "transactionType": "BUY",
    "exchangeSegment": "NSE_EQ",
    "productType": "INTRADAY",
    "orderType": "MARKET",
    "validity": "DAY",
    "tradingSymbol": "",
    "securityId": "11536",
    "quantity": 5,
    "disclosedQuantity": 0,
    "price": 0.0,
    "triggerPrice": 0.0,
    "afterMarketOrder": false,
    "boProfitValue": 0.0,
    "boStopLossValue": 0.0,
    "legName": ,
    "createTime": "2021-11-24 13:33:03",
    "updateTime": "2021-11-24 13:33:03",
    "exchangeTime": "2021-11-24 13:33:03",
    "drvExpiryDate": null,
    "drvOptionType": null,
    "drvStrikePrice": 0.0
}


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
orderId string Order specific identification generated by Dhan
correlationId string The user/partner generated id for tracking back
orderStatus enum string Last updated status of the order
TRANSIT PENDING REJECTED CANCELLED TRADED EXPIRED
transactionType enum string The trading side of transaction
BUY SELL
exchangeSegment enum string Exchange & Segment
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
productType enum string Product type of trade
CNC  INTRADAY  MARGIN  CO BO
orderType enum string Order Type
LIMIT MARKET STOP_LOSS STOP_LOSS_MARKET
validity enum string Validity of Order
tradingSymbol string Refer Trading Symbol in Tables
securityId string Exchange standard id for each scrip. Refer here
quantity int Number of shares for the order
disclosedQuantity int Number of shares visible
price float Price at which order is placed
triggerPrice float Price at which order is triggered, for SL-M, SL-L, CO & BO
afterMarketOrder boolean The order placed is AMO ?
boProfitValue float Bracket Order Target Price change
boStopLossValue float Bracket Order Stop Loss Price change
legName enum string Leg identification in case of BO
ENTRY_LEG TARGET_LEG STOP_LOSS_LEG
createTime string Time at which the order is created
updateTime string Time at which the last activity happened
exchangeTime string Time at which order reached at exchange
drvExpiryDate int For F&O, expiry date of contract
drvOptionType enum string Type of Option
CALL PUT
drvStrikePrice float For Options, Strike Price

Get Order by Correlation Id

In case the user has missed order id due to unforeseen reason, this API retrieves the order status using a tag called correlation id specified by users themselve.

curl --request GET \
--url https://api.dhan.co/orders/external/{correlation-id} \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

{
    "dhanClientId": "1000000003",
    "orderId": "112111182198",
    "correlationId":"123abc678",
    "orderStatus": "PENDING",
    "transactionType": "BUY",
    "exchangeSegment": "NSE_EQ",
    "productType": "INTRADAY",
    "orderType": "MARKET",
    "validity": "DAY",
    "tradingSymbol": "",
    "securityId": "11536",
    "quantity": 5,
    "disclosedQuantity": 0,
    "price": 0.0,
    "triggerPrice": 0.0,
    "afterMarketOrder": false,
    "boProfitValue": 0.0,
    "boStopLossValue": 0.0,
    "legName": ,
    "createTime": "2021-11-24 13:33:03",
    "updateTime": "2021-11-24 13:33:03",
    "exchangeTime": "2021-11-24 13:33:03",
    "drvExpiryDate": null,
    "drvOptionType": null,
    "drvStrikePrice": 0.0,
    "omsErrorCode": null,
    "omsErrorDescription": null
}


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
orderId string Order specific identification generated by Dhan
correlationId string The user/partner generated id for tracking back
orderStatus enum string Last updated status of the order
TRANSIT PENDING REJECTED CANCELLED TRADED EXPIRED
transactionType enum string The trading side of transaction
BUY SELL
exchangeSegment enum string Exchange & Segment
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
productType enum string Product type of trade
CNC  INTRADAY  MARGIN  CO BO
orderType enum string Order Type
LIMIT MARKET STOP_LOSS STOP_LOSS_MARKET
validity enum string Validity of Order
tradingSymbol string Refer Trading Symbol in Tables
securityId string Exchange standard id for each scrip. Refer here
quantity int Number of shares for the order
disclosedQuantity int Number of shares visible
price float Price at which order is placed
triggerPrice float Price at which order is triggered, for SL-M, SL-L, CO & BO
afterMarketOrder boolean The order placed is AMO ?
boProfitValue float Bracket Order Target Price change
boStopLossValue float Bracket Order Stop Loss Price change
legName enum string Leg identification in case of BO
ENTRY_LEG TARGET_LEG STOP_LOSS_LEG
createTime string Time at which the order is created
updateTime string Time at which the last activity happened
exchangeTime string Time at which order reached at exchange
drvExpiryDate int For F&O, expiry date of contract
drvOptionType enum string Type of Option
CALL PUT
drvStrikePrice float For Options, Strike Price
omserroeCode string Error code in case the order is rejected or failed
omsErrorDescription string Description of error in case the order is rejected or failed

Trade Book

This API lets you retrieve an array of all trades executed in a day.

curl --request GET \
--url https://api.dhan.co/trades \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

[
    {
        "dhanClientId": "1000000009",
        "orderId": "112111182045",
        "exchangeOrderId": "15112111182045",
        "exchangeTradeId": "15112111182045",
        "transactionType": "BUY",
        "exchangeSegment": "NSE_EQ",
        "productType": "INTRADAY",
        "orderType": "LIMIT",
        "tradingSymbol": "TCS",
        "securityId": "11536",
        "tradedQuantity": 40,
        "tradedPrice": 3345.8,
        "createTime": "2021-03-10 11:20:06",
        "updateTime": "2021-11-25 17:35:12"
        "exchangeTime": "2021-11-25 17:35:12",
        "drvExpiryDate": null,
        "drvOptionType": null,
        "drvStrikePrice": 0.0
    }
]


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
orderId string Order specific identification generated by Dhan
exchangeOrderId string Order specific identification generated by exchange
exchangeTradeId string Trade specific identification generated by exchange
transactionType enum string The trading side of transaction
BUY SELL
exchangeSegment enum string Exchange & Segment
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
productType enum string Product type of trade
CNC  INTRADAY  MARGIN  CO BO
orderType enum string Order Type
LIMIT MARKET STOP_LOSS STOP_LOSS_MARKET
tradingSymbol string Refer Trading Symbol in Tables
securityId string Exchange standard id for each scrip.Refer here
tradedQuantity int Number of shares executed
tradedPrice float Price at which trade is executed
createTime string Time at which the order is created
updateTime string Time at which the last activity happened
exchangeTime string Time at which order reached at exchange
drvExpiryDate int For F&O, expiry date of contract
drvOptionType enum string Type of Option
CALL PUT
drvStrikePrice float For Options, Strike Price

Trades of an Order

Users can retrieve the trade details using an order id. Often during partial trades or Bracket/ Cover Orders, traders get confused in reading trade from tradebook.The response of this API will include all the trades generated for a particular order id.

curl --request GET \
--url https://api.dhan.co/trades/{order-id} \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

{
    "dhanClientId": "1000000009",
    "orderId": "112111182045",
    "exchangeOrderId": "15112111182045",
    "exchangeTradeId": "15112111182045",
    "transactionType": "BUY",
    "exchangeSegment": "NSE_EQ",
    "productType": "INTRADAY",
    "orderType": "LIMIT",
    "tradingSymbol": "TCS",
    "securityId": "11536",
    "tradedQuantity": 40,
    "tradedPrice": 3345.8,
    "createTime": "2021-03-10 11:20:06",
    "updateTime": "2021-11-25 17:35:12",
    "exchangeTime": "2021-11-25 17:35:12",
    "drvExpiryDate": null,
    "drvOptionType": null,
    "drvStrikePrice": 0.0
}


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
orderId string Order specific identification generated by Dhan
exchangeOrderId string Order specific identification generated by exchange
exchangeTradeId string Trade specific identification generated by exchange
transactionType enum string The trading side of transaction
BUY SELL
exchangeSegment enum string Exchange & Segment
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
productType enum string Product type of trade
CNC  INTRADAY  MARGIN  CO BO
orderType enum string Order Type
LIMIT MARKET STOP_LOSS STOP_LOSS_MARKET
tradingSymbol string Refer Trading Symbol in Tables
securityId string Exchange standard id for each scrip. Refer here
tradedQuantity int Number of shares executed
tradedPrice float Price at which trade is executed
createTime string Time at which the order is created
updateTime string Time at which the last activity happened
exchangeTime string Time at which order reached at exchange
drvExpiryDate int For F&O, expiry date of contract
drvOptionType enum string Type of Option
CALL PUT
drvStrikePrice float For Options, Strike Price


Note: For description of enum values, refer Annexure