fixed scope issue in api endpoint