Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Delete Records Using sObject Collections
- 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.
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.
Syntax
URI: /services/data/vXX.X/composite/sobjects?ids=recordId,recordId
Formats: JSON, XML
HTTP Method: DELETE
Authentication: Authorization: Bearer token
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 up to 200 IDs of objects to be deleted. The IDs can belong to different object types, including custom objects. |
Note: 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.
Example
Example Request
1curl -X DELETE https://MyDomainName.my.salesforce.com/services/data/v67.0/composite/sobjects?ids=001xx000003DGb2AAG,003xx000004TmiQAAS&allOrNone=false -H "Authorization: Bearer token"Example Response Body
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]Example Response Body (Some Items Failed 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]Example Response Body (Some Items Failed 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]