SmartAPI Token and WebSocket Session Lifecycle


  • Dear Angel One SmartAPI Support Team,

    I am integrating Angel One SmartAPI for a live market-data application using WebSocket 2.0.

    I have reviewed the SmartAPI documentation for Authentication, Generate Token, Logout, WebSocket 2.0, Exceptions, Instruments, Market Data and Rate Limits.

    Most of the integration flow is clear. However, I could not find definitive documentation for a few authentication and WebSocket lifecycle scenarios.

    Could you please clarify the following based on the current SmartAPI production behavior:

    Refresh Token Validity
    What is the exact validity/expiry period of the refresh token?
    Does it expire at the daily session boundary or have a different lifetime?
    Feed Token Validity
    What is the exact validity/expiry period of the feed token used for WebSocket 2.0?
    Does it expire together with the JWT or independently?
    Token Refresh / Rotation
    When generateTokens() is called using the refresh token, the response contains JWT, refresh token and feed token.

    Please confirm:

    Does the newly returned refresh token invalidate the previous refresh token?
    Does the newly returned feed token invalidate the previous feed token?
    Should the application always replace all three stored tokens with the newly returned values?
    Existing WebSocket After Token Refresh
    If generateTokens() returns a new feed token while a WebSocket 2.0 connection is already active:
    Can the existing WebSocket continue using the old authenticated session?
    Or must it be disconnected and reconnected using the new JWT/feed token?
    Token Expiry During Active WebSocket
    What happens if the JWT or feed token reaches its expiry/session boundary while the WebSocket is already connected?
    Is the connection immediately disconnected?
    Does it continue until network disconnection?
    Is an authentication/error message sent before closure?
    Logout / terminateSession
    When terminateSession(clientCode) is called, please confirm which credentials/resources are invalidated:
    JWT
    Refresh token
    Feed token
    Existing WebSocket connections
    Daily Authentication Expiry
    Current SmartAPI documentation indicates that the authentication/session token expires at 00:00 (midnight).

    Could you please confirm that 00:00 IST is the current production session/token expiry boundary and that this supersedes older SmartAPI guidance mentioning other session durations?

    Recovery After Expiry
    Please confirm the expected recovery action for:

    Expired JWT with a still-valid refresh token
    Expired refresh token
    Expired feed token
    Session expired (AB1010)
    WebSocket authentication failure (HTTP 401/403)
    Specifically, please indicate when generateTokens() should be used and when a complete login using Client Code + MPIN/PIN + TOTP is mandatory.

    This clarification will help us implement deterministic session renewal and WebSocket recovery without making assumptions about SmartAPI authentication behavior.

    If possible, please also share the latest official documentation/reference covering these lifecycle rules.