Create Multiple Records using rest API
Documentation
While the SObject Tree resource can be used to create nested records,
you can also create multiple, unrelated records of the same type. In a
single request, you can create up to two hundred records. In the
request data, you supply the required and optional field values for
each record, each record’s type, and a reference ID for each record,
and then use the POST method of the resource. The response body will
contain the IDs of the created records if the request is successful.
Otherwise, the response contains only the reference ID of the record
that caused the error and the error information.
We need to use below end point
/services/data/v34.0/composite/tree/Account/
And request body will be something like this
{
"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"
}]
}