<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Complete fix: AG8004 &quot;Invalid API Key&quot; after successful login + &quot;Primary static IP is already associated with another app&quot;]]></title><description><![CDATA[<p dir="auto">Spent a weekend debugging this after the April 2026 portal migration — posting the complete resolution since the pieces are scattered across many threads.</p>
<p dir="auto"><strong>Symptoms:</strong> <code>generateSession</code> succeeds, but every data call (<code>getLtpData</code>, <code>getCandleData</code>) returns AG8004 "Invalid API Key". Creating a new app fails with "Primary static IP is already associated with another app" — even for IPs you registered yourself.</p>
<p dir="auto"><strong>Root causes (verified):</strong></p>
<ol>
<li><code>generateSession</code> does NOT validate the API key — only client credentials. Dead/legacy keys still "log in" fine and only fail on data endpoints. The dashboard is the only source of truth for keys.</li>
<li>The portal migration deleted legacy apps but did NOT release their static-IP registrations. Old IPs stay orphaned inside dead apps.</li>
<li>One static IP maps to one client (UCC) — and CGNAT addresses (e.g. Jio mobile ranges) may already be claimed by another user entirely.</li>
</ol>
<p dir="auto"><strong>Fix path:</strong></p>
<ol>
<li>Don't reuse keys from old emails — legacy keys are dead post-migration even though login "works".</li>
<li>Create a fresh app on the new portal. If your IP is "already associated", register a static IP you actually control that has never been registered anywhere (e.g. a fresh cloud elastic IP). The mapped IP can be updated once per calendar week later.</li>
<li>Static IP is enforced for ORDER placement only (from 01-Apr-2026). Login/candles/LTP don't check origin IP, so data pipelines and paper trading work from anywhere.</li>
<li>Write to support to purge legacy apps and release orphaned IPs.</li>
<li>Gotcha #1: the Python SDK's error logger prints your X-PrivateKey (API key) into logs on failed requests — scrub logs before sharing them anywhere (and never commit a logs/ folder).</li>
<li>Gotcha #2: NSE Saturday DR-drill sessions return MOCK candles at ~10% off real prices through getCandleData as if real. Filter weekend bars deviating &gt;3% from the prior close (genuine Muhurat/Budget sessions survive that rule).</li>
</ol>
<p dir="auto">Working reference implementation (rate-limited wrapper, fetchers with the mock-session guard, honest walk-forward research pipeline): <a href="https://github.com/saif859/smartapi-algo" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/saif859/smartapi-algo</a></p>
<p dir="auto">Happy to answer questions. I do broker-API integration work professionally — DM if you're stuck beyond what a forum post can fix.</p>
]]></description><link>https://smartapi.angelone.in/smartapi/forum/topic/5635/complete-fix-ag8004-invalid-api-key-after-successful-login-primary-static-ip-is-already-associated-with-another-app</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 06:12:44 GMT</lastBuildDate><atom:link href="https://smartapi.angelone.in/smartapi/forum/topic/5635.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Aug 2026 10:32:14 GMT</pubDate><ttl>60</ttl></channel></rss>