Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (2023)

  • Tweet
  • Share0
  • +1
  • LinkedIn0

Imagine you want to automate your call center follow-up emails. After your support rep speaks with a customer, you would like to automatically send an email thanking them for contacting your company. Let’s take this a step further, and say you want to include the specific conversation topic discussed with the customer that you track in your CRM. You can do this from Marketo using the requestCampaign SOAP API to send an email with dynamic content.

The requestCampaign API allows you to pass in a lead or leads. It also allows you to pass in Program Tokens that can be used with an existing Campaign to send dynamic content. The requestCampaign SOAP API 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.

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 create an email that accepts dynamic content via Program Tokens, fourth how to define an email as part of a flow action, and fifth 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

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (1)

2. Click on Smart Campaign

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (2)

3. Enter smart campaign name and click Create

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (3)

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.
Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (4)
2. In the trigger, select “is” and “Web Service API.”
Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (5)

How to Pass in Dynamic Content Using the API

In Marketo, My Tokens are variables that you can use in your Program. My Tokens enable you to enter information pertaining to your Program in one place, replace that information with a value you specify, and retrieve this information in other parts of the application, such as an email template.

Using the requestCampaign SOAP API, you can pass an array of Program Tokens, which will override existing tokens. After the campaign runs, the tokens are discarded.

You create My Tokens at either the Campaign folder level, or at the Program level. My Tokens at the Campaign folder level will inherit down to all Programs contained within the Campaign folder. If you create My Tokens at the Campaign folder level, you can overwrite the inherited value at the Program level. For example, if you define tokens for the Program Date and the Program Description at the Campaign folder level, you can overwrite these values at the individual Program level. Here’s how to do this.

1. From the Marketing Activities tree, select the Campaign folder or Program where you want to create the tokens. From the top menu bar, select My Tokens. Then the My Tokens canvas will display. From the right hand side tree, drag a Token Type to the canvas, which in this case is “Text.” In the Token Name field, highlight My Token and enter a unique Token Name, which in this case is “my.conversationtopic.” In the Value field, enter a relevant Value for the token, which in this case is “Thank you for calling us today.” Note by using the API we will override the default My Token value. Click “Save” to save the custom token.

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (6)

2. Create a New Email by clicking New. Then click on New Local Assets and select Email. Next fill out the relevant fields to name your email. When drafting your email, click the Token icon to include tokens in your email. Now that you have created your template email with Tokens, we will add the email as a flow action for the Campaign in the subsequent step. So when you call the campaign via the API, the email will be sent out.

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (7)

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (8)

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.

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (9)

Find and select the email you want to send.

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (10)

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



























<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="">



















<value>Thank you for calling about adding a line of service to your current plan.</value>






SOAP Response for requestCampaign











<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="">









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


























































































import com.marketo.mktows.*;


import javax.xml.namespace.QName;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.crypto.Mac;

import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Hex;

import javax.xml.bind.JAXBContext;

import javax.xml.bind.JAXBElement;

import javax.xml.bind.Marshaller;

