Delete a document recovered in a Web Api in the folder of Appian but show it in the Response of the WebApi

I want to recover a document from a process and then show it through the web api but also delete it  from the Appian folder.

The problem is that when i delete from the folder the document, the local variable is empty and then it show me that error in the response:

Is there any way to retain the value of the document in the webpai variable but delete it in the folder of Appian no avoid generate so many documents in the folder???

Regards,

  Discussion posts and replies are publicly visible