Newer Version Available

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

sObject Tree

Creates one or more sObject trees with root records of the specified type. An sObject tree is a collection of nested, parent-child records with a single root record.

In the request data, you supply the record hierarchies, required and optional field values, each record’s type, and a reference ID for each record. Objects are created in the same order that they’re listed in the request. Upon success, the response contains the IDs of the created records. If an error occurs while creating a record, the entire request fails. In this case, the response contains only the reference ID of the record that caused the error and the error information. The response bodies and HTTP statuses of the requests are returned in a single response body. The entire request counts as a single call toward your API limits.

The request can contain the following:
  • Up to a total of 200 records across all trees
  • Up to five records of different types
  • sObject trees up to five levels deep

Because an sObject tree can contain a single record, you can use this resource to create up to 200 unrelated records of the same type.

When the request is processed and records are created, triggers, processes, and workflow rules fire separately for each of the following groups of records.
  • Root records across all sObject trees in the request
  • All second-level records of the same type—for example, second-level Contacts across all sObject trees in the request
  • All third-level records of the same type
  • All fourth-level records of the same type
  • All fifth-level records of the same type

Syntax

URI
/services/data/vXX.X/composite/tree/sObjectName
Formats
JSON, XML
HTTP method
POST
Authentication
Authorization: Bearer token
Parameters
None required
Request body
sObject Tree Request Body
Response body
sObject Tree Response Body

Example