DhanHQ API
Access Data and Trading via APIs
To use the Webhook functionality, you must have an active paid TradingView plan. Once you have an active paid plan, follow the steps below to configure the Dhan Webhook :
1. Log in to web.dhan.co.
2. Navigate to Orders → Webhooks.
3. Click on Manage to activate the Webhook functionality.
4. Select Generate New, choose the required token validity, and generate the Webhook URL.
5. Once the Webhook URL is generated, scroll down to the Create JSON section.
6. Select the required Instrument Type, such as Equity, Futures, or Options.
7. Click on Add Script.
8. Select the required script/instrument.
9. Click on Generate JSON.
10. The system will provide the required Webhook URL and JSON structure, which you can use while configuring alerts in TradingView.
The documentation PDF and YouTube tutorial are also available on the same JSON Creator page for your reference.
Regarding strategy automation: Please note that the complete Pine Script and strategy-side automation need to be developed, configured, and managed from your end.
This includes :
a. Developing or modifying the complete Pine Script.
b.Defining entry and exit conditions.
c. Implementing the required buy/sell logic.
d. Implementing the required strike-selection logic.
e. Handling instrument or strike decoding, wherever required.
f. Creating TradingView alerts based on your strategy conditions.
g. Dynamically generating the appropriate JSON payload whenever a trading signal is triggered.
h. Configuring the generated Dhan Webhook URL in the corresponding TradingView alerts.
For example, if your strategy requires selecting the strike price nearest to a multiple of 100, this strike-selection logic must be implemented within your Pine Script or automation system. Similarly, all dynamic conditions and calculations required by your strategy must be handled within your own implementation.
Dhan provides the Webhook URL and the required JSON structure for order placement. However, we do not currently provide a built-in mechanism to develop or modify your complete Pine Script, implement your strategy logic, select strikes based on your strategy conditions, or decode the required values on your behalf.
Therefore, the responsibility for developing and completing the Pine Script and strategy-side automation logic rests with you. Once your Pine Script generates the required JSON payload based on your strategy conditions, it can be sent to the Dhan Webhook URL to place the corresponding order.
The overall workflow is as follows:
Your Pine Script/Strategy → TradingView Signal → TradingView Alert → Dhan Webhook URL → JSON Payload → Order Placement. Please ensure that the Pine Script, alert conditions, dynamic parameter generation, and JSON payload are correctly configured from your end as per your strategy requirements.
For any further clarification regarding the Dhan Webhook setup or JSON structure, please feel free to write back to at apihelp@dhan.co. We will be happy to assist you.
Related FAQs

