Loading

Hard Delete records with REST bulk API

Veröffentlichungsdatum: May 1, 2026
Beschreibung

Use the Salesforce Bulk API to permanently delete records from Salesforce. The Bulk API is a RESTful API optimized for processing large data sets asynchronously.
When records are deleted using standard API calls, they are moved to the Recycle Bin. To permanently remove deleted records without waiting 15 days or manually emptying the Recycle Bin, you can use the Bulk API's hardDelete operation.

Lösung

Prerequisites:

Before performing a hard delete using the Bulk API, ensure the following:

  • The user profile has the Bulk API Hard Delete permission enabled, or a permission set with this permission has been assigned to the user. For more information on configuring the Bulk API Hard Delete permission, see this article. This permission enables the user to delete records in the Bulk API without storing them in the Recycle Bin.

By using following instructions you will be able to delete the records permanently using Workbench with REST Bulk API:

Step 1: Authenticate with Bulk API:

Use a REST Client like Postman or Workbench. Authentication works a bit differently in Bulk API. We need a valid session ID, which we’ll include in the X-SFDC-Session header with each of our Bulk API requests. We obtain a session ID using the SOAP API login() call.

Step 2: Create a Bulk API Job:

For the URI, replace the text in the URI text box with the following: /services/async/XX.0/job, where XX.0 corresponds to the API version you’re using

The request body must specify the operation as hardDelete, the Salesforce object type you want to delete (for example, Account), and the content type as JSON. The three required fields in the request body are: operation, object, and contentType. For the request body, copy and paste the following text. 

{
  "operation" : "hardDelete",
  "object" : "Account",
  "contentType" : "JSON"
}

Step 3: Add Batches to the Job:

Add Batches to the Job. Now we can hard delete account data via a batch. A batch is a set of records sent to the server in a POST request. The server processes each batch independently, not necessarily in the order it’s received. Replace the text in the URI text box with the following: /services/async/XX.0/job/jobID/batch. Replace jobID with the job ID you generated above.

Step 4: Monitor Job Status:

We’ve submitted our batches. Now it’s up to the server to process the request. We can monitor the server’s progress by checking the status of the job’s batches through the Salesforce UI. In Salesforce, from Setup, enter Bulk Data Load Jobs in the Quick Find box, then select Bulk Data Load Jobs.

Click on the JobId which we have created, you will get the status of your batches, if it failed you will see the error, if it completed you will see the same in status.

Step 5: Verify Deletion:

You can check now , records has been permanently deleted from the Salesforce you will not find those in Recycle bin.


Important Note About Workbench:

Workbench is a free, open-source, community-supported tool. It is not a Salesforce product, and Salesforce does not provide support for it. Workbench is referenced here for illustrative purposes only. Use it at your own discretion.

Nummer des Knowledge-Artikels

000382207

 
Laden
Salesforce Help | Article