I have used REST in the past for creating/updating single record and used Bulk API to create records in bulk too. But there seems to be new way to creating multiple records using REST. Here is the article - https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm

Can someone post few help articles on how to get started? I have not used curl in the past, is there way to test this using PostMaster or WorkBench?


Let me make it simple. Suppose I have below REST resource in Salesforce, how can I call it to pass multiple contact records?


global with sharing class Mycontacts{

@HttpPost global static List doPost(List lstcnts){ insert lstcnts; return lstcnts; }


2 Answers 2


You can definitely use workbench to execute these

Use the below for the request


and in the body use the below JSON

"records" :[{
"attributes" : {"type" : "Account", "referenceId" : "ref1"},
"name" : "SampleAccount1",
"phone" : "1111111111",
"website" : "www.salesforce1.com",
"numberOfEmployees" : "100",
"industry" : "Banking"   
"attributes" : {"type" : "Account", "referenceId" : "ref2"},
"name" : "SampleAccount2",
"phone" : "2222222222",
"website" : "www.salesforce2.com",
"numberOfEmployees" : "250",
"industry" : "Banking"
"attributes" : {"type" : "Account", "referenceId" : "ref3"},
"name" : "SampleAccount3",
"phone" : "3333333333",
"website" : "www.salesforce3.com",
"numberOfEmployees" : "52000",
"industry" : "Banking"
 "attributes" : {"type" : "Account", "referenceId" : "ref4"},
 "name" : "SampleAccount4",
 "phone" : "4444444444",
 "website" : "www.salesforce4.com",
 "numberOfEmployees" : "2500",
 "industry" : "Banking"

You should see the response in workbench

Alternatively you can use POSTMAN to experiment with this API .

You will need to create a connected app in salesforce and use oauth 2.0 to get access token for subsequent calls

use the below link for reference

  • Thanks Mohith for the response. If I run “cs3.salesforce.com/services/data/v39.0/composite/tree/Account” in Postman, I get below error message { "message": "MediaType of 'application/x-www-form-urlencoded' is not supported by this resource", "errorCode": "UNSUPPORTED_MEDIA_TYPE" } What should be the “Content-Type” ? Jan 26, 2017 at 21:32
  • It was in 2013 at that time we did not have composite or tree API's Jan 26, 2017 at 21:34
  • Making some progress. I can insert the account. Couple of follow up questions - How to differentiate between insert, update, etc - How can I call custom REST resource? Jan 26, 2017 at 22:04
  • Try giving an Id and see what happens .I guess tree is only for inserts . Jan 26, 2017 at 22:20
  • Tried that, it complained. I think it is only for inserts. I also tried changing to "Patch" but only Post is supported. So back to the question. What is best way to pass json/csv file using REST, preferably custom REST? Seems simple, but only way I see so far is bulk API. Jan 26, 2017 at 22:33

As of API v42.2 you can now use the SObject Collections Composite endpoints. There are two major benefits over the existing composite tree & batch endpoints.

1: You can update up to 200 records at a time

2: The updates take place in a single execution context on salesforce. The other composite record create a context PER RECORD, which make it run incredibly slow for big updates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.