API Settings
Configure your Dhan API credentials for automated trading
Your Webhook Endpoint
/api/postbackCopy this URL and paste it in your Dhan API settings under "Postback URL"
Benefits of Postback URL
- • Instant notifications - Know immediately when orders are filled
- • Reduced API calls - No need to poll for order status
- • Faster execution - React to fills instantly for stop-loss placement
Get this from Dhan Web: Profile → Security → Set up TOTP → Copy the secret key
Optional: For automated token refresh
How to Set Up TOTP
- Log in to web.dhan.co
- Go to Profile → Security Settings → TOTP Setup
- Scan the QR code with an authenticator app (Google Authenticator, Authy, etc.)
- Copy the secret key shown below the QR code
- Paste the secret key above to enable TOTP in this app
Benefits of TOTP
- • Faster authentication - No waiting for SMS/email OTPs
- • More reliable - Works even without mobile network
- • Automation ready - Generate codes programmatically for token refresh
Log in to your Dhan account at dhan.co
Use your registered credentials to access your account
Navigate to API Settings
Go to Profile > API Trading > Generate Access Token
Copy Client ID and Access Token
The token is valid for 24 hours and needs to be refreshed daily
Whitelist Your IP Address
SEBI mandates IP whitelisting for order placement. Add your static IP in Dhan API settings.
Configure Postback URL (Optional)
Set up the webhook URL above in Dhan API settings for instant order updates
Set Up TOTP (Optional)
Enable TOTP for faster authentication and easier daily token refresh