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 multiple records, returning a list of DeleteResult objects. You can choose to roll back the entire request when an error occurs.

Request Syntax

DELETE /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.
ids Required. A list of 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    "id": "001RM000003oCprYAE",
5    "success": true,
6    "errors": [
7      
8    ]
9  },
10  {
11    "success": false,
12    "errors": [
13      {
14        "statusCode": "MALFORMED_ID",
15        "message": "Duplicate Fullname",
16        "fields": [
17          "Id"
18        ]
19      }
20    ]
21  }
22]
This example shows a response when some items caused errors and allOrNone is true.
1HTTP/1.1 200 OK
2[
3  {
4    "id" : "001RM000003oCprYAE",
5    "success" : false,
6    "errors" : [
7      {
8        "statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
9        "message" : "Record rolled back because not all records were valid and the request was using AllOrNone header",
10        "fields" : [ ]
11      }
12    ]
13  },
14  {
15    "success" : false,
16    "errors" : [
17      {
18        "statusCode" : "MALFORMED_ID",
19        "message" : "Duplicate Fullname",
20        "fields" : [
21          "Id"
22        ]
23      }
24    ]
25  }
26]