How can i delete all the linked documents through api?

Basically i was trying to delete “Item” doc but some item were linked to some doc for ex: Stock entry and Bin, how can i delete the linked document of any type through api?