Payload reference
Product path (preferred):
POST /strategy/:strategy_id/eq|fut|opt- Content-Type:
application/json(JSON sent astext/plainis also accepted) - URL: copy from Strategy → Config → Webhook URL (includes
?key=…)
Request fields
| Field | Type | Required | Description |
|---|---|---|---|
action | string | yes | BUY · SELL · EXIT · EXIT_BUY · EXIT_SELL · MODIFY · FORCE_EXIT · EXIT_ALL |
symbol | string | yes except flatten | Required for entry, exit, and modify. Optional filter on flatten. |
price | number | yes on entry | Number or numeric string |
sl | number | no | Stop-loss; omit or 0 = none. On MODIFY: new stop |
target | number | no | Target; omit or 0 = none. On MODIFY: new target |
exchange | string | no | NSE / BSE / MCX |
exchange_segment | string | no | e.g. NSE_EQ, NSE_FNO |
security_id | number | no | Dhan security id — preferred for F&O |
qty / quantity | number | no | Absolute quantity (overrides Settings) |
lots | number | no | Whole lots (F&O) |
is_intraday | boolean | no | Default from Settings. false → CNC for equity only |
trail_sl | number | no | Trailing jump in price points (₹), not percent (Dhan trailingJump). Needs an sl. 0 / omit = off |
order_mode | string | no | LIMIT · MARKET · AUTO |
key | string | no | Not needed for TradingView. Use ?key= on the URL. Optional for Postman. |
order_id | string | no | On MODIFY only: pin a specific Dhan order |
Not supported: legs[] (HTTP 400). One contract per request.
Minimal entry
{
"action": "BUY",
"symbol": "RELIANCE",
"price": 2950.5
}
Entry with SL + target
{
"action": "BUY",
"symbol": "RELIANCE",
"price": 2950.5,
"sl": 2920,
"target": 3010,
"trail_sl": 0
}
sl / target of 0 means none. Omit qty / lots to use Settings.
Exit
{
"action": "EXIT",
"symbol": "RELIANCE",
"price": 2980
}
Modify SL / target
{
"action": "MODIFY",
"symbol": "RELIANCE",
"sl": 2910,
"target": 3050
}
Flatten
{
"action": "FORCE_EXIT"
}
Optional: "symbol": "RELIANCE". Alias: EXIT_ALL.
Identical buy/sell and exit payloads for the same strategy are deduped for about 1 hour. MODIFY and FORCE_EXIT are not.
Settings that affect webhooks
| Setting | Effect |
|---|---|
| Auto-Execute | Off = signal only. On = send to Dhan |
| Capital / lots | Size when JSON omits qty / lots |
| Order mode | When JSON omits order_mode |
| Trade only in market hours | Rejects BUY / SELL outside 09:15–15:30 IST Mon–Fri |
| Square-off time | Flatten open lots at that IST time once per day |
| Daily profit / loss | Stops automatic trading for this strategy only |
See Force exit & timings. Auth: Authentication.
Errors
| Status | Meaning |
|---|---|
| 400 | Invalid JSON / missing price on entry / legs[] / target or trail without sl / plain-text not recognized |
| 401 | Missing or invalid API key — see Authentication |
| 403 | TradingView off, strategy disabled, outside market hours, or max trades per day |
| 404 | Strategy or symbol not found / no open position to exit |
200 + duplicate: true | Same buy/sell or exit already processed within ~1 hour |