SmartAPI cancelOrder API fails with AB2001 for STOPLOSS_LIMIT orders (Manual Cancel Works)


  • Hi Team,

    I’ve encountered a serious issue with the SmartAPI cancelOrder API, which fails to cancel pending STOPLOSS_LIMIT orders, even though the same orders can be cancelled manually from the Angel One app or web platform. Mainly during after market hours

    Problem Description:
    When I attempt to cancel a STOPLOSS_LIMIT order using:

    cancelOrder(orderid='XX', variety='STOPLOSS')
    

    I consistently receive this error response:

    {
      Response: {'message': 'Internal Error', 'errorcode': 'AB2001', 'status': False, 'data': None}
    }
    

    I also tried fallback varieties 'NORMAL' and 'AMO', but the result is the same.

    Things I’ve Verified:

    • orderstatus is 'open'
    • ordertype is 'STOPLOSS_LIMIT'
    • variety is 'STOPLOSS' (as returned from orderBook())
    • I’m using the correct orderid
    • Manual cancel via Angel One web/app works perfectly
    • Tried multiple orders, same result

    Sample Order Details:

    {
      "orderid": "XXXXX",
      "variety": "STOPLOSS",
      "ordertype": "STOPLOSS_LIMIT",
      "orderstatus": "open",
      "tradingsymbol": "NIFTY03JUL2526000CE",
      "producttype": "CARRYFORWARD"
    }
    

    Expected Behavior:
    The API should cancel the order just like the app or terminal does.

    Actual Behavior:

    • cancelOrder() returns AB2001 Internal Error
    • Order remains open
    • Can be cancelled only manually (which defeats the purpose of automation)

    Suggested Fix:
    Please investigate and resolve the internal mismatch that’s causing cancelOrder() to fail.

    Request:
    Kindly escalate this issue to the backend/API team. It affects automated risk management in live markets, where SLs must be cancellable in real-time.

    Thank you,
    Ranga