This article demonstrates how to send an email, using the API to trigger an External Event, and populating some simple external data into the email.
The following HTML will be used:
<html>
<head>
<title>API Exercise 3 Example</title>
</head>
<body>
<h2>
Exercise 3 - Placeholders
</h2>
<p>
Dear {{event.firstName}} ,<br>
Please find your order details below:
</p>
<ul>
<li>Ordernumber: {{event.orderNumber}}</li>
<li>Product: {{event.productName}}</li>
<li>Quantity: {{event.Quantity}}</li>
<li>Price: {{event.Price}}</li>
</ul>
</body>
</html>
In this example, there are five different placeholders:
- A first name
- An order number
- The name of the product
- The quantity of the product
- The price of the product
API placeholders always have the following syntax: {{event.placeholdername}}
It must contain the event.
prefix, otherwise it will not work!
Use the name of the placeholder (e.g. firstName
) in your JSON Payload. The JSON of this campaign will look like the following:
{
"key_id": "3",
"external_id": "jack.example@gmail.com",
"data":{
"firstName": "Jack",
"orderNumber": "12345",
"Quantity": "3",
"Price": "45.95"
}
}
The following image shows when the API call is triggered using the Emarsys Dev Hub:
The result of the email will show the data:

Broadcast Events
Broadcast events are used when you need to send triggered emails to contacts who are not in your contact database. Since no personalization data is available for these virtual contacts, the email address and all personalization data must be provided in the payload of the request.
The JSON of this campaign will look like the following:
{
"email": "virtual@contact.com",
"data": {
"global": {
"orderId": "123456789",
"orderDate": "2019-08-07",
"subject": "Test payload"
}
}
}
For more information, see the Developer Hub.