Site icon SFMC Geeks

Create Data Extensions in Marketing Cloud via API

LEGO Nerds

Much of the magic of Marketing Cloud relies on invisible data extensions called Data Views. These are data extensions that house the data of sends, opens, clicks, subscribers, journeys, etc. However, they are not immediately visible to the user. There are ways to extract this data using reports or data extracts. You can also leverage this data by using the build-in Einstein features, like Einstein Send Time Optimization and Einstein Engagement splits in Journey Builder.

However, there are other times that you might want to pull from this data without generating reports or writing one-off SQL queries. For example, you might want to use a suppression data extension in a Salesforce Send where you exclude anyone who has already opened an email on the day of the send. Or there is this example written by Emily where you pass Bounce data back to Sales Cloud via Journey Builder with information from the Bounce Data View. Here’s an overview of Journey Builder Data written by Nathalie.

While the Data Views are not visible, Salesforce does document all the Data Views and their fields so you can replicate them yourself. However, creating Data Extensions that replicate the Data Views can be quite tedious. So, here is a GitHub repository with the SOAP API for almost every Data View. As of this writing, I still have a few to build. They are not ones I have yet to use, so I have not gotten to them yet (but I will).

And here is the easiest way to create Data Extensions on the fly:

First, if you do not have Postman, download it now.

Second, create an API package in Marketing Cloud.

{{AuthenticationBaseURI}}/v2/token
Content-Type: application/json
{
"grant_type": "client_credentials",
"client_id": "{{ClientId}}",
"client_secret": "{{ClientSecret}}"
}
var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("accessToken", data.access_token);
{{SOAPBaseURI}}/Service.asmx
Authorization: Bearer {{accessToken}}
SoapAction: Create
Content-Type: text/xml
SELECT *
FROM _bounce
SELECT * 
FROM _bounce
WHERE EventDate BETWEEN GETDATE()-7 AND GETDATE() 
Exit mobile version