public class RequestCampaign {

public static void main(String[] args) {

System.out.println("Executing Request Campaign");

try {

URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL");

String marketoUserId = "CHANGE ME";

String marketoSecretKey = "CHANGE ME";

QName serviceName = new QName("", "MktMktowsApiService");

MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName);

MktowsPort port = service.getMktowsApiSoapPort();

// Create Signature

DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

String text = df.format(new Date());

String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22);

String encryptString = requestTimestamp + marketoUserId ;

SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1");

Mac mac = Mac.getInstance("HmacSHA1");


byte[] rawHmac = mac.doFinal(encryptString.getBytes());

char[] hexChars = Hex.encodeHex(rawHmac);

String signature = new String(hexChars);

// Set Authentication Header

AuthenticationHeader header = new AuthenticationHeader();




// Create Request

ParamsRequestCampaign request = new ParamsRequestCampaign();


ObjectFactory objectFactory = new ObjectFactory();

JAXBElement<Integer> campaignId = objectFactory.createParamsRequestCampaignCampaignId(4496);


ArrayOfLeadKey leadKeyList = new ArrayOfLeadKey();

LeadKey key = new LeadKey();




JAXBElement<ArrayOfLeadKey> arrayOfLeadKey = objectFactory.createParamsRequestCampaignLeadList(leadKeyList);


ArrayOfAttrib aoa = new ArrayOfAttrib();

Attrib attrib = new Attrib();


attrib.setValue("Thank you for calling about adding a line of service to your current plan.");


JAXBElement<ArrayOfAttrib> arrayOfAttrib = objectFactory.createParamsRequestCampaignProgramTokenList(aoa);


SuccessRequestCampaign result = port.requestCampaign(request, header);

JAXBContext context = JAXBContext.newInstance(SuccessRequestCampaign.class);

Marshaller m = context.createMarshaller();

m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

m.marshal(result, System.out);


catch(Exception e) {





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.

Sending an Email with Dynamic Content from Marketo using the API - Marketo Developers (11)

*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.


How do I send a dynamic email in Marketo? ›

Add Segmentation
  1. Go to Marketing Activities.
  2. Select your email and click Edit Draft.
  3. In this example we're making the Subject Line dynamic. Click in the Subject field, then click the Make Dynamic button. ...
  4. Enter the Segmentation name, select it, and click Save.

How do I send an email from Marketo API? ›

All you need to do is create a default program in Marketo. From there, add in a smart campaign with a smart list that listens for your desired action (fills out form, clicks link, visits webpage) and then use the send email flow step to send your email. Of course, you'll need to build the email before you can send it.

How do I add dynamic content to Marketo? ›

Add Dynamic Content to an Email
  1. Step One: Create a token. Navigate to the program where you want to use the token. Click My Tokens. Double click on Email Script. Then name this token. ...
  2. Step Two: Reference the token in the email template. Note the name of the token. Navigate to your email draft. Include the token.

How do I make my email content dynamic? ›

How to build a dynamic email campaign
  1. Build your email list. ...
  2. Collect information about your subscribers. ...
  3. Group your subscribers. ...
  4. Create dynamic email content. ...
  5. Add email personalization. ...
  6. Preview for both targeted and non-targeted recipients.
Oct 26, 2022

Can email content be dynamic? ›

Gmail supports dynamic email, messages with interactive content. Dynamic email is sometimes called AMP for email. You can interact with dynamic email like you would a website. For example, you can reply to an event invitation, or respond to comments in a Google Doc, without leaving Gmail.

What is dynamic content in Marketo? ›

What is dynamic content? Dynamic content is content that displays differently to the lead based on rules that are set by the user. Content that does not display differently based on rules is called static content. Page 3.

How do I send an email through API? ›

Send Emails with Gmail API
  1. Step 1: Create a project at Google API Console.
  2. Step 2: Enable Gmail API.
  3. Step 3: Credentials and authentication with OAuth 2.0.
  4. Step 4: Pick a quickstart guide.
  5. Step 5: API client library.
  6. Step 6: Access to Gmail. Go. Java. Ruby. .NET. Node.js. PHP. Python. ...
  7. Step 7: Create an email.
  8. Step 8: Send an email.
Aug 26, 2019

Can REST API send email? ›

Use the Send Mail (v1) REST API to send an email to specified recipients, optionally attaching files from EPM Cloud. You can attach any file up to 10 MB in size, other than a snapshot, that is available in EPM Cloud environments.

How do I send an email through Web API? ›

Table of Contents
  1. Step #1 – Create an ASP.NET Core Web API project.
  2. Step #2 – Integrate your ASP.NET Core project with Swagger UI.
  3. Step #3 – Add the MailKit library.
  4. Step #4 – Add your SMTP server & email account details to the appsettings.json file.
  5. Step #5 – Make the SMTP server & email account details readable at runtime.
Mar 9, 2023

How do I set up dynamic content? ›

Here are some of the most popular methods.
  1. Newsletters and Emails. Both newsletters and emails are probably the most basic and classic forms of dynamic content being presented. ...
  2. Landing Pages. ...
  3. Articles. ...
  4. Forms and Purchases. ...
  5. Product Pages. ...
  6. Website Ads. ...
  7. Understand Your Customer and Users First. ...
  8. Use Data to Monitor Your Content.

What is the difference between dynamic content and snippets in Marketo? ›

Dynamic content and Snippets are the same in that they both work by using your pre-built segmentations. Once you select the segmentation you want to personalize, you can create a message for each group. Dynamic content works better where you might want to change content one time.

How do I make dynamic content accessible? ›

Here are a few quick tips to keep in mind:
  1. Consider whether each feature will cause unexpected changes for users.
  2. Provide updates to inform users when content will change.
  3. Make sure update notifications have a suitable priority — don't interrupt screen reader users unless the update is critical.
Mar 22, 2022

How do I automatically load remote content in email? ›

Mail->Settings->General->Check for new messages: you can set this option for a number of settings. 'Automatically' is the default.

How do I make my email content responsive? ›

Responsive email design best practices

Stick to a single column layout. Less shifting and moving makes it easier for your audience to read your content. At minimum, use 13- or 14-pt font for the body text and no smaller than 20-pt for the titles. This will make your email much more readable on a small screen.

What is an example of dynamic content? ›

Examples of dynamic content include personalized product recommendations on an e-commerce site, dynamic pricing that changes based on supply and demand, real-time updates on stock prices or sports scores, live chat features that provide instant customer support, interactive quizzes and surveys that adapt to user ...

What is a dynamic email template? ›

A dynamic email is a type of generic email that includes variables to personalize the content for each individual recipient. A simple example of this is using the {$name} variable to add the recipient's name.

Why use dynamic content in email? ›

Dynamic email content helps your team create personalized experiences at scale. No more crafting separate campaigns for different audience segments. Instead of creating a different email to talk to your leads, customers, and advocates, you can develop 1 email and switch the content based on the specific segment.

Is dynamic content faster than Static? ›

Static Website Advantages

With knowledge of HTML and CSS, you can code up a decent one without too much effort or cost. Static websites also tend to be faster than dynamic websites on the user's end.

How do I create an email template in Marketo? ›

Find and select your email, then click Edit Draft. Click the Email Actions drop-down and select Save as Template. Click the Folder drop-down, select where you want the template to live, and click Save. And that's it!

What is the difference between dynamic content and personalization? ›

The difference between content personalization and dynamic content personalization is automation. Dynamic personalization responds in real-time, using first-party data to serve content that's more appealing or more likely to convert. Web content personalization, by contrast, tends to respond to the last action taken.

How does dynamic content work? ›

Dynamic content is a web-page or email component that changes. Typically, changes are based on user signals that include in-session behavior, user data, and user-characteristics. In-session behavior- Adapt content based on what pages they visit, which products they add to cart, and how long they spend on site.

How to send attachment through API? ›

In the Message Body
  1. Open the Attachments panel and click Add Attachment. Click the image to enlarge it.
  2. Select the file you want to send. ReadyAPI will ask you if want to cache it in the request. ...
  3. Open the Request editor and set the request media type as multipart/form-data or multipart/mixed .

Can you send documents via API? ›

Transferring Files with APIs

When passing large documents “via” APIs the ideal scenario is to utilize a link to the large file and pass that link in JSON payloads, only touching the file when an application, archival system or some persistent store needs the file contents stored locally.

How do I send an API request? ›

How to Do API Testing
  1. Enter the URL of the API endpoint. ...
  2. Select the appropriate HTTP method. ...
  3. Enter your credentials in the Authorization tab. ...
  4. Click Send to submit your API request.
Sep 20, 2021

When should you not use REST API? ›

Here are some reasons not to create a REST API for your system.
  1. It already has an API. Your system already has an API. ...
  2. It Will Break. Your API will break. ...
  3. It Will Change. Ha! ...
  4. It Will Be Slow. Your API will be slow. ...
  5. It Will Be Hard To Parse. ...
  6. 6: It Will Not Make You Money. ...
  7. Conclusion.

Is SMTP same as API? ›

API is the method of communication used by different platforms or applications. SMTP allows your computer to create and send messages to the server. API is the window to send another code or utility. Comparatively, SMTP is more popular, which makes it easy to integrate and use.

How to send data through REST API? ›

To send data to the REST API server, you must make an HTTP POST request and include the POST data in the request's body. You also need to provide the Content-Type: application/json and Content-Length request headers. Below is an example of a REST API POST request to a ReqBin API endpoint.

How to validate email address using API? ›

Here are the best email validation API tools that help you validate email addresses.
  1. SendGrid Validation API. SendGrid is an excellent cloud-based email marketing platform that helps you send massive marketing campaigns across the world. ...
  2. Mailgun Email Validation. ...
  3. ZeroBounce. ...
  4. DeBounce. ...
  5. NeverBounce. ...
  6. Clearout. ...
  7. Hunter.
Nov 11, 2020

How do I send an API response message? ›

  1. Select 'POST' as method.
  2. Add Content-Type header with the value 'application/json'
  3. Add the value which you want to add in the list in Body and press 'SEND' button.
  4. In the response header, you can see the http status code and message '201 Created'
Aug 22, 2019

How do I send a response to a Web API? ›

Depending on which of these is returned, Web API uses a different mechanism to create the HTTP response. Convert directly to an HTTP response message. Call ExecuteAsync to create an HttpResponseMessage, then convert to an HTTP response message. Write the serialized return value into the response body; return 200 (OK).

What are the 4 steps to create dynamic content? ›

5 Steps to Creating Dynamic Content
  1. Step 1: Assemble your sources and identify relevant drivers & challenges. ...
  2. Step 2: Verify your insights & assumptions via social media. ...
  3. Step 3: Match your solutions to the needs of your market and test. ...
  4. Step 4: Develop content. ...
  5. Step 5: Monitor changes & adapt.

How do I add dynamic text? ›

Add dynamic text to your layout
  1. With a layout view active, on the Insert tab, in the Graphics and Text group, click the Dynamic Text button . ...
  2. Choose a dynamic text tag from the gallery.
  3. In the layout view, click and drag a box in the desired location to create the dynamic text element.

Which of the following options is used to render dynamic content? ›

The method is used to render a dynamic list of components based on values in an array.

What are snippets used for Marketo? ›

Snippets are reusable HTML components which can be embedded into Emails and Landing Pages and which can be segmented for dynamic content. Snippets don't have associated templates, and can be created and deployed within other assets within Marketo.

What is dynamic content insertion? ›

What is dynamic content insertion? Dynamic content insertion lets you add keywords and information to pages in order to match them more closely with your visitors, ads, email campaigns and so on to make them more relevant. This is also known as symmetric messaging.

What do you need to have in place to utilize dynamic content *? ›

To set up dynamic content on your website, you'll need to use a website builder that uses a content management software (CMS) – a place where you can collect and monitor user data. Most website builders such as Wix, WordPress, and Squarespace have this feature.

Where is dynamic content stored? ›

Dynamic webpages are not stored as static HTML files. Instead, server-side scripts generate an HTML file in response to events, such as user interactions or user logins, and send the HTML file to the web browser. Because dynamic content is generated server-side, it is typically served from origin servers, not a cache.

How do I display dynamic content in HTML? ›

Wrap each one of your dynamic content sections in a DIV and add a class called dynamic-content. Also, give each DIV a unique ID.

How do I send an auto generated email? ›

Schedule emails to send
  1. On your computer, go to Gmail .
  2. At the top left, click Compose.
  3. Create your email.
  4. At the bottom left next to "Send," click the Down arrow .
  5. Click Schedule send.

How do I load remote content in messages? ›

Open Preferences (on the Mac) or Tools | Options (on Windows) Click on Privacy. Select the checkbox for "Allow remote content in messages"

What is a responsive email format? ›

A responsive template will automatically adapt to any screen size, so whether the email is opened on a smartphone, tablet, or computer, it will look great, function well, and be easy for the recipient to read.

What is the best way to email sensitive information? ›

Send messages & attachments confidentially
  1. On your computer, go to Gmail.
  2. Click Compose.
  3. In the bottom right of the window, click Turn on confidential mode . Tip: If you've already turned on confidential mode for an email, go to the bottom of the email, then click Edit.
  4. Set an expiration date and passcode. ...
  5. Click Save.

How do I make my email more clickable? ›

  1. Pre-set the preview text. ...
  2. Write clear and clickable subject lines. ...
  3. Keep your emails concise. ...
  4. Include one call-to-action button per email. ...
  5. Add alt text to your CTA image. ...
  6. Hyperlink your emails' images. ...
  7. Include noticeable text links. ...
  8. Place at least one clickable item above the fold.
Mar 31, 2023

Which language is used to create dynamic content? ›

Popular dynamic programming languages include JavaScript, Python, Ruby, PHP, Lua and Perl.

What is the best example of dynamic? ›

10 Dynamic Force Examples in Daily Life
  • Earthquake.
  • Moving a Car.
  • Hitting a Cricket Ball.
  • Inflating a Balloon.
  • Stretching a Band.
  • Throwing an Object.
  • Playing with a Dough.
  • Churning Milk.

Which language provides dynamic content? ›

In addition to HTML, CSS, and JavaScript, a dynamic website uses a server-side scripting language like PHP or Python. This enables connection with the database to allow for interactive features and content changes.

Can Marketo send transactional emails? ›

A common use case for the Marketo API is to trigger the sending of transactional emails to specific records via the Request Campaign API call.

How do I send an automated marketing email? ›

Setting up the welcome email automation flow includes these steps:
  1. Install an email marketing tool. To start, you'll need easy-to-use email automation software (like Omnisend).
  2. Build and segment an email list. ...
  3. Set up an automation trigger. ...
  4. Create email campaigns. ...
  5. Activate the automation.
May 10, 2022

What is the difference between email campaign and transactional email? ›

There are a few ways to answer this question: Content and purpose: A transactional email contains information about an action the recipient has already taken, while a marketing email intends to drive the recipient toward an action you want them to take.

What is the difference between transactional email and bulk email? ›

Transactional emails facilitate a commercial transaction or relationship or provide an individual customer with the information necessary for a transaction or relationship. Bulk emails, which are sent from one sender to multiple recipients, are for marketing purposes.

Can Marketo send text messages? ›

Add SMS to Marketo, and grow campaign revenue

Text messages offer an average open rate of 98%, far more than any other channel. Use Marketo lifecycle triggers to send your message to the right people at the right time. Seamlessly integrate SMS into simple and advanced Marketo workflows with webhooks and Email to SMS.

Can emails be sent automatically? ›

Email automation is a way to create emails that reach the right people with the right message at the right moment—without doing the work every time, sending automated messages leveraging a marketing automation tool.

How do you send automated messages to customers? ›

How to Send Automated Text Messages for Marketing
  1. Sign Up for an Automated Text Message Service.
  2. Upload Your Opted-in Contacts.
  3. Build Your Text Marketing List with Keywords and Sign Up Forms.
  4. Create Your Automated Text Message.
  5. Schedule and Send Automated Text Messages.

What is an example of email automation? ›

Examples of email automation: Seasonal offers promoted

Seasonal occasions such as Christmas, Thanksgiving, and Halloween are great times to send automated emails. Setting these up prior to the day or period allows you to target customers when they're most in the mood to spend their cash.

What is email with dynamic content? ›

Dynamic content in email marketing describes any email content that changes based on the subscribers' data, preferences, and behaviors. So, you'd send out a marketing email to your entire database, but certain content modules within that email would be dynamic, changing based on a characteristic you determine.

How to insert dynamic values from custom entities in an email template? ›

Insert dynamic text

On the template editor, place your cursor where you want the personalized content to appear. Select Insert dynamic text. Select the Record type and Field name. The category that you specified when you created the email template determines the record types you can choose.


Top Articles
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated: 12/10/2023

Views: 6250

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.