kodi has a function called clean library, it's used to remove any items from the library that have an invalid path. This includes files you've deleted, renamed, replaced, etc.
A common example is that sonarr will replace a lower quality episode with one of higher quality. If quality is part of your file naming schemes, the low quality episode is replaced with a high quality episode with a different file name. Sonarr sends an "update" to kodi, which basically just adds the new path as a duplicate entry.
Sonarr has an option to push the clean library command, which should remove the old entry. I've never had this enabled before as clean library wont work if a video is playing on the kodi instance that it's executed on. However, now with a dedicated headless instance I should be able to enable this feature and in theory it should work.
I was thinking that because the headless instance didn't have my shares mounted in the videos library (like my htpc) then it might not work. I have proven that notion false by wiping my kodi install/profile on my desktop and starting fresh. With a brand new kodi install, attached to the SQL DB, I can still preform a clean library operation. So in theory the headless instance should work for preforming a clean operation from either json api calls from sonarr or via the remote on the webui.
I'm fighting with the sonarr devs over the way they "update" the library. sickbeard used to modify the existing library entry's path when replacing or renaming and it's silly that sonarr isn't doing the same, but that's a whole other can o' worm