Business Insights Development Featured Post Development News & Insights

A Mulesoft 4 Story – Connecting to Salesforce Marketing Cloud

Salesforce Marketing Cloud (SFMC)

Salesforce Marketing Cloud (SFMC) is predicted to be one of the most in-demand products from customers using Salesforce. The principal reason behind this choice is because businesses now understand the value of marketing to a customer on their preferred channel, whether that’s social media, on-site advertising, or email marketing.

Historically, businesses have always struggled to quantify the success of marketing efforts, particularly on a granular level. To achieve a complete view of the customer, businesses need to be able to track each customer interaction with the marketing content, and then decide on what works and what doesn’t.

MuleSoft makes it possible to pull this data together. It is now possible to track customer reactions to marketing through direct and indirect mentions, sentiment analysis on social media and their browsing habits on the organization website or app. All of this can then be used to create personalized messaging, and to continually adjust a customer’s journey in real time, based on their actual and predicted behavior throughout the sales process. MuleSoft can be used to set up triggers on third-party platforms. Once a certain criteria is met, customers will automatically be marketed in a certain way, using all available information to identify the most effective method.

This article explains how Mulesoft connects to SFMC to realize this potential.

SFMC offers REST and SOAP APIs that expose their internal entities to the outside world. To derive these SOAP and REST API endpoints, SFMC’s system-generated subdomain URL for the top-level enterprise account (=tenant) is needed. Hence, to make use of the APIs, this feature needs to be enabled for the concerned account.

Step 1. To do this, in SFMC Admin, view install ‘packages’ component as API integration type which in turn can be installed as the following integration types with relevant authorization (read/write) to access various entities:

  • Server to server with client credentials grant type
  • Web App Integrations with authorization code grant type
  • Public App Integrations with authorization code grant type (the difference being it can’t securely store a client secret)

Let us consider the “Server-to-Server integration” type. The tenant’s SOAP, REST, authentication base URIs and credentials can be obtained as shown above. This data can now be used in Mulesoft’s SOAP-based connector, web service consumer (SOAP API), or HTTP(S) requestor (REST API) to connect to SFMC. Please note that not all operations are defined completely by either of the APIs and hence, a combination of these 2 APIs might be needed to satisfy business goals based on the best approach.

Business scenario:

Our source can be an eCommerce website such as Shopify, which has consumer data like name, email, phone numbers, etc. This data needs to be synced with SFMC’s DataExtension routed via Mulesoft in real-time for developing better and targeted marketing content.

Here, we will look at an example of creating/updating a DataExtensionObject in SFMC. In simple terms, a DataExtension is a table that contains subscriber data which can be used as a source to run queries on, pull information, and send marketing promotions to a subset of subscribers in the Marketing Cloud. DataExtensionObject represents an object/row within this table.

Let us assume that we have a DataExtension for customers (Ecomm-Customers) created under EMAIL -> Subscribers -> DataExtensions -> Ecomm-Customers

Note: Hardcoded values have been added for convenience in the examples below and should be read as expressions from variables or externalized properties file.

Step 2. Using MuleSoft HTTP(S) request connector (REST API)

SFMC REST APIs provide broader access and supports newer Marketing Cloud technologies and capabilities. REST calls are synchronous by nature with timeout feature and supports a maximum payload of 4 megabytes. It is lighter with less overhead as compared to SOAP API calls and uses JSON for request and response. REST API can be divided into following broad functional classifications: Content Builder API, Event Notification Service API, Journey Builder API, GroupConnect Chat Messaging API, MobileConnect API, Einstein Recommendations API and Transactional Messaging API.

SFMC REST API provides methods to insert and update data into DataExtensions and endpoints that can be accessed from Mulesoft using HTTP Requestor.

The connection configuration for HTTP requestor would be as follows:

Note: To enable authentication as ‘Client credentials grant type’ in the dropdown above, enter the following as dependency in pom file


Next, the payload that flows from source (e.g. Shopify) has to be transformed into a specific JSON format. For REST API, create/update request data format will be as:

Once the mule project is up and running and a customer is created or modified in Shopify, a webhook for the customer create/update process will trigger the mule flow. An API led approach of Mulesoft will ensure that the experience layer captures the webhook and its payload, pass the information to the process API, which has the added ability to process, analyze and transform the information. The system API is then invoked to connect, and based on authentication token, will place a request to create or update the object in SFMC. The user can then log into SFMC and verify the values inserted or updated in real time.

Though REST API supports broader capabilities of Marketing Cloud, it does not have a resource endpoint that supports the DELETE feature of the above-created customer in SFMC. For this, SOAP API can be used as illustrated in Step 3.

Step 3. Using Mulesoft web service consumer connector (SOAP API)

Using the same business scenario described above, we can connect to SOAP API to delete the created DataExtension object. SOAP API is built on web service standards with an emphasis on security and reliability. Some of the comprehensive tasks supported by SOAP API are sending emails to a subscriber list or data extension, performing crud operation on an object, triggering email send and many more and these calls can be made synchronously or asynchronously depending on the requirement. To invoke SOAP API – authenticate API calls and use the right WSDL links and endpoints specific to your tenant.

e.g. All instances WSDL links: 
All instances endpoints:

The first step is to obtain an auth token that is to be sent as part of the header element of SOAP calls. There are many ways of doing this and here we will see the use of REST API services offered by SFMC to retrieve the token using client credentials of the subdomain.

A typical scenario would be to delete the customer in Shopify; a webhook for delete will be triggered that would be captured by Experience API of Mulesoft, which then invokes Process API where we can have dataweave XML transformation of the request body. Then, the System API will invoke Auth and SOAP APIs of SFMC. We can now verify that the customer has been deleted from the SFMC data extension.

Step 4. Using Mulesoft SOAP-based connector

Mulesoft 4 has pre-built SOAP based Salesforce Marketing Cloud Connector (v3.0) which enables us to easily connect to and perform operations on Marketing Cloud via its API. Some of the operations that can be done are illustrated below.

Let us consider the same scenario as above and delete a customer data extension object.

This MuleSoft connector is easy to use and can address a range of capabilities offered by the Marketing Cloud API. At this point though, SFMC connector configuration does not support expressions as shown above, where there might be a need to read URLs, client id/secret, etc. from variables. Future upgrades to the MuleSoft connector may address this, which would provide a wholesome solution to our technical needs.

In conclusion, the integration of MuleSoft with SFMC can only revolutionize and bring about a positive change to the digital marketing world. This domino effect would enable targeted campaigning, that would lead to increased and effective sales and revenues. To reiterate, Mulesoft will help in simplifying the integration process of marketing cloud with multiple source systems and maximizing their purpose, use and effectiveness.

Documentation on the connector can be referenced at:

Salesforce marketing cloud APIs documentation can be referenced at:

Incepta is a certified MuleSoft partner with an experienced team of MuleSoft certified experts in MuleSoft development and consulting. Visit our website: www.inceptasolutions.com or email us at hello@inceptasolutions.com