Dhan

Add and validate your Dhan account in QUANT LEVELS.

In short: Enable TOTP on Dhan, generate an API Key + Secret, register your static IP with Dhan, then add the account here with your Client ID, MPIN, TOTP Secret Key, API Key and API Secret. Your access token then auto-refreshes every day at 8:30 AM - nothing to do manually after setup.

Step 1 - Generate API Key

  1. Open the Dhan app or web.dhan.co and log in.
  2. Go to Profile → DhanHQ Trading APIs.
  3. Generate an API Key (API Secret is optional for Dhan, but add it if shown).
  4. Fill in these URLs on the API settings page:
    FieldValue
    Redirect Urlhttps://quantlevelsdevloper.in/auth/dhan
    Postback Urlhttps://quantlevelsdevloper.in/postback/dhan?key=jByKSan5riiFoxHxtetuI2dkBRkOA_dm

Step 2 - Enable TOTP

  1. On the same API page, enable TOTP.
  2. Scan the QR code in Google Authenticator (or any TOTP app).
  3. Copy the TOTP Secret Key shown - you'll need it below.

Step 3 - Set up a static IP

Dhan whitelists API access by IP. Use the Auto Assign button on the Add Account form to get a free IP from our pool, or paste your own proxy. Save the shown IP against your Dhan account.

Step 4 - Add the account

  1. Go to Accounts → Add New Account.
  2. Select Broker as Dhan.
  3. Enter Dhan Client ID, 6-digit MPIN, TOTP Secret Key, API Key and API Secret.
  4. Save. Your token generates immediately and auto-refreshes every day at 8:30 AM.

Common Issues

Login failed: Invalid Token / TOTP Validation Failed

Usually means the TOTP Secret Key was copied wrong, or your server clock has drifted (TOTP codes are time-based). Re-copy the key from Dhan's TOTP setup page and re-save.

Order rejected but account shows as logged in

Check your registered IP against Dhan matches the Proxy IP shown on this account's edit page - Dhan rejects order placement (not login) from a non-whitelisted IP.

Copy trading on Dhan

Dhan sends a live postback for every order on the account, including trades placed manually via Dhan's own app - so a Dhan master account detects your manual trades immediately, no extra setup needed. Mark any Dhan account as Master from Master Overview to start copying its trades to your mapped slave accounts.

FAQ

Do I need a paid Dhan API plan?

No. Dhan's trading APIs are free to use.

Can I use the same Dhan account as both master and slave for different masters?

An account can be a master or a slave, not both at once.