Guides 12 min read · Updated
Angel One SmartAPI Static IP: Register, Change and Fix Errors
SmartAPI static IP for Angel One: where to add primary and secondary IPs, the weekly change limit, the TOTP login in Python and IP error fixes.
Angel One's SmartAPI accepts orders only from a static IP address that you have registered on your API app. Since 1 April 2026, SmartAPI checks the source IP of every place, modify and cancel order request, and of every GTT create, modify and cancel request, and processes it only if it comes from your registered static IP. You add a primary IP and an optional secondary IP at smartapi.angelone.in under New Login, My APIs, Add App. Each can be changed once a week, and only IPv4 addresses are accepted.
This guide covers the portal, the weekly limit, a TOTP login with the official smartapi-python library (version 1.5.5, still the latest on PyPI on 15 November 2026), a test order, a systemd service and the common errors. For the rule across all brokers, see our static IP guide for algo trading; the Kite Connect and Dhan API guides do the same job for those brokers.
Why does Angel One SmartAPI need a static IP?
SEBI's circular of 4 February 2025 on retail algo trading became binding on every broker from 1 April 2026. NSE's implementation standards require a static IP for API access, with one primary and one optional secondary IP and at most one change per calendar week. On 15 November 2026, SEBI's circulars list showed nothing newer on retail algo trading; our guide to SEBI's algo trading rules covers the full framework.
Angel One's FAQ on the April 2026 changes adds the SmartAPI details:
- The static IP is for "tech-savvy" clients running their own algo. A no-code platform hosted on Angel One's servers needs none.
- An IP maps to one client at a time. The FAQ lets family members, as SEBI defines family, share one on a written request with 2FA validation, but a SmartAPI forum admin earlier said family sharing wasn't supported yet. Ask Angel One before you rely on it.
- Below 10 orders per second per exchange, your algo needs no exchange registration.
- Market orders and IOC orders are prohibited for algo trading.
SmartAPI's own rate limit is stricter: place, modify and cancel requests together may not exceed 9 per second per client code, and extra requests fail with a 403 "Access denied" error.
Only order calls are checked. SmartAPI's order documentation says the source IP of place, modify and cancel requests "will be validated against the static IP registered by the user", and the GTT documentation says the same for GTT rules. Login, market data, positions and the order book work from any IP.
Where to add your static IP in the SmartAPI portal
First find the address. On an Algo VPS, algo-ip prints the IPv4 address to register. On another Linux server, run curl -4 https://ifconfig.me on the server itself. Then, as of 15 November 2026:
- Go to smartapi.angelone.in and choose New Login. Angel One's forum notice says the older Login is only for editing or retiring keys made before the change.
- Open My APIs, the page headed "My Smart API & Apps".
- Click + ADD APP, or the pencil icon beside an existing app.
- Fill in App Name, Redirect URL, an optional Postback URL, Primary Static IP (required) and Secondary Static IP (optional).
- Save. The portal generates the API key once an app exists.
You can have up to 5 apps. The redirect URL is only used by SmartAPI's browser-based publisher login, so a bot that logs in with PIN and TOTP ignores it, but the form still needs a valid URL. Both IP fields accept only four numbers separated by dots: no IPv6. A notice on the SmartAPI site suggests getting a static IP from your internet provider or "a secure VPN service", but the address must be used by you alone, so a VPN exit shared with other customers won't do.
How often can you change the SmartAPI static IP?
Once a week. The portal says "Primary IP and Secondary IP can be updated once in a week only", and Angel One's FAQ says "not more than once a calendar week". So:
- Use the secondary slot for a real backup, such as a second server or an ISP static IP, and register it when you create the app.
- Test from the server. An order from your laptop fails, so don't spend a weekly change on your home address.
- Keep the server. A HostEthical VPS keeps its IPv4 address through reboots and reinstalls, but a new server means a new IP.
Log in again after any change. Angel One doesn't say whether a session survives an IP change; Upstox and Dhan both require a new token, so a fresh login is the safe habit.
How to log in to SmartAPI from Python with TOTP
SmartAPI's login documentation says: "In order to login, you need a client code, valid pin and TOTP." The session "remains active till 12 midnight, unless the user chooses to log out", which is how Angel One meets the exchanges' daily logout rule. The library's generateSession(client_code, pin, totp) does the login, and Angel One's README makes the 6-digit code with pyotp from your TOTP secret, the value behind the QR code on the SmartAPI site's Enable TOTP page.
On an Algo VPS both libraries are already installed (/opt/algo/venv/bin/pip show smartapi-python pyotp). Elsewhere, install four packages: the PyPI package doesn't declare logzero or websocket-client, but its code imports both.
python3 -m venv ~/venv
~/venv/bin/pip install smartapi-python pyotp logzero websocket-client
Put your credentials in /opt/algo/.env, which only root can read:
ANGEL_API_KEY=the_key_from_my_apis
ANGEL_CLIENT_CODE=your_client_code
ANGEL_PIN=your_pin
ANGEL_TOTP_SECRET=the_secret_behind_the_qr_code
Together these four values can open an API session on your account. Use SSH keys only, never commit the file to git, and set up TOTP again if you suspect a leak.
Test your static IP with one order
Save this as /opt/algo/angel_test.py. It logs in, places one LIMIT order and prints the reply, and refuses to run until you set your own price.
# /opt/algo/angel_test.py: log in, place ONE limit order, print the reply
import os
import sys
import pyotp
from SmartApi import SmartConnect
LIMIT_PRICE = 0.0 # set your own limit price before running
if LIMIT_PRICE <= 0:
sys.exit("Set LIMIT_PRICE first.")
client = os.environ["ANGEL_CLIENT_CODE"]
api = SmartConnect(api_key=os.environ["ANGEL_API_KEY"])
totp = pyotp.TOTP(os.environ["ANGEL_TOTP_SECRET"]).now()
login = api.generateSession(client, os.environ["ANGEL_PIN"], totp)
if not login.get("status"):
sys.exit(f"Login failed: {login.get('message')}")
print("Logged in as", login["data"]["clientcode"])
reply = api.placeOrderFullResponse({
"variety": "NORMAL",
"tradingsymbol": "SBIN-EQ", # the example in Angel One's README
"symboltoken": "3045",
"transactiontype": "BUY",
"exchange": "NSE",
"ordertype": "LIMIT", # market orders are barred for algo trading
"producttype": "DELIVERY",
"duration": "DAY",
"price": str(LIMIT_PRICE),
"quantity": "1",
"ordertag": "ipcheck", # your own label, under 20 characters
})
print(reply)
api.terminateSession(client)
Run it as root:
cd /opt/algo
set -a; . ./.env; set +a
venv/bin/python angel_test.py
An order ID in the reply means Angel One accepted the request from your IP. Risk checks on funds or price bands can still reject the order afterwards, so check the order book, and cancel with api.cancelOrder(order_id, "NORMAL") if you don't want a fill. Two quirks: the library writes an error log to logs/<date>/app.log under the current directory, so run it from a writable folder, and it sends a fixed placeholder in its X-ClientPublicIP header. Angel One validates the request's source IP, so ignore that header when debugging.
Run your SmartAPI bot 24/7 with systemd
This skeleton logs in, checks a price every minute, and logs in again after Angel One ends the session at midnight. Save it as /opt/algo/angelbot.py:
# /opt/algo/angelbot.py: start with systemctl enable --now algo@angelbot
import logging
import os
import sys
import time
import pyotp
from SmartApi import SmartConnect
from SmartApi.smartExceptions import TokenException
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
SESSION_OVER = {"AG8001", "AG8002", "AB1010", "AB1011"} # token invalid or expired, session expired, not logged in
def login():
api = SmartConnect(api_key=os.environ["ANGEL_API_KEY"])
totp = pyotp.TOTP(os.environ["ANGEL_TOTP_SECRET"]).now()
r = api.generateSession(os.environ["ANGEL_CLIENT_CODE"], os.environ["ANGEL_PIN"], totp)
if not r.get("status"):
logging.error("Login failed, not retrying: %s", r.get("message"))
sys.exit(0) # a clean exit, so systemd doesn't retry in a loop
logging.info("Logged in as %s", r["data"]["clientcode"])
return api
api = login()
while True:
try:
r = api.ltpData("NSE", "SBIN-EQ", "3045")
except TokenException:
r = {"errorcode": "AG8001"}
except Exception as e: # network trouble: log it and try again
logging.warning("request failed: %s", e)
time.sleep(30)
continue
code = r.get("errorcode") or r.get("errorCode")
if code in SESSION_OVER:
logging.warning("Session over (%s), restarting to log in again", code)
sys.exit(1) # systemd restarts the bot, which logs in afresh
if r.get("status"):
logging.info("SBIN last price %s", r["data"]["ltp"])
# your strategy goes here; send orders with api.placeOrderFullResponse(...)
time.sleep(60)
On an Algo VPS, the algo@ template runs it with /opt/algo/venv, loads /opt/algo/.env, restarts it after a crash and starts it at boot: systemctl enable --now algo@angelbot, then journalctl -u algo@angelbot -f for the log. On any other server, put the script in /home/algo/bot (owned by an algo user), the credentials in /etc/angelbot.env with chmod 600, and save this as /etc/systemd/system/angelbot.service:
[Unit]
Description=Angel One SmartAPI bot
After=network-online.target
Wants=network-online.target
[Service]
User=algo
WorkingDirectory=/home/algo/bot
EnvironmentFile=/etc/angelbot.env
ExecStart=/home/algo/venv/bin/python angelbot.py
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target
Start it with sudo systemctl daemon-reload && sudo systemctl enable --now angelbot. The codes in SESSION_OVER come from SmartAPI's published error table. A failed login stops the bot rather than retrying every few seconds with a wrong PIN, so check the log and restart it by hand. When you add real orders, give each an ordertag and look for it in the order book first, so a restart can't send an order twice. Our guide to running a trading bot 24/7 covers timers, holidays and alerts.
Fixing "Unregistered IP address" and other SmartAPI errors
| What you see | What it means | What to do |
|---|---|---|
| "Access denied: Unregistered IP address. Register your IP before retrying." (AG7002) | The order didn't come from an IP on your app. Tradetron's help centre reports this wording; Angel One's published error table doesn't list it | The checklist below |
| "Primary Static IP is already associated with another App" | Forum users report it when the IP is already on another app or account | Give each account its own IP |
| AG8001, AG8002, AB1010 | Invalid token, token expired, session expired | Log in again; sessions end at midnight |
| 403 "Access denied" on orders | More than 9 order requests a second | Throttle place, modify and cancel together |
For an IP rejection, check these in order:
- Send the order from the server, not your laptop, with no VPN or proxy in the path.
- Compare addresses.
algo-iporcurl -4 https://ifconfig.memust match the IP under My APIs, digit for digit. - Use the right key: the one from the New Login portal, not a key made under the old Login.
- Check IPv6. On 15 November 2026,
apiconnect.angelone.in, the host the library calls, had only an IPv4 address in DNS, so requests leave over IPv4 anyway. A SmartAPI forum moderator has given 15 December 2026 as a tentative date for IPv6. Once Angel One adds it, a server that prefers IPv6 would send orders from an unregistered address. Algo VPS prefers IPv4; on other servers, add the/etc/gai.confline from our static IP guide. This shows the address your server uses:curl -sv -o /dev/null https://apiconnect.angelone.in 2>&1 | grep -i "connected to" - Log in again after changing the IP.
- Mind the weekly limit. If this week's change went wrong, contact Angel One's SmartAPI support.
Upstox and Fyers static IP setup compared
If you run bots on more than one broker, the details differ. This is what each broker's pages said on 15 November 2026:
| Broker | Where to register the IP | Primary and backup | Changes | IP version |
|---|---|---|---|---|
| Angel One | smartapi.angelone.in → New Login → My APIs → Add App or edit | Primary required, secondary optional | Once a week each | IPv4 only |
| Upstox | My Apps → static IPs on your algo app, or the Update Static IPs API | Primary required, secondary optional | Once per calendar week; existing access tokens stop working | IPv4 or IPv6 |
| FYERS | API dashboard → User Apps → "Algo trading app" → static IP and redirect URL → Activate (guide) | Not stated on that page | Not stated | Not stated |
Upstox's algo trading notice says the check covers placing, modifying and cancelling orders, multi orders, GTT orders and exiting all positions, but not holdings, positions, funds or historical candles, and that no other customer may share or register your IP. On FYERS, activating the algo app gives you a new App ID ending in "200" and a new secret, which your code must use. The upstox-python-sdk and fyers-apiv3 packages are preinstalled on Algo VPS alongside smartapi-python.
Algo VPS Mumbai costs ₹1,510 a month, or about ₹1,325 a month when billed yearly, with a dedicated IPv4 address, IPv4-first networking and the algo@ service ready. A plain Cloud VPS from ₹860 a month, or about ₹774.17 a month when billed yearly works too if you install Python and the SDK yourself; Mumbai adds a monthly location fee. And if you trade through a no-code platform hosted on Angel One's own servers, you need neither a static IP nor a server.
Frequently asked questions
Where do I add a static IP in Angel One SmartAPI?
Go to smartapi.angelone.in, choose New Login, open My APIs and click Add App, or the edit icon beside an existing app. Enter the app name, a redirect URL, your Primary Static IP and, if you want a backup, a Secondary Static IP. The portal creates the API key once the app exists. You can have up to 5 apps, and both IP fields accept IPv4 addresses only.
How often can I change my SmartAPI static IP?
Once a week. The SmartAPI portal says the primary and secondary IP can each be updated once a week only, and Angel One's FAQ says not more than once a calendar week. Register a backup as your secondary IP from the start, test only from the server you registered, and log in again after any change before you place your next order.
Does Angel One SmartAPI support IPv6 static IPs?
Not as of November 2026. The IP fields in the SmartAPI portal accept only IPv4 addresses, and Angel One's forum notice said only IPv4 static IPs are supported for now. When we checked on 15 November 2026, the API host apiconnect.angelone.in had only an IPv4 address, so requests from a dual-stack server still leave over IPv4.
Which SmartAPI calls need the static IP?
Only order calls. SmartAPI's documentation says the source IP of place, modify and cancel order requests, and of create, modify and cancel GTT requests, is checked against your registered static IP. Login, market data, quotes, positions, holdings and the order book work from any IP. Order requests are also capped at 9 per second in total.
Why do I get "Unregistered IP address" from Angel One?
The order request came from an address that isn't registered on your SmartAPI app. The usual causes are sending the order from a laptop instead of the server, a VPN, a typing mistake in the IP, or using an API key made under the old login. Compare the server's public IPv4 with the IP shown under My APIs, then log in again and retry.