Fix undefined variable use in Api