Unable to place options order through API - getting DH-905 error despite matching documentation format

I’m trying to place an options order through the API but receiving a DH-905 error (Missing required fields, bad values for parameters etc.) despite matching the payload format from the documentation exactly.

What’s Working:

  • Successfully able to call other endpoints (e.g., /v2/fundlimit)
  • Authentication is working (getting 200 responses for other endpoints)

My Request:

Security Details:
The security ID (46113) corresponds to NIFTY-Dec2024-24400-CE with lot size 25.

What I’ve Tried:

  • Matched payload exactly with documentation format
  • Used proper lot size (25)
  • Tried with and without price
  • Removed optional fields
  • Tried different correlation IDs
  • Verified all fields match the required types
  • Tried doing the same in Postman but I get the same error

Could someone please help identify what might be causing the DH-905 error? More specific error details would be helpful in resolving this issue.

  • Payload:
{
    "dhanClientId":"xxxx",
    "correlationId":"123abc678",
    "transactionType":"BUY",
    "exchangeSegment":"NSE_FNO",
    "productType":"MARGIN",
    "orderType":"MARKET",
    "validity":"DAY",
    "securityId":"46113",
    "quantity":"25",
    "disclosedQuantity":0,
    "price":"260",
    "triggerPrice":0,
    "afterMarketOrder":false,
    "amoTime":"",
    "boProfitValue":0,
    "boStopLossValue":0
}

Trying with this payload but still getting the same error:

{
    "dhanClientId": "xxxx", (changing original id to xxxx)
    "transactionType": "BUY", 
    "exchangeSegment": "NSE_FNO", 
    "productType": "INTRADAY", 
    "orderType": "MARKET", 
    "validity": "DAY", 
    "securityId": "46121", 
    "quantity": 1, 
    "disclosedQuantity": 0, 
    "price": 156.9, 
    "triggerPrice":0.0,
    "afterMarketOrder": false, 
    "boProfitValue": 0.0, 
    "boStopLossValue": 0.0
}

Hello @Chutku

Welcome to MadeForTrade community!

Your first payload is correct, where you are taking quantity in lot size (i.e. 25). However, you have added ‘orderType’ as MARKET but adding price as well. If you want to place market order, then keep price as 0. Else, you can keep order type as LIMIT and enter your desired order price.

1 Like

Thanks for the reply @Hardik. Modified and tried but still no luck :frowning:

Tried this:

{
    "dhanClientId": "xxxx", 
    "correlationId": "ord1733736584",
    "transactionType": "BUY", 
    "exchangeSegment": "NSE_FNO", 
    "productType": "INTRADAY", 
    "orderType": "MARKET", 
    "validity": "DAY", 
    "securityId": "46121", 
    "quantity": "25", 
    "disclosedQuantity": 0, 
    "price": 0,
    "triggerPrice":0,
    "afterMarketOrder": false,
    "amoTime":"",
    "boProfitValue": 0, 
    "boStopLossValue": 0
}

Do we really need all of the above? For example if afterMarketOrder is false, do we still need to pass amoTime as blank? Also, I tried quantity as simple integer and also as a string (shown above) but I get the same error:

{
    "errorType": "Input_Exception",
    "errorCode": "DH-905",
    "errorMessage": "Missing required fields, bad values for parameters etc."
}

I am sure it is something very small that I am missing but not able to figure out!

It worked! I had to make the afterMarketOrder to true and enter OPEN as amoTime since I was doing it “After market”! So I am guessing, when the market is live, I need to pass afterMarketOrder as false and amoTime as blank (“”) and it should work.

Your ‘making quantity in lot size (i.e. 25)’ part of the comment is what I was actually doing wrong earlier. Thank you so much for specifically pointing that out! Very helpful!

{
    "dhanClientId":"110XXX87", 
    "correlationId":"ABC123", 
    "transactionType":"BUY", 
    "exchangeSegment":"NSE_FNO", 
    "productType":"BO", 
    "orderType":"LIMIT", 
    "validity":"DAY", 
    "securityId":"55628", 
    "quantity":"75", 
    "disclosedQuantity":"0",
    "price":"80.0", 
    "triggerPrice":"0",
    "afterMarketOrder":"false",
    "amoTime":"",
    "boProfitValue":"20.0", 
    "boStopLossValue":"10.0"
}

I am constantly getting this error :

{
    "errorType": "Input_Exception",
    "errorCode": "DH-905",
    "errorMessage": "Missing required fields, bad values for parameters etc."
}

I am not able to place order via Dhan API even after every thing is in align with the Dhan API documentation ? Can someone please help me this ASAP.

@Hardik @Naman @RahulDeshpande @Dhan @Dhan_Cares

It’s been 4 days no one reply is anyone around or I am just beating around the bush.

Hello @rahulbajaj

Sorry for missing this thread earlier. Can you check the security ID over here? Rest everything looks good.
Or if you can say which instrument are you trying to place this order in, would be able to replicate at my end as well.

@rahulbajaj - I may be wrong but can you try also changing triggerPrice from 0 to 0.0. I am sending a float value for price and triggerPrice values when using the API. It may or may not work but you can give it a try. Like @Hardik mentions everything else looks good.

1 Like

Thanks @Chutku and @Hardik I am trying with nifty 22700 ce or pe I guess. It was for 21st Feb but it expired so can you try with upcoming weekly expiry.

Hello @rahulbajaj

Just tried and it is working fine. Can you try at your end with the same, if not kindly DM your Client ID and will check logs for this.

Hello @Hardik Still it is not working, Can you please check I have DM you.

have you received my DM @Hardik

still waiting on the update @Hardik

@Hardik @Dhan_Cares @RahulDeshpande

Hello @rahulbajaj

Have reverted to you over DM.

Hi @Hardik , Am facing similar issue but am using DhanHQ object to place order.

def place_order(scrip_id, client_id, quantity=75, price=0.5):
    """
    Places a BUY order using the Dhan API.
    """
    try:
        order = dhan.place_order(
            security_id=scrip_id,
            exchange_segment=dhan.NSE_FNO,
            transaction_type=dhan.BUY,
            quantity=int(quantity),
            order_type=dhan.LIMIT,  
            product_type=dhan.INTRA,
            price=float(price),  
            trigger_price=0.0,  
            disclosed_quantity=0,
            after_market_order=False,
            validity="DAY",
            amo_time="OPEN",
            bo_profit_value=None,
            bo_stop_loss_Value=None,
            tag="order-123"
        )

        print("Order Response:", order)
        return order  

    except Exception as e:
        print("Error placing order:", str(e))
        return {"status": "error", "message": str(e)}

help(dhan.place_order)
order_status = place_order(scrip_security_id, client_id)

What am i missing ?

Hey @dexter77

What is the error you are getting? Just one thing, make sure the quantity is in lot size itself (for example, Nifty will be 75)

Thanks @Hardik , i was able resolve on my own, where i had parse the scrip id to string, where it was an array in my case. Thanks for your interest.

{
    "dhanClientId":"XXX",
    "correlationId":"ABC123",
    "transactionType":"BUY",
    "exchangeSegment":"NSE_FNO",
    "productType":"INTRADAY",
    "orderType":"MARKET",
    "validity":"DAY",
    "securityId":"51118",
    "quantity":"75",
    "price":"0.0",
    "afterMarketOrder":false,
    "triggerPrice":"0.0",
    "amoTime":"",
    "boProfitValue":"", 
    "boStopLossValue":""
}

i am also getting same issue …