Sending a transactional email from Marketo using the API

March 27, 2014 | by

You can send a transactional email from Marketo using the requestCampaign SOAP API. It requires an existing Smart Campaign to be created using the Marketo UI. It also requires the email recipient to exist in Marketo. So before calling the requestCampaign API, use the getLead API to verify if the email exists in Marketo. After you make a call via the requestCampaign API, you can confirm it by checking to see if the Smart Campaign has run in Marketo.

We’ll show you first how to create a Smart Campaign, second how to set up a trigger to send a campaign via the API, third how to define an email as part of a flow action, and fourth a code sample that would be used to execute this campaign.

How to Create a New Smart Campaign in Marketo

Smart Campaigns in Marketo execute all of your marketing activities. You can set up a series of automated actions to take on a smart list of contacts. In the case of sending transactional emails, you set up a trigger in the campaign, as shown below, to send emails using the API. First let’s set up the Smart Campaign.

1. In Marketing Activities, choose a Program and then under the New dropdown, click on New Local Asset


2. Click on Smart Campaign


3. Enter smart campaign name and click Create


Add Triggers to a Smart Campaign

Adding Triggers to a Smart Campaign allows you to make a Smart Campaign run on one person at a time based on a live event, which in this case is a request via the requestCampaign API.

1. Search for the “Campaign is Requested” trigger and then drag and drop it to the canvas.
2. In the trigger, select “is” and “Web Service API.”

How to Create Email Flow Action on a Campaign

The association of an email with a Smart Campaign allows marketers to manage how they want an email to look, and allows the third-party application to determine who receives it and when.

After creating an email as a new Local Asset, you can set it as a flow action in a campaign.


Find and select the email you want to send.


Code Sample to Call the requestCampaign API

After setting up the campaign and triggers in the Marketo interface, we will show you how to use the API to send an email. The first sample is a XML request, the second is a XML response, and the final one is a Java code sample that can be used to generate the XML request. We also show you how to find the campaign ID that is used when making a call to the requestCampaign API.

The API call also requires you to know the ID of the Marketo campaign beforehand. You can determine the campaign ID using either of the following methods:

1. Use the getCampaignsForSource API

2. Open the Marketo campaign in a browser and look at the URL address bar. The campaign ID (represented as a 4-digit integer) can be found immediately following “SC”. For example, The bolded portion is the campaign ID – “1025.”

SOAP Request for requestCampaign

SOAP Response for requestCampaign

See below a sample Java program that executes the scenario described above.

* This article contains code used to implement custom integrations. Due to its customized nature, The Marketo Technical Support team is unable to troubleshoot custom work. Please do not attempt to implement the following code sample without appropriate technical experience, or access to an experienced developer.