Cancel doctype after save through api

Is there a way on how to cancel doctype after being saved through API. Let’s say I have apps in localhost:8000 and another in localhost:8001. I tried to create a doctype in 8001 through API in 8000. After getting response from 8001, I changed somethings in 8000 and it failed or getting error. the doctype is already being saved in 8001 but the transaction failed. Is there a way to cancel the doctype in 8001 automatically or should I cancel it though api too.

I see some frappe.db.rollback but I dont know if this would work nor how to use it properly.

Maybe you can do this:
A custom API method in 8001 that starts to create the document and then, before saving it, it calls another method in 8000. If the 8000 method does not finish properly, the method in 8001 does not save the document.

So, you have 2 api custom methods, one in each site. When you call the method in 8001 it will call back to the method in 8000 to check if everything is ok before saving the new document.