Dhan AlgoTrader

API Settings

Configure your Dhan API credentials for automated trading

Add Credentials
Enter your Dhan API credentials. Tokens are valid for 24 hours and need daily updates.
Postback URL (Webhook)
Receive real-time order updates from Dhan. Configure this URL in your Dhan API settings.

Your Webhook Endpoint

/api/postback

Copy 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
TOTP Authentication
Set up Time-based One-Time Password for faster authentication and potential automated token refresh.

Get this from Dhan Web: Profile → Security → Set up TOTP → Copy the secret key

Optional: For automated token refresh

How to Set Up TOTP

  1. Log in to web.dhan.co
  2. Go to Profile → Security Settings → TOTP Setup
  3. Scan the QR code with an authenticator app (Google Authenticator, Authy, etc.)
  4. Copy the secret key shown below the QR code
  5. 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
How to Get Your API Credentials
1

Log in to your Dhan account at dhan.co

Use your registered credentials to access your account

2

Navigate to API Settings

Go to Profile > API Trading > Generate Access Token

3

Copy Client ID and Access Token

The token is valid for 24 hours and needs to be refreshed daily

4

Whitelist Your IP Address

SEBI mandates IP whitelisting for order placement. Add your static IP in Dhan API settings.

5

Configure Postback URL (Optional)

Set up the webhook URL above in Dhan API settings for instant order updates

6

Set Up TOTP (Optional)

Enable TOTP for faster authentication and easier daily token refresh