I am writing a script to update forever orders in my account as per Forever Order - DhanHQ Ver 2.0 / API Document
Request:
curl -X PUT “https://api.dhan.co/v2/forever/orders/5132507282049 ” -H “Accept:application/json, text/plain, / ” -H “Content-Type:undefined” -H “access-token:PUT_MY_TOKEN_HERE” --data ‘{“dhanClientId”:“PUT_CLIENT_ID_HERE”,“orderId”:“5132507282049”,“orderFlag”:“SINGLE”,“orderType”:“STOP_LOSS”,“legName”:“ENTRY_LEG”,“quantity”:6,“price”:1939.4,“triggerPrice”:1939.3,“disclosedQuantity”:0,“validity”:“DAY”}’
I keep getting below error
{“errorType”:“Input_Exception”,“errorCode”:“DH-905”,“errorMessage”:“Missing required fields, bad values for parameters etc.”}
Kindly help here. Error is too generic to understand what is going wrong.
I am passing all the required paramters in payload as per documentation. Kindly let me know if I am doing anything wrong.
@PravinJ @Mohseen_Usmani Kindly help with this issue.
Hi @niteenautade , try with the below modifications :
Field
Valid Example
orderType
"LIMIT"
or "MARKET"
orderFlag
"SINGLE"
or "OCO"
legName
"TARGET_LEG"
or "STOP_LOSS_LEG"
triggerPrice
Required for SL leg
validity
"DAY"
only
Content-Type
Must be "application/json"
@Mohseen_Usmani I want to update forever order that have transactionType = BUY.
I believe legName “TARGET_LEG” or “STOP_LOSS_LEG” are for Sell forever orders.
Please correct me if I am not wrong
@Mohseen_Usmani Even with the modifications you mentioned, it is giving same error
{
orderId: ‘5132507282049’,
error: {
errorType: ‘Input_Exception’,
errorCode: ‘DH-905’,
errorMessage: ‘Missing required fields, bad values for parameters etc.’
}
}
Hi @t7support can you please guide here.
@niteenautade @Mohseen_Usmani
There is no legName called ENTRY_LEG in the documention. I think the API doesn’t allow us to modify entry leg of a forever order as of now.
@Hardik
@t7support The documentation mentions that ENTRY_LEG is supported.
https://dhanhq.co/docs/v2/forever/#:~:text=to%20be%20done-,ENTRY_LEG,-%2D%20For%20Single%20and
Refer - Modify Forever Order section payload structure
@niteenautade
I pasted the documentation from sandbox interface. It seems both differ. @Hardik pls clarify which is correct
https://sandbox.dhan.co/v2/#/operations/modifyforeverorder
Hardik
July 30, 2025, 4:13am
11
Hey @t7support @niteenautade
Over here, you can use TARGET_LEG
and STOP_LOSS_LEG
for modifying Forever Order. You can check the same here: Dhan API
Will update the documentation here as well.
2 Likes
Using STOP_LOSS_LEG
worked. Thanks @Hardik !
1 Like