Well, of course, it depends on a country, state, region, but mostly hidden cams are kinda illegal. If you want to track your kids or workers then yeah, using spy apps is legal. Read here to get more information on this topic
http://cellphonetrackapp.net/tag/spy-phone-app/