Integrating my automation through your APIs

Subject:
Issue connecting to WebSocket feed (Error 401 Unauthorized)

Message:
Hello Upstox Support Team,

I’ve created an API app named “DeltaSmart_BOT” in my developer console and can successfully use the REST API (for example /option/chain and /market/quote).

However, when I try to connect to the WebSocket feed (wss://api.upstox.com/v2/feed) using my access token, the connection fails with the following error:

Error: Handshake status 401 Unauthorized

I’m using the latest token generated from the developer portal (the same one that works fine for REST requests).

Could you please confirm the following points:

  1. Is the access token generated via the Developer Dashboard → Generate Token valid for WebSocket authentication?

  2. If not, how can I generate a WebSocket-compatible token using OAuth2 (authorization code flow)?

  3. Are there any specific scopes or permissions required for real-time market data streaming?

  4. Is there a test or sandbox WebSocket feed I can use for development purposes?

Goal:
I want to subscribe to the NIFTY option chain via the live feed (instrument keys like NFO_OPTIDX_NIFTY24NOV25200CE and NFO_OPTIDX_NIFTY24NOV25200PE) for real-time LTP updates.

Thank you for clarifying the correct authentication process for the WebSocket connection.

Best regards,
Sudhakar
(Developer – DeltaSmart_BOT project)


:white_check_mark:

This error indicates that you are using an invalid access token. Please regenerate your access token and try again.

I also see that you are connecting to the deprecated endpoint wss://api.upstox.com/v2/feed. This endpoint has been discontinued — please switch to the v3 WebSocket feed:

For easier WebSocket integration, you can use the streamer utilities provided in our SDKs:

If you continue to see errors after regenerating the token and switching to the v3 feed, please share the request/connection logs and I’ll help debug further.

Thanks!