function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kevin OcieKevin Ocie 

i want retrieve deleted records from salesforce using REST API?

I have loaded my Salesforce object data into Azure SQL. Now I want that one or multiple record in Salesforce get deleted then I can retrieve those records using REST API.
Is there any way to create REST API for those records for particular object?
Best Answer chosen by Kevin Ocie
AbhishekAbhishek (Salesforce Developers) 
"Yes, but".

By default SF soft deletes the records, they can still be seen in UI in Recycle Bin and undeleted from there. (There's also a hard delete call to skip the Recycle Bin).

Records stay in there for 15 days max. And bin's capacity depends on your org's data storage, see https://help.salesforce.com/articleView?id=home_delete.htm&type=5. So if you mass deleted a lot of data there's a chance the bin will overflow.

To retrieve these you need to call /queryAll instead of /query service. And filter by isDeleted column which doesn't show up in Setup but is on pretty much every object. See https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_queryall.htm

/services/data/v49.0/queryAll/?q=SELECT+Name+from+Account+WHERE+isDeleted+=+TRUE


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.