Marketing Cloud is a B2C platform. It is a Marketing Automation and Analytic tool which delivers personalized customer engagement on every channel. It covers email, web, mobile, social, and advertising, and Marketing Cloud covers it all.
Salesforce Marketing Cloud allows most of the functionality available through API. All the possible things you can achieve through Marketing Cloud Platform can be achievable through the Marketing Cloud API. We can either use SOAP or REST API based on our requirements.
Follow the below three easy steps to get started with the world of Salesforce Marketing Cloud API.
- Identify Installed Package
- Request the Access Token
- Use Access Token to hit other API
Step 1: Identify Installed Package
The installed package provides Client ID, Client Secret, Authentication Base URI, and REST Base URI. To access the package detail page, from Setup, enter Installed Packages in the Quick Find box, select Installed Packages, and click the package’s name that you want to view.
Setup –> Quick Find (Enter Installed Package) –> Package Name
Check the below screenshot for more information. Create a newly installed package if you don’t find any existing installed package
Step 2: Request the Access Token
Append v2/token to the Authentication Base URI provided in the Installed Package. You need to submit a POST request to /v2/token route to get the Access Token. We can reuse the same access token for 20 minutes. Check the below screenshot for reference.
Replace the subdomain, clientId, clientSecrect, mid in the below screenshot with the installed package information from the previous step.
API URL = Authentication Base URL + ‘/V2/token’
Where Authentication URL = https://{{subdomain}}.auth.marketingcloudapis.com
Step 3: Use Access Token from the second step to hit other API
Use the access token from the second step to submit the request to another API. In the below screenshot, I have added the Authorization Header as Bearer with Access token.
Authorization: Bearer {{AccessToken}}
This will return all assets. We can filter the response by adding query params at the end of the API URL.
https://{{domain}}.rest.marketingcloudapis.com/asset/v2/content/assets?$page=1&$pagesize=10
References:
- Marketing Cloud API: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/apis-overview.html
- Get the Access Token: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/access-token-s2s.html#related-items
- Marketing Cloud API Series: https://www.youtube.com/watch?v=MmRv8xcwqsM&list=PLntZFZH56rSfyFo-o7Lh9NQGvtVhD7Io8
- Marketing Cloud API: https://youtu.be/RUT02nP6Q-Y
- Trailhead: https://trailhead.salesforce.com/en/content/learn/modules/marketing-cloud-apis
- Salesforce blogs by Perficient: https://blogs.perficient.com/category/partners/salesforce/