[api] fix crash when operating on not existing token