Order Placement API (v2.0) + Suggestions for Improvements

Hi @PravinJ @Hardik

I’ve been an API consumer since version 1.0 and migrated my integration to v2.0 early this year. However, I didn’t get a chance to work further at that time. Now, when I tried to explore and proceed with the integration again, the order placement API is failing in both Live and Sandbox environments.

Here’s the request payload I am using:

{
	"price": 114.45,
	"boProfitValue": 0.0,
	"boStopLossValue": 0.0,
	"dhanClientId": "XXXXXXXX",
	"correlationId": "anythingggg",
	"transactionType": "BUY",
	"exchangeSegment": "NSE_FNO",
	"productType": "MARGIN",
	"orderType": "LIMIT",
	"validity": "DAY",
	"securityId": "47761",
	"quantity": 2,
	"afterMarketOrder": false
}

Response received:

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

This error message is too generic and doesn’t specify which field is invalid or missing, which makes debugging very difficult. I had already suggested earlier that API error messages should be more descriptive and meaningful, so that developers can quickly identify the exact issue. Unfortunately, this still seems to be a problem.

Feedback / Suggestions

  1. Clearer Error Responses
    I requested last year also please improve error responses to clearly mention which parameter is wrong or missing instead of a broad message like DH-905.
  2. API Change Log
    I could not find any changelog for v2.0 or subsequent updates. Having a documented changelog (similar to DeltaExchange API Changelog) would help developers track and adapt to changes smoothly.
  3. Simplify or Better Document the Order Placement API
    Order placement currently feels complex since the payload requirements change by order type. If simplification isn’t possible, please at least provide comprehensive documentation with complete payload examples for all order types (LIMIT, MARKET, BO, CO, etc.).

For example, the LIMIT order request above used to work earlier but now fails without clear guidance.

I hope you’ll consider these points to improve the developer experience with Dhan APIs.

Thanks!

Hi @Dharmender ,

As checked in the payload you shared, kindly remove conditionally required fields. Additionally, please ensure the quantity is not entered in terms of lots. You can also remove the co-relation field entirely.

Kindly refer to the corrected payload below:

{
  "validity": "DAY",
  "exchangeSegment": "NSE_FNO",
  "securityId": "47761",
  "productType": "MARGIN",
  "orderType": "LIMIT",
  "dhanClientId": "1103351541",
  "afterMarketOrder": true,
  "quantity": 75,
  "price": 114.45,
  "transactionType": "BUY",
  "amoTime": "OPEN"
}

EndPoint - https://api.dhan.co/v2/orders

We have also noted your feedback regarding mentioning the exact fields to be included in such cases of invalid requests.

For the API Change Log suggestion, you may refer to the release notes here: Releases - DhanHQ Ver 2.0 / API Document

You can also review the complete order placement documentation here: Orders - DhanHQ Ver 2.0 / API Document

Hi @Shubham_Singh

Thanks for your attention!

I tried payload shared by you but still it isn’t working.

You can also review the complete order placement documentation here: Orders - DhanHQ Ver 2.0 / API Document

Would you please help to understand data needed to send for below order placement types:
Bracket Market order
Buy at Market order
Buy at Price order
Stop Loss order

as per your documentation? Thanks in advance!

Hi @Shubham_Singh @Hardik @Dhan_Auto_Moderator

Do you have update on this?

@Hardik

Do you have update on this? It is more than 2 weeks since I’m blocked due to this.

Hey @Dharmender

Can you check if the quantity and Security ID being passed over here is correct. Also, if you can share the cURL request once, we can help you faster.