Newer Version Available

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

Create Multiple Records with Fewer Round-Trips

Use a POST request with sObject Collections to add multiple 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/tooling/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 for FlexiPage can contain up to 200 objects. As support is added for other Tooling API objects, the maximum number of objects c be different for each.
  • 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.
  • Although SObject Collections is also supported in SOAP API, you can’t use SOAP API objects in a Tooling API SObject Collections call.

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 Body Example

Response Body Examples

This example shows a response when all the items were processed successfully.
This example shows a response when some items caused errors and allOrNone is false.
This example shows a response when some items caused errors and allOrNone is true.