Added validation for api calls.