Newer Version Available
Create Multiple Records with Fewer Round-Trips
Use a POST request with sObject Collections to add up to 200 records, returning a list
of SaveResult objects. You can choose whether to roll back the entire request when an error
occurs.
Request Syntax
POST /vXX.X/composite/sobjects
Parameters
| Parameter | Description |
|---|---|
| allOrNone | Optional. Indicates whether to roll back the entire request when the creation of any object fails (true) or to continue with the independent creation of other objects in the request. The default is false. |
| records | Required. A list of sObjects. In a POST request using sObject Collections, set the type attribute for each object, but don’t set the id field for any object. |
Usage Guidelines
- The list can contain up to 200 objects.
- The list can contain objects of different types, including custom objects.
- Each object must contain an attributes map. The map must contain a value for type.
- Objects are created in the order they’re listed. The SaveResult objects are returned in the order in which the create requests were specified.
- If the request body includes objects of more than one type, they are processed as chunks. For example, if the incoming objects are {account1, account2, contact1, account3}, the request is processed in three chunks: {{account1, account2}, {contact1}, {account3}}. A single request can process up to 10 chunks.
- A single request can process up to 10 chunks.
- You can’t create records for multiple object types in one call when one of the types is related to a feature in the Salesforce Setup area.
Request Body Example
1POST /composite/sobjects
2{
3 "allOrNone" : false,
4 "records" : [{
5 "attributes" : {"type" : "Account"},
6 "Name" : "example.com",
7 "BillingCity" : "San Francisco"
8 }, {
9 "attributes" : {"type" : "Contact"},
10 "LastName" : "Johnson",
11 "FirstName" : "Erica"
12 }]
13}Response Body Example
1[
2 {
3 "success": false,
4 "errors": [
5 {
6 "fields": [],
7 "message": "There was an error creating this object.",
8 "statusCode": "DUPLICATES_DETECTED"
9 }
10 ],
11 "warnings": []
12 },
13 {
14 "success": true,
15 "id": "003xx000004TmiQAAS",
16 "errors": [],
17 "warnings": []
18 }
19]