top of page

How to Create a Contact in Marketing Cloud Using REST API

Updated: Nov 3, 2024


Matrix code

Looking to streamline your contact management in Salesforce Marketing Cloud using the REST API Marketing Cloud? In this step-by-step guide, we'll show you how to create a contact using the REST API with ease, making your processes more efficient and automated. Whether you're an admin, developer, or marketer, this guide will help you get the job done quickly, with code examples and actionable insights.

By the end of this post, you'll know how to:

  • Set up your REST API endpoint for contact creation.

  • Craft the necessary JSON request with customizable parameters.

  • Send your API request and verify contact creation in Salesforce Marketing Cloud.

Let’s dive in and make contact management simpler for you.



Step 1: Set Up Your REST API Endpoint

To get started, you’ll need to gather your REST Base URI from Salesforce Marketing Cloud. Once you have it, build your endpoint by appending /contacts/v1/contacts to it. This is the URL you’ll use to send the request for creating a new contact.

Why this matters: Setting up the endpoint correctly ensures your API request is sent to the right place in Marketing Cloud, making it the foundation for success when working with the REST API Marketing Cloud.


Set Up REST API Endpoint

Step 2: Prepare Your JSON Parameters

Next, we need to define the contact's details using JSON. This structured format will carry the necessary data, such as email addresses or other attributes, into Marketing Cloud.

Key JSON Parameters:

  • contactKey: The unique identifier for your contact, often their email address.

  • attributeSets: An array containing the contact’s information.

    • attributeSets.name: Defines the data group for storing contact information (e.g., "Email Addresses").

    • attributeSets.values: Key-value pairs representing the contact’s data, such as email and HTML preferences.

Sample JSON Code:

{
    "contactKey": "example@deshive.com",
    "attributeSets": 
        [{
            "name": "Email Addresses",
            "items": 
                [{
                    "values": 
                        [{
                            "name": "Email Address",
                            "value": "example@deshive.com"
                        },
                        {
                            "name": "HTML Enabled",
                            "value": true
                        }]
                }]
        }]
}

Pro Tip: You can easily modify the contactKey and attributeSets.values to match the data you want to input. This makes the process scalable and customizable for any use case.

Prepare JSON Parameters

Step 3: Send the API Request

Now that your JSON is ready, it’s time to send the request using tools like Postman or your preferred API testing platform. If everything is set up correctly, you should receive a response confirming the successful creation of the contact in Salesforce Marketing Cloud.

Why it’s important: Sending the API request successfully is crucial for automating workflows and integrating your systems with Salesforce Marketing Cloud.


Send the API Request

Step 4: Verify the Contact in Marketing Cloud

Once your contact is created, log into Marketing Cloud and navigate to the All Contacts section. Search for the newly created contact by their email address or contact key. Here, you can verify the data fields that were included in the API request.

What you’ll see:

The contact’s information, such as their email address and whether they have HTML emails enabled, will be visible as per the values provided in the JSON request.


Go to Contact Builder

Search

Step 5: Review Your Contact Data

At this point, you can open the contact profile and review all the details you added via the API, ensuring the values are accurate and reflecting what was sent in the request. This is your chance to double-check that everything is working as expected.






Why Use the REST API for Marketing Cloud?

Automating your contact creation process with the REST API Marketing Cloud comes with several benefits:

  • Efficiency: Save time by automating repetitive tasks, such as adding contacts in bulk.

  • Scalability: Easily adapt your API requests to create multiple contacts or update large datasets.

  • Data Accuracy: Ensure your data is consistently formatted and up-to-date by reducing the manual input that can lead to errors.

By leveraging the REST API, you're also opening the door to a range of other Marketing Cloud capabilities, from automating journeys to managing customer preferences in real-time. This not only makes your workflows faster but also more robust and scalable.



Wrapping Up

You've now successfully created a contact in Salesforce Marketing Cloud using the REST API Marketing Cloud. This method allows you to automate contact management and integrate your systems more seamlessly. Whether you're looking to improve efficiency or scale your operations, the REST API can help you do just that.


What’s next?

Now that you know how to create contacts, explore other possibilities with the REST API. From managing lists to automating journey entries, the potential is limitless. Be sure to bookmark this post and share it with your team to maximize your use of Marketing Cloud.

If this guide was helpful, drop a comment below or share it with your network! Let us know how you plan to use the REST API in your Marketing Cloud strategy.





Join the conversation!

  • What other Marketing Cloud features would you like to automate using the REST API?

  • Have questions? Leave them in the comments, and we’ll get back to you with answers.

  • Share this guide with others who might benefit from automating their contact management!

Comments


© 2024 DESHIVE

bottom of page