Connecting to MailChimp using API workflow alerts


Important Note

In this article you will learn how to set up a MailChimp API alert to send user details through.

This article is written with the consideration that a Mailchimp campaign has already been created and completed. If you have not completed the set up of your campaign this process will not work!


Set Up - Example

1) Go to Admin Dash > Manage > Workflows and click on 'Sign Up'

2) Click on 'Account Created'

3) Click on 'Add Alert'

4) As shown in the image below, enter in a name for the workflow in the first field. Set the alert type to 'api_call' and set the request type to 'POST'.

5) Now we need to find a few pieces of information:

API Key: To find your Mailchimp API Key log in to the Mailchimp user dash, API key can be generated or found by going to Account > Extras > API Keys. (example: 0c0b4b3c6a0a39c47f12c78e946bb248-us14) Save this number for the next step.

Campaign ID: To find this we'll need to open up your terminal and enter the following:

curl --request GET --url https://DATA_CENTER.api.mailchimp.com/3.0/campaigns --user 'somevalue: YOUR_API_KEY'

making sure to replace DATA_CENTER with the data center from your API key (This is the last part of your API Key (us14 in our example API key above) and adding your full API Key where you see YOUR_API_KEY. So, an example would look like:

curl --request GET --url <a href="https://us14.api.mailchimp.com/3.0/campaigns">https://us14.api.mailchimp.com/3.0/campaigns</a> --user 'somevalue:0c0b4b3c6a0a39c47f12c78e946bb248-us14'

6) Placing that GET request into your terminal will provide you with your Campaign ID in the response. It will be the first number after 'id' as shown in the image below. Save that number for the next step.

7) Go back to your workflow alert and in the box labeled 'Endpoint' you will need to insert the following:

https://DATA_CENTER.api.mailchimp.com/3.0/campaigns/ID/actions/send
	

making sure to replace DATA_CENTER with the data center from your API key (This is the last part of your API Key (us14 in our example API key above) and replacing ID with the ID copied from the last step above.

Our example would then look like:

https://us14.api.mailchimp.com/3.0/campaigns/28684d02f2/actions/send
	

8) Next week need to add information to the Headers section of the Workflow Alert. To find the information to add you will want to copy the code below, replacing YOUR_API_KEY with your API key

"Basic " + window.btoa(unescape(encodeURIComponent('username' + ':' + 'YOUR_API_KEY')))
	

Our example would then look like:

"Basic " + window.btoa(unescape(encodeURIComponent('username' + ':' + '0c0b4b3c4a0a39c44f12c78e946bb248-us14')))<br>
	

and add it to your browser's Console and press 'Enter'. This will give an output as shown in the image below. Save this information for the next step:

9) Before you copy the output from the console into the 'Headers' Section, you need to enter the following in the headers section as shown in the image below:

	{
	
		"Authorization": OUTPUT_

	}
	

Our example would then look like:

	{
	
		"Authorization": "Basic dXNlcm5hbWU6MGMwYjRiM2M0YTBhMzljNDRmMTJjNzhlOTQYmIyNDgtdXMxNA=="

	}
	

Here's a view of the whole WorkFlow Alert:

Be sure to hit 'save' once this is completed as you have now set up an API call to your Mailchimp campaign!