Salesforce Composite Connector in Mule 4

DZone 's Guide to

Salesforce Composite Connector in Mule 4

In this article, take a look at the Salesforce Composite Connector in Mule.

· Integration Zone ·
Free Resource

1. Introduction: Salesforce’s REST API Composite Resource

Salesforce Composite Connector from MuleSoft uses a single REST API call to access several individual Salesforce services, thereby simplifying your code, reducing network overhead, and improving your app’s performance. The connector provides convenient access to Salesforce's composite resources to execute large-scale data operations on Salesforce data.

2. Why Use Salesforce’s REST API Composite Connector?

  • Enables a user to execute dependent requests in a single API call. For example, use the connector to invoke a single composite resource that creates an account and retrieves its information to use it to create a contact.
  • Offers the ability to create a collection of nested parent-child records.
  • Allows you to create and update multiple records in a single request.

3. How to Use

Salesforce Composite Connector will not be available in the Mule palette initially. To get these connectors, search in the Mule palette exchange.    

In this document, we are using “Create sObject tree” connector for understanding.

Below is the configuration for sObject tree connector:

  • Consumer Key and Consumer secret:

For Consumer key and secret, we need to create a connected app in Salesforce.

Go to Setup -> Build -> Create -> Apps -> Create new in Connected apps

Populate all the required basic information:

 Enable OAuth setting:

Save the app.

Click on Manage and set Permitted Users as All users may self-authorize, 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:

  • Username and Password:

This should be set to the username and password of Salesforce Org where the app is created.

Get back to Anypoint Studio and create a basic flow using the sObject tree connector:

Set payload with sObject tree:


When you run the application, in response, you will get the Salesforce IDs of newly created accounts and contacts.

4.Benefits of Salesforce Composite Connectors:

The Salesforce Composite resources within Salesforce’s REST API can be used to perform complex object interactions that would normally require multiple calls to Salesforce using the real-time API. In certain scenarios, this connector can simplify your flows, reduce the number of API calls to SFDC, and shorten processing time.   

The operations the Composite resources are:

  1. Batch: Batch allows up to 25 separate unrelated actions to be executed in a single call. Each executes independently, and information is not shared between the calls.
  2. 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.
  3. SObject Collections: Similar to batch, the SObject Collection resource can reduce round trip calls on groups of objects (up to 200) but requires a common action (e.g. Create, Update, Retrieve, or Delete a group of records). This call has the option to specify a rollback behavior in the case of partial failure.
  4. Composite: This will sequentially execute a series of actions in a single call. The response from one action can be used as an input in the subsequent action.
instant biometric integration, mule 4, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}