Use the Salesforce sObject Tree API to insert a parent record and multiple child records in one request
domain: developer.salesforce.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to developer.salesforce.com, checked against official docs, with linked verified routes.
Steps
Construct a POST request to /services/data/vXX.0/composite/tree/<SObjectType> with a records array
Each record in the array may contain a child records block using the relationship name to nest children
Assign a referenceId string to every record so the response maps successes and errors back to your payload
Submit the request; on success the response contains the new IDs keyed by referenceId
On partial failure the entire transaction is rolled back; inspect the hasErrors flag and the results array to identify which referenceId failed
Stay within the documented limit of records per call when nesting parent and child objects
Known gotchas
The entire tree insert is all-or-nothing; a single validation failure rolls back every record in the payload, unlike a standard batch upsert
You cannot mix different top-level sObject types in a single tree call; all root records must be the same type
Deeply nested trees (grandchildren) are supported but each level must use the correct child relationship name, not the object API name
Give your agent this knowledge — and 15,600+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?