Personalize Email Content with Content APIs

Content APIs allow you to create personalized campaigns by fetching data dynamically at the time of sending the campaign based on Recommendations or coupons or other Personalization APIs. Such targeted, relevant, and timely communication has been proven to have much better engagement and conversion rates than generic email campaigns. For more information about Content APIs, click here.

Using Content APIs in MoEngage

Follow these three steps to use Content API in MoEngage.

  1. Add an API to MoEngage.

  2. Create a personalized email campaign using the saved Content API.

  3. Personalize different elements in the email using Content API such as Images, Links, Dynamic text, and so on. You can employ Content API in both Subject Line and the email body.
  4. Send the campaign.

Add an API to MoEngage

To set up an API to be used during MoEngage campaigns, add the URL and parameters of the Content API to the MoEngage platform. Follow these steps:

  1. Navigate to MoEngage Dashboard > Settings > APIs and click the Content API tab.

  2. Click Add button.
    The following Add Content API screen is displayed.

  3. Fill in the following details:

Field Description
API Name Type the Content API name
API Type Select the type as Single.
API URL Type the complete URL of the Content API.
Header Click the plus sign and type the key value for the headers used in the Content API
Key Value Parameters Click the plus sign to add key value for the parameters used in the Content API. Use “@” in the value field to choose from the list of pre-defined user attributes. The parameters cannot be personalized using Event attributes in the value field.

4. Click Save.

The Content API is saved in the MoEngage app.

Create a personalized email campaign

Create a campaign using the steps described in Create Email Campaign. During the campaign creation, in the content creation step use the ContentApi variable to access all the configured Content API sources.  You can use the Content API by directly calling the ContentApi variable in the code or by choosing the Content API from the Email Personalization UI.

You can add the created Content APIs using the Personalization screen as shown below. Type '@' in the Custom HTML Editor and add the Content API created.


Click on 'Done' and the Content API gets added to the email message.

For example, in the screenshot shown below, the Content API is used to dynamically fetch the Recommened Products for a given user id. Marketers can use this feature to engage users with product recommendations and nudge them towards making a purchase. The value parameter can be a dynamic parameter (type '@' to add a user attribute to be passed to the Content API) or can be a static parameter that can be keyed in the value section.


This when added, appears as follows in the Custom HTML Editor.


Click on the Preview option to see how the user will see it in their inbox.


Example 1

You may have a “cart” data source with the following JSON:

 "date": "March 10, 2016",
 "items": [
     "name": "belt",
     "image": "",
     "price": 11
   }, {
     "name": "shoes",
     "image": "",
     "price": 12
   }, {
     "name": "hat",
     "image": "",
     "price": 10

In the content creation, use the following code:

{% for cart_item in ContentApi.cart().items %}
   <h2>{{ }}: ${{ cart_item.price|round(2) }}</h2>
   <img src="{{ cart_item.image }}" />
{% endfor %}

Example 2

The campaigns contain placeholders for different SKUs (in this case, hotels), along with the required formatting, segmentation, and triggering schedules.


Send the Email Campaign

At the time of sending the message, for the example above the system would:

  • Invoke the Content API to fetch hotels recommended for the user based on the search parameters like destination, check-in, and check-out dates, number of adults and children, and so on.

  • Populate the email with details of the recommended hotels like the name, rating, price, image, and ranking in an HTML-formatted, personalized email.

  • Do this for every user belonging to the specified segment dynamically without any manual input.


For more information on personalization language, refer to Templating Language Documentation.

Was this article helpful?
0 out of 1 found this helpful

How can we improve this article?