Salesforce Composite REST API is an innovative feature that enables executing multiple API requests with a single call. This feature allows users to perform various operations in a single callout, such as read, create, update, and delete Salesforce data. Additionally, the output of one request can serve as an input to the subsequent request. A remarkable advantage of Composite API is that all the requests specified are bundled and processed as one call, reducing the number of API requests and being friendly towards API limits. Users can leverage Anypoint Connector for Salesforce Composite (Salesforce Composite Connector) to smoothly integrate with Salesforce Composite API.

MuleSoft’s Salesforce Composite Connector streamlines code, lowers network overhead, and boosts the app performance by using a single REST API call to access multiple distinct Salesforce services. The connection offers flexible access to Salesforce’s composite resources to perform extensive data operations on Salesforce data. Before being imported into Salesforce, each record is first represented as a sObject. The records obtained from Salesforce are similarly saved in a sObject variable.

Features of Salesforce Composite Connector

Complex object interactions that would often need many requests to Salesforce when utilizing real-time APIs can be carried out using the Salesforce Composite Connector included within the Salesforce REST API. In specific circumstances, this connector can streamline workflows, lower the volume of API calls to SFDC, and speed up processing. The Salesforce Composite Connector includes the following operations:

  • Batch: A batch may carry out up to 25 distinct, unconnected actions in a single call. Each call runs independently, and no data is passed between them.
  • sObject Tree: sObject trees are created with root records of the specified type in one or more instances. A sObject tree is a group of nested parent-child records with a single root record.
  • sObject Collections: The sObject collection resource, which works similarly to batch, can reduce round trip calls on collections of objects (up to 200), but it necessitates a common operation (such as creating, updating, retrieving, or deleting a collection of records). In case of a partial failure, this call includes the ability to specify a rollback behavior.
  • Composite: In a single call, this will consecutively carry out a number of operations. One action’s response can be included in another action’s input.

Use Case

For example, let’s see how the customer-onboarding scenario works, wherein a customer has to fill out the onboarding form with this data. Primarily, the Account and Contact objects have to be created in Salesforce.

In a conventional method, two API callouts are required to create an Account and Contact using only the Salesforce Rest API . However, utilizing the Salesforce composite REST API can accomplish both tasks in a single call. Moreover, the Salesforce composite REST API allows all Rest API series to be counted as a singular call towards API limits. This approach significantly reduces API usage, a crucial factor when operating within the Salesforce platform due to the governor limitations on resource consumption.

sObject Tree Using the Salesforce Composite Connector

One or more sObject trees with a root record of the chosen type are created by the sObject tree Salesforce. It is a group of parent-child records that are nested within one another. There are only 200 records allowed in total across all trees; five records of a different kind are allowed, and the sObject tree Salesforce can only go as deep as five levels.

  • Conducts operations on numerous records in a single request.
  • Lessens the quantity of data sent back and forth between the client and server.
  • A single response body contains both the HTTP statuses of the responses and the response bodies.
  • The entire request counts as a single call toward API limits.
  • Determines if the entire request needs to be rolled back in case of an error.
  • Creates objects in the order they’re listed.
  • If the request body includes objects of more than one type, they are processed in chunks. For instance, if {account1, account2, contact1, account3} are the incoming objects, the request is processed in three chunks; a single request can process up to 10 chunks.

Steps to Configure Salesforce Composite Connector

  1. Add Salesforce Composite Connector from the exchange.

2. Here, we are using “Create sObject tree” connector for understanding. Below is the configuration for sObject tree Salesforce connector :

3. Define the consumer key and secret and create a connected app in Salesforce.

  • Go to Setup -> Build -> Create -> Apps -> Create New Connected App.
  • Enter all the required information.
  • Enable OAuth Settings, enter the call-back URL (if needed), and select Full Access Scope.
  • Save the App.
  • Click on Manage and set Permitted Users as ‘All users may self-authorize’ and IP Relaxation as ‘Relax IP restrictions.’
  • Now get the Consumer ID and Secret from the custom app.
  • Use this same key and secret in the Salesforce Composite Connector Configuration.

4. Set the username and password to the username and password of the Salesforce Org where the app is created.

5. Now go back to Anypoint Studio and create a basic flow using the Execute Composite Request connector:

6. It is recommended to conduct a test on this operation using Postman. Upon running the application, the resulting output will include the Salesforce IDs of the newly generated accounts and contacts.

Testing in Postman

  1. Open Postman.

2. Copy and paste the below request body in the body tab and click send.

3. A typical response looks as depicted above.

4. The response as Account and Contact are created successfully.

Advantages of the Composite Connector over the Salesforce Composite Connector

  1. Multiple REST API calls for a single call. Good practices to reduce API usage.
  2. Ability to finish a procedure in a single call, similar to how we must finish several linked activities in a single call.
  3. Can easily handle parent-child relationship operation.
  4. Can handle more complicated and related objects and data structures.
  5. Appropriate in all or none process circumstances. For example, if we insert an account and all of its child contact records using solely the Rest API, but contact creation fails due to an error, we are unable to roll back the account record. In a Salesforce Composite Rest API, it is simple to administer.


The Salesforce Composite Connector from MuleSoft can simplify code and reduce the processing time by reducing the number of calls to SFDC. Using the Connector, multiple records can be created and updated with a single request, reducing network overhead and improving app performance. To leverage features of MuleSoft for seamless developer experience, engage with a reliable MuleSoft Integration Services provider like Nous Infosystems.

Manuel George Abraham
Technical Architect, GSS, Enterprise Integration

Ready to get started?

Contact us Close