This functionality is used to send, through the MDirector API, emails with content that we have in another system. In this way, clients with API access can make a connection to send the content of that external system to a template previously defined in MDirector and be able to send email campaigns to contacts with that content.
For example: a brand wants to create by API a weekly mailing with news about its market. It has an html with a general structure that will be used for each mailing whose content will be filled automatically from your system. When creating the API mailing, the general content, i.e. the news of the week, will be filled in with the same API call, while if there is contact personalization, the placeholders will remain intact to be filled in at the time of sending the mailing.
Important: content placeholders must be distinguished from contact placeholders. If an API mailing is created with placeholders that have the same name as a contact field (default or customized), the content placeholder will prevail and therefore the contact placeholder will not be taken into account.
For example: if you want to include a different newsletter name every month, for example "The spring newsletter", "The summer newsletter", etc. and you also want to personalize the newsletter with the name of the contact that receives it "Newsletter for Paquita Salas", the placeholder for the newsletter name cannot be [Name] but one that identifies this field well as [NameNewsletter] or another completely different as the one we have put in the example below [LargeTitle].
Steps to program a mailing by API with content:
- Create a new template in "Templates":
- Content that is different in each campaign is included as placeholders.
In this example, placeholders are:
[TituloGrande]
[Titular1]
[ImagenCabeceraGrande]
[Desarrollo1]
[Name] and [Lastname1] are also included to customize at the contact level (be careful, if these fields were sent in the API call they would be filled in when creating the mailing and therefore they would be the same for all contacts).
The fields containing images as in this case [ImagenCabeceraGrande] are included inside the image in the option "Image URL" as follows:
- The API call will be made from the following link: https://api.mdirector.com/api_delivery
API is programmed by including these two parameters:
templateId: identifier of the template to be copied and pasted from "templates".
templateVariables: an array with the values for the content placeholders (in this case all except [Name] and [Lastname1]).
Complete example of API call with template parameters in orange:
{
"type": "email",
"name": "test template 05",
"subject": "hello world 05",
"campaignName": "PlantillasAPI",
"language": "en",
"segments": "[\"574\"]",
"templateId": "98c1a5af-ba94-3afd-8d7b-77d3e166133e",
"templateVariables": {"TituloGrande":"The summer newsletter",
"Titular1":"New1",
"Desarrollo1":"This is the new's content jhsh sfh dkfh dkfhdfkd hfkdj hfkjdhf kjdf hkdj hfkdjf hkdjf hkdjf hkdhfdkjhfkdj hfkjd hfkjd f",
"ImagenCabeceraGrande":"http://app.mdirector.com/files/user-template-resources/4/4/7/0/4470/56eb9666-1edf-3cd0-9123-59602ac1e7ad/43909974371_752410415f_b.jpg.jpegw:596h358x4y0.pngw:596h327x0y0.png"},
"fromName": "Mary",
"replyToName": "Alex",
"replyToEmail": "aarribas@antevenio.com"
}
The response of the call (if it is ok (200)) returns among other things the parameter "envId" which is the identifier of the sending that has been created. This identifier must be used in the PUT call made to program the sending.
{
"response": "ok",
"message": "The delivery was successfully created",
"data": {
"camId": "102",
"envId": "515",
"subId": "678",
"html": "\n <!DOCTYPE html ……………………………….
}
- Once the above POST call has been made, the mailing has been created in draft in MDirector as follows:
- The sending programming can be done in the usual way by API with the PUT method with the following parameters:
{
"envId": "515",
"date": "now"
}
and the call back if everything went ok is:
{
"response": "ok",
"message": "The delivery '515' was successfully scheduled for '2023-07-03 11:49'"
}
The e-mail will arrive with the fields completed, both at the contact level and at the content level:
NOTE
We are constantly working to make our platform easier to use so that you can get the most out of it. If you have already exhausted our support and video resources, please contact our support team, we will be happy to assist you at soporte@mdirector.com
Comments