Newer Version Available

This content describes an older version of this product. View Latest

Delete Multiple Records with Fewer Round-Trips

Use a DELETE request with sObject Collections to delete up to 200 records, returning a list of DeleteResult objects. You can choose to roll back the entire request when an error occurs.

Request Syntax

DELETE /services/data/vXX.X/composite/sobjects?ids=recordId,recordId

Parameters

Parameter Description
allOrNone Optional. Indicates whether to roll back the entire request when the deletion of any object fails (true) or to continue with the independent deletion of other objects in the request. The default is false.

If the sObject Collections request is embedded in a Composite request, the Composite request’s allOrNone parameter can also affect the results. See allOrNone Parameters in Composite and Collections Requests.

Note

ids Required. A list of up to 200 IDs of objects to be deleted. The IDs can belong to different object types, including custom objects.

Usage Guidelines

  • The DeleteResult objects are returned in the order in which the IDs of the deleted objects were specified.
  • You can't delete records for multiple object types in one call when one of those types is related to a feature in the Salesforce Setup area.

Checking for Errors

  • If the request isn’t well formed, the API returns a 400 Bad Request HTTP Status. Fix the syntax of the request and try again.
  • If the request is well formed, the API returns a 200 OK HTTP Status. If an item was processed successfully, the success flag shows for that item. Error information is returned in the errors array.

Request Example

1DELETE /composite/sobjects?ids=001xx000003DGb2AAG,003xx000004TmiQAAS&allOrNone=false

Response Body Examples

This example shows a response when all the items were processed successfully.
1HTTP/1.1 200 OK
2
3[
4   {
5      "id" : "001RM000003oLrHYAU",
6      "success" : true,
7      "errors" : [ ]
8   },
9   {
10      "id" : "001RM000003oLraYAE",
11      "success" : true,
12      "errors" : [ ]
13   }
14]
This example shows a response when some items caused errors and allOrNone is false.
1HTTP/1.1 200 OK
2
3[
4   {
5      "id" : "001RM000003oLrfYAE",
6      "success" : true,
7      "errors" : [ ]
8   },
9   {
10      "success" : false,
11      "errors" : [
12         {
13            "statusCode" : "MALFORMED_ID",
14            "message" : "malformed id 001RM000003oLrB000",
15            "fields" : [ ]
16         }
17      ]
18   }
19]
This example shows a response when some items caused errors and allOrNone is true.
1HTTP/1.1 200 OK
2
3[
4   {
5      "id" : "001RM000003oLruYAE",
6      "success" : false,
7      "errors" : [
8         {
9            "statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
10            "message" : "Record rolled back because not all records were valid and the request was using AllOrNone header",
11            "fields" : [ ]
12         }
13      ]
14   },
15   {
16      "success" : false,
17      "errors" : [
18         {
19            "statusCode" : "MALFORMED_ID",
20            "message" : "malformed id 001RM000003oLrB000",
21            "fields" : [ ]
22         }
23      ]
24   }
25]