added registration api and logic for handling errrors