Subject: Sandbox API - Persistent 401 Unauthorized Error (UDAPI100050)

Hello Upstox Support Team,

I am encountering a persistent authentication issue with the Sandbox API environment.

Details:

  • API Key: af0ab2a6-a8d4-4984-a24a-cdf5eb057d2c

  • Environment: Sandbox

  • Error Code: UDAPI100050

  • Error Message: Invalid token used to access API

Problem Description:
All of my API calls to any authenticated endpoint are failing with a 401 Unauthorized error, even when using a freshly generated Sandbox access token from the developer dashboard.

Troubleshooting Steps Already Taken:

  1. I have revoked my old Sandbox token.

  2. I have generated a new Sandbox token multiple times.

  3. I have confirmed there are no copy-paste errors.

  4. I have tested the new token immediately after generation, and it fails instantly.

  5. I have isolated the issue using a minimal Python script, which proves the problem is not with my application’s logic.

Minimal Reproducible Example:
Here is the simple Python script (upstox-python-sdk v2) that consistently reproduces the error:

code Python

downloadcontent_copy

expand_less

    import upstox_client
from upstox_client.rest import ApiException
import logging

# This is the newly generated token that is failing.
SANDBOX_ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJrZXlfaWQiOiJza192MS4wIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiI3NjE0MzIiLCJqdGkiOiI2OGFkNTExMWEwMGZmNDE2NWFiMzUxNGEiLCJpc011bHRpQ2xpZW50IjpmYWxzZSwiaXNQbHVzUGxhbiI6dHJ1ZSwiaWF0IjoxNzU2MTg4OTQ1LCJpc3MiOiJ1ZGFwaS1nYXRld2F5LXNlcnZpY2UiLCJleHAiOjE3NTg3NTEyMDB9.eQN_rLb9P5Fvsre0Hj7vinf0RkxbyHRzEzdIUkfLYZc"

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def test_token():
    configuration = upstox_client.Configuration()
    configuration.access_token = SANDBOX_ACCESS_TOKEN
    
    try:
        api_client = upstox_client.ApiClient(configuration)
        user_api_instance = upstox_client.UserApi(api_client)
        api_response = user_api_instance.get_profile(api_version="v2")
        logging.info(f"API Response: {api_response.data}")

    except ApiException as e:
        logging.error("Authentication Failed.")
        logging.error(f"HTTP Status Code: {e.status}")
        logging.error(f"Response Body: {e.body}")

if __name__ == "__main__":
    test_token()
  

Full Error Log from the script:

code Code

downloadcontent_copy

expand_less

IGNORE_WHEN_COPYING_START

IGNORE_WHEN_COPYING_END

    (venv) PS C:\Users\human\OneDrive\Documents\FACTROID\FEDBKBOT> python .\test_auth.py
2025-08-26 12:27:36,156 - INFO - --- Starting Minimal Authentication Test ---
2025-08-26 12:27:36,547 - ERROR - --- ❌ FAILURE! Authentication Failed. ---
2025-08-26 12:27:36,547 - ERROR - Reason: Unauthorized
2025-08-26 12:27:36,547 - ERROR - HTTP Status Code: 401
2025-08-26 12:27:36,562 - ERROR - Response Body: b'{"status":"error","errors":[{"errorCode":"UDAPI100050","message":"Invalid token used to access API","propertyPath":null,"invalidValue":null,"error_code":"UDAPI100050","property_path":null,"invalid_value":null}]}'
  

Could you please investigate why my newly generated Sandbox tokens are being rejected as invalid? Please let me know if there is an issue with my application setup or my account.

Thank you for your assistance.

Best regards,

VIJAY

Hi @VIJAY_1675918, Sandbox mode enabled for limited APIs, please refer Sandbox documentation for the enabled APIs for Sandbox

Why you are giving vague replies, please reply on the issue only. Why can’t you are available on video call and fix this issue then and there by screen sharing option.

Please consider this as high priority and resolve this issue at earliest.

From the last 10 days, I am unable to login to Sandbox environment.

I have meticulously checked and inputted secret key, redirect uri and other details, but all are failed..

Please get it resolved.