You don’t, if it’s on ABP, then you will need to reset the frame counters. If it’s on OTAA, then it will sort itself out.
There’s an API for that! But it is regularly formatted so can be parseable before JSON was invented - like wot I had to do as a child, working down the data mines for 25 hours a day …
It’s a bunch of 100 sensors which are picked up in the field, reenergized in the lab and afterwards reinstalled. It’s not necessarily the same sensor at the same place.
So what, the device is now in a different location, so update your database, at best, have a barcode on it. And if it’s got a different config of sensors on it, so what, update your database, at best, have some templates setup.
Regardless, there is no concept of reinstall, if you delete a device it has ramifications that are just far more easily resolved with a backend management system - after all, TTN doesn’t care what sensors are attached, it just passes on the payload, nor does it care where it is, to the extent that it doesn’t provide a way of saying what it’s location is, you can deal with that.