Dhan (DhanHQ) — How to Get Your API Credentials
DhanHQ offers two credential modes — a single Access Token, or an API Key + Secret pair.
This guide covers getting either one from your Dhan Web account. It stops once you have
your credentials in hand.
Before You Start
- An active Dhan trading account
- TOTP-based two-factor setup — Dhan's documentation states this is mandatory for all API users, not optional
Step 1: Open "Access DhanHQ APIs"
Log in to Dhan Web, click your profile icon in the top-right corner, then select
"Access DhanHQ APIs" (also reachable via Profile → DhanHQ Trading APIs).
📸 Screenshot 1: Profile menu showing "Access DhanHQ APIs"
Highlight the profile icon and the menu entry.
Step 2: Request access (first time only)
If this is your first time using Dhan's APIs, click "Request Access" and refresh the
page. Per Dhan's documentation, access is granted within seconds.
📸 Screenshot 2: "Request Access" screen
Highlight the Request Access button.
Step 3: Choose Access Token mode or API Key mode
By default this page opens in Access Token mode. Use the toggle in the
top-right to switch to API Key Mode instead if you'd rather have a
separate API Key and Secret pair.
📸 Screenshot 3: Access Token / API Key Mode toggle
Highlight the toggle control.
Step 4: Generate your credentials
Click "Generate API Key" (or "Generate Access Token", depending on the mode chosen).
Then scroll to Profile Details and copy your Client ID — used alongside your API
credentials.
📸 Screenshot 4: Generated credentials with Client ID
Mask the actual key/secret/token values before sharing — use dummy values if illustrating this step.
Step 5: Complete TOTP setup
Under "Optional Settings" (despite the name, Dhan's documentation states this step is
mandatory), click "Set-up TOTP" and follow the instructions to configure two-factor
authentication for API access.
📸 Screenshot 5: TOTP setup screen
Highlight the Set-up TOTP button.
What You Should Have Now
- Access Token — if you used Access Token mode, or
- API Key + API Secret — if you used API Key mode
- Client ID — from your Profile Details
- TOTP configured — mandatory before the credentials above will work
Important Limitations
- 12-month validity: Dhan's documentation states generated API Keys and Secrets are valid for 12 months, after which they must be regenerated.
- Mandatory TOTP: API access will not work until two-factor setup is complete, per Dhan's documentation.
- Rate limits are not covered in the pages reviewed for this guide — check DhanHQ's documentation directly for current figures.
🔒 Security warning: Keep your Access Token, API Secret, and TOTP details
confidential. Never share them publicly. Never include real credentials in screenshots —
use dummy values or mask them.
Screenshot Checklist
- Profile menu showing "Access DhanHQ APIs"
- "Request Access" screen
- Access Token / API Key Mode toggle
- Generated credentials with Client ID
- TOTP setup screen
Source: Dhan's official DhanHQ API documentation (dhanhq.co/docs) and Dhan Support articles (dhan.co/support).