Skip to content

Postback

Postback API or Webhooks uses a POST request with JSON payload to the Postback URL. This JSON payload contains order update in case of change in status (TRANSIT, PENDING, REJECTED, CANCELLED, TRADED or EXPIRED) or whenever order is modified or partially filled.

This Postback API is on access token level i.e. all trades originating from one particular access token will be sent to that particular Webhook URL. This makes it optimal for individual developers.

Postback Payload

The JSON payload is sent as a raw HTTP POST body in below structure.

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 MTF  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

Setting up Postback

To set up Postback API, you will need to provide a unique Postback URL to receive callbacks. You will need to follow the steps below to set up Postback URL:

  • While generating access token on web.dhan.co, enter your URL in the 'Postback URL' field.
  • Click on 'Generate' to successfully set Postback and generate a new token.


Important: You will not receive postback calls if Postback URL is set to localhost or 127.0.0.1.


Note: To receive Postback originating for all orders placed from a platform/app, Partner Login module needs to be used.