How do I delete all records from a Salesforce object?

Question by malero

I screwed something up on my initial Salesforce import and need to start over. How do I delete all of the objects from my custom object?

Answers

  • I'm not aware of an API endpoint that allows you to delete all records from an object. You can send a DELETE request to the following endpoint to delete a single record. So you could loop through all of them and delete them one by one through the API.

    
    https://yourInstance.salesforce.com/services/data/v53.0/sobjects/YourObject__c/YourObjectID
    

    The easiest way to delete all records from a Salesforce object is to open the developer console. You can find the link to the developer console under the cog in the top right after you're logged in. After you're in the developer console, click on the debug option in the top left and click Open Execute Anonymous Window. You can then enter the following code to delete all of the records from your object.

    
    delete [Select id from YourObject__c];
    

    Answered by malero