Salesforce Marketing Cloud API: A Newbie’s Guide

If you’re using Salesforce Marketing Cloud, chances are you’ve heard about the Salesforce Marketing Cloud API. For many marketers, the concept of an API may seem overwhelming, but in reality, it’s a powerful tool that allows you to unlock the full potential of your Marketing Cloud platform.

Coloured background with text Salesforce Marketing Cloud API: A Newbie's Guide

Whether you’re a developer or a marketer trying to maximise the functionality of Marketing Cloud, understanding the API can elevate your strategy and streamline your marketing processes.

To help you get there, I’ve put together this quick ‘newbie’s’ guide, explaining the technical bits and showing you how to make the most out of this powerful tool.

What is the Salesforce Marketing Cloud API?

First things first, an API, or Application Programming Interface, is essentially a bridge between two systems that allows them to communicate. 

The Salesforce Marketing Cloud API allows users to access various functionalities and data from their Marketing Cloud account, without needing to manually interact with the platform.

For businesses using Marketing Cloud, the API can be a game-changer, as it allows integration with other tools you might already be using, such as your website CMS, event management system, or social media networks, providing flexibility to extend the capabilities of your marketing activities.

When and why you need it

You might wonder why you should use the API when Marketing Cloud already has an intuitive user interface and so many native capabilities. Well, the API becomes indispensable when you need to:

  • Automate repetitive tasks like sending emails or updating customer data.

  • Integrate Marketing Cloud with other systems you’re already using, such as CRMs, data warehouses, or custom applications.

  • Pull custom reports and insights by fetching real-time data that you can visualise in your own dashboard.

  • Scale your marketing efforts without manual intervention.

For example, here’s a basic list of what’s possible with the right API setup:

  • Send personalised emails based on triggered events or specific customer data.

  • Manage contacts and subscriber lists automatically.

  • Retrieve tracking data to analyse the performance of email campaigns.

  • Create or update customer data across different sources.

  • Build dynamic content by pulling data from external systems to customise email content.

In short, if you’re looking for ways to increase efficiency, reduce manual effort, and enhance your marketing strategy through automation, the Salesforce Marketing Cloud API can help.

SOAP vs. REST API: Which is relevant?

Salesforce Marketing Cloud supports two types of APIs: SOAP and REST.

  • SOAP API: SOAP stands for Simple Object Access Protocol. It’s a protocol-based approach that uses XML for its messaging format. While it’s powerful and can handle complex operations, SOAP is often considered more rigid and requires more setup.

  • REST API: REST stands for Representational State Transfer. REST APIs use a simpler, more lightweight communication style, typically using JSON format for messages. It’s easier to use, especially for developers working on mobile apps or websites.

For those non-techie readers, if any of those terms sound overwhelming, don’t stress too much, you don’t need to understand everything about APIs to use one. You just need to know the basics, or who to turn to for development support (side note: MarCloud is a certified Salesforce Partner with experienced developers in-house, request a call if you want to handball your API integration work to an agile and expert team!).

Which API should you use in Marketing Cloud?

For most use cases within Salesforce Marketing Cloud, the REST API is the way to go. It’s faster, easier to implement, and more flexible for common marketing tasks like sending emails, managing contacts, or retrieving performance data. SOAP is still useful for more complex operations, but for day-to-day marketing automations, REST will likely suit your needs.

Usage limits

It’s important to note that Salesforce Marketing Cloud imposes certain limits on API usage. There are a few key limits to keep in mind:

  • Daily API call limit: This depends on your account setup but usually ranges between 2,500 and 1,000,000 calls per day.

  • Concurrency limits: Marketing Cloud allows a certain number of simultaneous requests, so be cautious when setting up automations or bulk updates.

  • Rate limiting: To prevent system overloads, Salesforce throttles API requests to ensure fair usage across customers.

You can find more detailed information on API limits in the Salesforce Marketing Cloud REST API documentation.

How to connect your API to Marketing Cloud

Connecting the Salesforce Marketing Cloud API may seem technical, but it can be broken down into manageable steps. Here’s a more granular guide on how to do it:

1. Create an API Integration in Marketing Cloud

  • Start by logging into your Salesforce Marketing Cloud account.

  • Go to Setup by clicking on your profile icon in the upper right corner.

  • In the left-hand menu, under the ‘Platform Tools’ section, select Apps and then Installed Packages.

  • Click New to create a package and give it a relevant name (e.g., ‘WordPress Integration’).

  • After creating the package, navigate to the Components section and click Add Component. Choose API Integration, and select the appropriate permissions for your use case (read/write, etc.).

2. Generate API keys (Client ID and Client Secret)

Once the API Integration is set up, you’ll need to generate the API keys, which include the Client ID and Client Secret. These are unique identifiers that allow your external application (e.g. WordPress) to communicate securely with Marketing Cloud.

  • After you add the API Integration component, the system will automatically generate the Client ID and Client Secret for you. Make sure to copy and store these securely as you’ll need them for authentication in the next step.

3. Authenticate your application

Now, you need to authenticate your application with Salesforce Marketing Cloud using the generated Client ID and Client Secret.

  • To do this, you’ll send a POST request to the Salesforce authentication endpoint. This can be done using tools like Postman or programmatically in your application.

  • The POST request should include your Client ID and Client Secret as well as grant-type information. The endpoint for authentication typically looks like this:

POST https://YOUR_SUBDOMAIN.auth.marketingcloudapis.com/v2/token

  • Include your credentials in the body of the request like so:

{

  "grant_type": "client_credentials",

  "client_id": "YOUR_CLIENT_ID",

  "client_secret": "YOUR_CLIENT_SECRET"

}

  • Upon successful authentication, you’ll receive an access token that is valid for a certain period (usually 20 minutes). You will use this token to authorise all future API requests.

4. Make API requests

With the access token in hand, you can now interact with Marketing Cloud via the API. Here is an example that will add data records (rows) to a specific Data Extension.

  • Use the access token in the header of each request to the relevant API endpoint. For example, if you’re trying to add a new contact to a list, your POST request might look like this:

HEADER (this is where you give information about your call):

Content-Type: application/json

Authorization: Bearer ACCESS TOKEN

POST https://YOUR_SUBDOMAIN}.rest.marketingcloudapis.com/hub/v1/dataeventsasync/key:DATAEXTENSION-EXTERNALKEY/rowset

[

    {

        "keys": {

            "SubscriberKey": "any unique key"

        },

        "values": {

            "IsActive": true,

            "FirstName": "John",

            "LastName": "Smith",

            "LastLogin": "2024-05-23T14:32:00Z",

            "FollowerCount": 2

        }

    },

{

        "keys": {

            "SubscriberKey": "another unique key"

        },

        "values": {

            "IsActive": true,

            "FirstName": "Joan",

            "LastName": "Smith",

            "LastLogin": "2023-04-21T14:32:00Z",

            "FollowerCount": 37

        }

    }

]

  • Replace YOUR_SUBDOMAIN with your unique Marketing Cloud subdomain, and include the necessary data for the specific action (e.g. sending an email, retrieving performance reports, or managing contact data).

  • Replace DATAEXTENSION-EXTERNALKEY with the external key of the Data Extension you wish to add data. This can be found by locating the Data Extension in the UI.

  • Create the json payload to deliver to Marketing Cloud. In the example we have here, we will be adding two records (John & Joan Smith). The values need to match fields in the target Data Extension. Just as in the UI, you should match the data type of each field, otherwise there will be an error.

Example: Connecting WordPress to your API

Let’s walk through an example of how someone might connect their WordPress website to Salesforce Marketing Cloud using the API for automating email marketing based on user interactions.

Step 1: Set up API integration in Marketing Cloud

First, in Marketing Cloud, a new API Integration is created, similar to the process outlined above. The API component allows WordPress to securely communicate with Marketing Cloud for automating actions such as sending newsletters to subscribers when they submit a form on the site.

Step 2: Generate API keys

Once the integration is ready, the WordPress administrator generates the necessary Client ID and Client Secret. These credentials are required to authenticate WordPress with Marketing Cloud.

Step 3: Authenticate in WordPress

On the WordPress side, a plugin like WP Fusion or a custom API integration can be used to handle the API requests. The admin enters the Client ID and Client Secret from Marketing Cloud into the plugin settings. The plugin then uses this information to send a POST request to Salesforce’s authentication endpoint and receives an access token.

Step 4: Automate API requests

Once authenticated, the plugin can send data from WordPress forms directly into Marketing Cloud. For example, when a user submits a subscription form on the WordPress site, the plugin triggers an API request to add the user as a contact in Marketing Cloud.

The POST request might look like this:

POST https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com/contacts/v1/contact

{

  "email": "user@example.com",

  "attributes": {

    "FirstName": "John",

    "LastName": "Smith"

  }

}

This automatically adds the new subscriber to a pre-defined list in Marketing Cloud, triggering a welcome email or adding them to a drip campaign.

With this integration in place, the WordPress site can now send real-time data to Salesforce Marketing Cloud, ensuring subscribers receive timely and personalised emails based on their activity on the site. This kind of automation streamlines the marketing process and ensures that no potential lead falls through the cracks.

Tailored API support from MarCloud

Navigating the Salesforce Marketing Cloud API can be daunting, especially if you’re not a developer. That’s where MarCloud comes in. As certified Salesforce Marketing Cloud consultants, we can help you integrate, optimise, and unlock the full power of the API to make your marketing more efficient and effective.

Need a hand with API integration or custom development? Request a call with us today for tailored support and expert guidance.

Anton Minnion headshot

Anton Minnion

A data scientist and engineer, Anton has extensive experience in successfully delivering martech and salestech solutions for a variety of clients, both big and small, and across 25 countries. With a scary amount of knowledge in the development space, his focus at MarCloud is on innovating technical solutions for clients but also creating brand new apps and products for Salesforce platforms, to solve common business challenges.

Featured resource

Cover with text AMPscript Code Snippets for Marketing Cloud

AMPscript Code Snippets for Marketing Cloud

Our genius MarCloud developers have combined the most commonly requested AMPscript code snippets into one document. Simply download, then copy and paste into your own account for fast solutions. Download the cheatsheet today and take your marketing to the next level.

Download AMPscript Code Snippet Cheatsheet

More recent posts

Desk Character Image

Need a hand getting the most out of your Pardot or Marketing Cloud account?

MarCloud is a team of certified Pardot, Marketing Cloud, and Salesforce specialists. We help businesses to unlock the potential of marketing automation. Ready to save time, deliver more quality leads, and generate more revenue? Here's how we help.

View support services