Using template with Send API

Send API, Mailjet Transactional API, allow you to leverage the power of the template language.

The templates and template language can be used in multiple ways with Send API:

  • posting on /send resource with message content as Text-part or Html-part
  • saving the content of the message with the /template resource and using it on demand with the Mj-TemplateID property of Send API.
  • using templates you created through the Passport User Interface.

Note

In order to have the template language interpreted, you must provide Mj-TemplateLanguage property in the payload to the Send API and set it to true.

Refer to the Send API guide for more information.

Send a message, containing template language

You can simply pass in the payload of the call to Send API a text version (Text-Part property) and/or an Html version (Html-Part property) containing template language.

curl -s \
	-X POST \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/send \
	-H 'Content-Type: application/json' \
	-d '{
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"Text-part":"Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! ",
		"Html-part":"

Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!


", "MJ-TemplateLanguage":true, "Recipients":[ { "Email": "passenger@mailjet.com" } ] }'
<?php
/*
This calls sends a message based on a template.
*/
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'FromEmail' => "pilot@mailjet.com",
    'FromName' => "Mailjet Pilot",
    'Subject' => "Your email flight plan!",
    'Text-part' => "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! ",
    'Html-part' => "

Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!

", 'MJ-TemplateLanguage' => true, 'Recipients' => [['Email' => "passenger@mailjet.com"]] ]; $response = $mj->post(Resources::$Email, ['body' => $body]); $response->success() && var_dump($response->getData()); ?>
/**
 *
 * This calls sends a message based on a template.
 *
 */
var mailjet = require ('node-mailjet')
	.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
	.post("send")
	.request({
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"Text-part":"Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! ",
		"Html-part":"

Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!

", "MJ-TemplateLanguage":"true", "Recipients":[ { "Email": "passenger@mailjet.com" } ] }); request .then(result => { console.log(result.body) }) .catch(err => { console.log(err.statusCode) })
# This calls sends a message based on a template.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Send.create(
  from_email: "pilot@mailjet.com",
  from_name: "Mailjet Pilot",
  subject: "Your email flight plan!",
  text_part: "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! ",
  html_part: "

Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!

", "Mj-TemplateLanguage": true, recipients: [{ 'Email'=> 'passenger@mailjet.com'}] )
"""
This calls sends a message based on a template.
"""
from mailjet import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'FromEmail': 'pilot@mailjet.com',
  'FromName': 'Mailjet Pilot',
  'Subject': 'Your email flight plan!',
  'Text-part': 'Dear {{data:firstname:"passenger"}}, welcome to Mailjet! ',
  'Html-part': '

Dear {{data:firstname:"passenger"}}, welcome to Mailjet!

', 'MJ-TemplateLanguage': 'true', 'Recipients': [ { "Email": "passenger@mailjet.com" } ] } result = mailjet.send.create(data=data) print result.status_code print result.json()
package MyClass;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.errors.MailjetSocketTimeoutException;
import com.mailjet.client.errors.MailjetClient;
import com.mailjet.client.errors.MailjetRequest;
import com.mailjet.client.errors.MailjetResponse;
import com.mailjet.client.resource.Email;
import org.json.JSONArray;
import org.json.JSONObject;
public class MyClass {
    /**
     * This calls sends a message based on a template.
     */
    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
      request = new MailjetRequest(Email.resource)
						.property(Email.FROMEMAIL, "pilot@mailjet.com")
						.property(Email.FROMNAME, "Mailjet Pilot")
						.property(Email.MJTEMPLATELANGUAGE, true)
						.property(Email.SUBJECT, "Your email flight plan!")
						.property(Email.TEXTPART, "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! ")
						.property(Email.HTMLPART, "

Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!

") .property(Email.RECIPIENTS, new JSONArray() .put(new JSONObject() .put("Email", "passenger@mailjet.com"))) .property(Email.MJEVENTPAYLOAD, "Eticket,1234,row,15,seat,B"); response = client.post(request); System.out.println(response.getStatus()); System.out.println(response.getData()); } }
/*
This calls sends a message based on a template.
*/
package main
import (
	"fmt"
	. "github.com/mailjet/mailjet-apiv3-go"
	"os"
)
func main () {
	mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
	email := &InfoSendMail {
      FromEmail: "pilot@mailjet.com",
      FromName: "Mailjet Pilot",
      Subject: "Your email flight plan!",
      TextPart: "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!",
      HTMLPart: "

Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!

", MjTemplateLanguage: "true", Recipients: []Recipient { Recipient { Email: "passenger@mailjet.com", }, } } res, err := mailjetClient.SendMail(email) if err != nil { fmt.Println(err) } else { fmt.Println("Success") fmt.Println(res) } }
using Mailjet.Client;
using Mailjet.Client.Resources;
using System;
using Newtonsoft.Json.Linq;
namespace Mailjet.ConsoleApplication
{
   class Program
   {
      /// 
      /// This calls sends a message to one recipient with a CustomID
      /// 
      static void Main(string[] args)
      {
         RunAsync().Wait();
      }
      static async Task RunAsync()
      {
         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
         MailjetRequest request = new MailjetRequest
         {
            Resource = Send.Resource,
         }
            .Property(Send.FromEmail, "pilot@mailjet.com")
            .Property(Send.FromName, "Mailjet Pilot")
            .Property(Send.Subject, "Your email flight plan!")
            .Property(Send.TextPart, "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!")
            .Property(Send.HtmlPart, "

Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet!

") .Property(Send.Recipients, new JArray { new JObject { {"Email", "passenger@mailjet.com"} } }) .Property(Send.MjTemplateLanguage, "True"); MailjetResponse response = await client.PostAsync(request); if (response.IsSuccessStatusCode) { Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount())); Console.WriteLine(response.GetData()); } else { Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode)); Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo())); Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage())); } } } }

Send a stored template

Use the Mj-TemplateID property in your Send API payload to specify the ID of the template you created.

curl -s \
	-X POST \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/send \
	-H 'Content-Type: application/json' \
	-d '{
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"MJ-TemplateID":"1",
		"MJ-TemplateLanguage":true,
		"Recipients":[
				{
						"Email": "passenger@mailjet.com"
				}
		]
	}'

<?php
/*
This calls sends a message based on a template.
*/
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'FromEmail' => "pilot@mailjet.com",
    'FromName' => "Mailjet Pilot",
    'Subject' => "Your email flight plan!",
    'MJ-TemplateID' => 1,
    'MJ-TemplateLanguage' => true,
    'Recipients' => [['Email' => "passenger@mailjet.com"]]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>

/**
 *
 * This calls sends a message based on a template.
 *
 */
var mailjet = require ('node-mailjet')
	.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
var request = mailjet
	.post("send")
	.request({
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"MJ-TemplateID":"1",
		"MJ-TemplateLanguage":"true",
		"Recipients":[
				{
						"Email": "passenger@mailjet.com"
				}
		]
	});
request
	.then(result => {
		console.log(result.body)
	})
	.catch(err => {
		console.log(err.statusCode)
	})

# This calls sends a message based on a template.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Send.create(
  from_email: "pilot@mailjet.com",
  from_name: "Mailjet Pilot",
  subject: "Your email flight plan!",
  "Mj-TemplateID": "1",
  "Mj-TemplateLanguage": true,
  recipients: [{ 'Email'=> 'passenger@mailjet.com'}]
)

"""
This calls sends a message based on a template.
"""
from mailjet import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'FromEmail': 'pilot@mailjet.com',
  'FromName': 'Mailjet Pilot',
  'Subject': 'Your email flight plan!',
  'MJ-TemplateID': '1',
  'MJ-TemplateLanguage': 'true',
  'Recipients': [
				{
						"Email": "passenger@mailjet.com"
				}
		]
}
result = mailjet.send.create(data=data)
print result.status_code
print result.json()

package MyClass;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.errors.MailjetSocketTimeoutException;
import com.mailjet.client.errors.MailjetClient;
import com.mailjet.client.errors.MailjetRequest;
import com.mailjet.client.errors.MailjetResponse;
import com.mailjet.client.resource.Email;
import org.json.JSONArray;
import org.json.JSONObject;
public class MyClass {
    /**
     * This calls sends a message based on a template.
     */
    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
      request = new MailjetRequest(Email.resource)
						.property(Email.FROMEMAIL, "pilot@mailjet.com")
						.property(Email.FROMNAME, "Mailjet Pilot")
						.property(Email.MJTEMPLATEID, 1)
						.property(Email.MJTEMPLATELANGUAGE, true)
						.property(Email.SUBJECT, "Your email flight plan!")
						.property(Email.RECIPIENTS, new JSONArray()
                .put(new JSONObject()
                    .put("Email", "passenger@mailjet.com")))
						.property(Email.MJEVENTPAYLOAD, "Eticket,1234,row,15,seat,B");
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}
/*
This calls sends a message based on a template.
*/
package main
import (
	"fmt"
	. "github.com/mailjet/mailjet-apiv3-go"
	"os"
)
func main () {
	mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
	email := &InfoSendMail {
      FromEmail: "pilot@mailjet.com",
      FromName: "Mailjet Pilot",
      Subject: "Your email flight plan!",
      MjTemplateID: "1",
      MjTemplateLanguage: "true",
      Recipients: []Recipient {
        Recipient {
          Email: "passenger@mailjet.com",
        },
      }
    }
	res, err := mailjetClient.SendMail(email)
	if err != nil {
			fmt.Println(err)
	} else {
			fmt.Println("Success")
			fmt.Println(res)
	}
}
using Mailjet.Client;
using Mailjet.Client.Resources;
using System;
using Newtonsoft.Json.Linq;
namespace Mailjet.ConsoleApplication
{
   class Program
   {
      /// 
      /// This calls sends a message to one recipient with a CustomID
      /// 
      static void Main(string[] args)
      {
         RunAsync().Wait();
      }
      static async Task RunAsync()
      {
         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
         MailjetRequest request = new MailjetRequest
         {
            Resource = Send.Resource,
         }
            .Property(Send.FromEmail, "pilot@mailjet.com")
            .Property(Send.FromName, "Mailjet Pilot")
            .Property(Send.Subject, "Your email flight plan!")
            .Property(Send.Recipients, new JArray {
                new JObject {
                 {"Email", "passenger@mailjet.com"}
                 }
                })
            .Property(Send.MjTemplateID, "1")
            .Property(Send.MjTemplateLanguage, "True");
         MailjetResponse response = await client.PostAsync(request);
         if (response.IsSuccessStatusCode)
         {
            Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
            Console.WriteLine(response.GetData());
         }
         else
         {
            Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
            Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
            Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
         }
      }
   }
}

Learn more about how to save and manage your templates on Mailjet in our Template API guide

Templates error management

Send API offers two payload properties to allow error management:

  • MJ-TemplateErrorReporting: Email Address where a message with the error description is sent to.
  • MJ-TemplateErrorDeliver: Determines if the message should - or not - be delivered to the recipient in case of an error, when processing the message's template language.

By default, when there is an error in the template, the message will not be delivered to the recipient and the message will have a `blocked' status in the Mailjet statistics.

If an error occurs when the template error reporting is enabled, a message from templating-language-error@mailjet.com with subject Error while evaluating Mailjet Templating language for message "original subject" will be delivered to the given error reporting address. It will contain the error message in the body and an attachment, containing the source of the original message (base64 encoded).

# This calls sends a message to a recipient and an template error email.
curl -s \
	-X POST \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/send \
	-H 'Content-Type: application/json' \
	-d '{
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"MJ-TemplateID":"1",
		"MJ-TemplateLanguage":true,
		"MJ-TemplateErrorReporting":"air-traffic-control@mailjet.com",
		"MJ-TemplateErrorDeliver":"deliver",
		"Recipients":[
				{
						"Email": "passenger@mailjet.com"
				}
		]
	}'
<?
/*
This calls sends a message to a recipient and an template error email.
*/
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$body = [
    'FromEmail' => "pilot@mailjet.com",
    'FromName' => "Mailjet Pilot",
    'Subject' => "Your email flight plan!",
    'MJ-TemplateID' => "1",
    'MJ-TemplateLanguage' => true,
    'MJ-TemplateErrorReporting' => "air-traffic-control@mailjet.com",
    'MJ-TemplateErrorDeliver' => "deliver",
    'Recipients' => [
        [
            'Email' => "passenger@mailjet.com"
        ]
    ]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success() && var_dump($response->getData());
?>

/**
 *
 * This calls sends a message to a recipient and an template error email.
 *
 */
const mailjet = require ('node-mailjet')
	.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
const request = mailjet
	.post("send")
	.request({
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"MJ-TemplateID":"1",
		"Mj-TemplateLanguage":"true",
		"MJ-TemplateErrorReporting":"air-traffic-control@mailjet.com",
		"MJ-TemplateErrorDeliver":"deliver",
		"Recipients":[
				{
						"Email": "passenger@mailjet.com"
				}
		]
	})
request
  .then(result => {
    console.log(result.body)
	})
  .catch(error => {
    console.log(error.statusCode)
	})
# This calls sends a message to a recipient and an template error email.
Mailjet.configure do |config|
  config.api_key = ENV['MJ_APIKEY_PUBLIC']
  config.secret_key = ENV['MJ_APIKEY_PRIVATE']
  config.default_from = 'your default sending address'
end
variable = Mailjet::Send.create(
  from_email: "pilot@mailjet.com",
  from_name: "Mailjet Pilot",
  subject: "Your email flight plan!",
  "Mj-TemplateID": "1",
  "Mj-TemplateLanguage": true,
  "Mj-TemplateErrorReporting": "air-traffic-control@mailjet.com",
  "Mj-TemplateErrorDeliver": "deliver",
  recipients: [{ 'Email'=> 'passenger@mailjet.com'}]
)
"""
This calls sends a message to a recipient and an template error email.
"""
from mailjet_rest import Client
import os
api_key = os.environ['MJ_APIKEY_PUBLIC']
api_secret = os.environ['MJ_APIKEY_PRIVATE']
mailjet = Client(auth=(api_key, api_secret))
data = {
  'FromEmail': 'pilot@mailjet.com',
  'FromName': 'Mailjet Pilot',
  'Subject': 'Your email flight plan!',
  'MJ-TemplateID': '1',
  'MJ-TemplateLanguage': 'true',
  'MJ-TemplateErrorReporting': 'air-traffic-control@mailjet.com',
  'MJ-TemplateErrorDeliver': 'deliver',
  'Recipients': [
				{
						"Email": "passenger@mailjet.com"
				}
		]
}
result = mailjet.send.create(data=data)
print result.status_code
print result.json()
package com.my.project;
import com.mailjet.client.errors.MailjetException;
import com.mailjet.client.errors.MailjetSocketTimeoutException;
import com.mailjet.client.MailjetClient;
import com.mailjet.client.MailjetRequest;
import com.mailjet.client.MailjetResponse;
import com.mailjet.client.resource.Email;
import org.json.JSONArray;
import org.json.JSONObject;
public class MyClass {
    /**
     * This calls sends a message to a recipient and an template error email.
     */
    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
      MailjetClient client;
      MailjetRequest request;
      MailjetResponse response;
      client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
      request = new MailjetRequest(Email.resource)
						.property(Email.FROMEMAIL, "pilot@mailjet.com")
						.property(Email.FROMNAME, "Mailjet Pilot")
						.property(Email.SUBJECT, "Your email flight plan!")
						.property(Email.MJTEMPLATEID, "1")
						.property(Email.MJTEMPLATELANGUAGE, true)
						.property(Email.MJTEMPLATEERRORREPORTING, "air-traffic-control@mailjet.com")
						.property(Email.MJTEMPLATEERRORDELIVER, "deliver")
						.property(Email.RECIPIENTS, new JSONArray()
                                                                .put(new JSONObject()
                                                                    .put("Email", "passenger@mailjet.com")));
      response = client.post(request);
      System.out.println(response.getStatus());
      System.out.println(response.getData());
    }
}
/*
This calls sends a message to a recipient and an template error email.
*/
package main
import (
	"fmt"
	. "github.com/mailjet/mailjet-apiv3-go"
	"os"
)
func main () {
	mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
	email := &InfoSendMail {
      FromEmail: "pilot@mailjet.com",
      FromName: "Mailjet Pilot",
      Subject: "Your email flight plan!",
      MjTemplateID: "1",
      MjTemplateLanguage: "true",
      MjTemplateErrorReporting: "air-traffic-control@mailjet.com",
      MjTemplateErrorDeliver: "deliver",
      Recipients: []Recipient {
        Recipient {
          Email: "passenger@mailjet.com",
        },
      },
    }
	res, err := mailjetClient.SendMail(email)
	if err != nil {
			fmt.Println(err)
	} else {
			fmt.Println("Success")
			fmt.Println(res)
	}
}
using Mailjet.Client;
using Mailjet.Client.Resources;
using System;
using Newtonsoft.Json.Linq;
namespace Mailjet.ConsoleApplication
{
   class Program
   {
      /// 
      /// This calls sends a message to one recipient with a CustomID
      /// 
      static void Main(string[] args)
      {
         RunAsync().Wait();
      }
      static async Task RunAsync()
      {
         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
         MailjetRequest request = new MailjetRequest
         {
            Resource = Send.Resource,
         }
            .Property(Send.FromEmail, "pilot@mailjet.com")
            .Property(Send.FromName, "Mailjet Pilot")
            .Property(Send.Subject, "Your email flight plan!")
            .Property(Send.Recipients, new JArray {
                new JObject {
                 {"Email", "passenger@mailjet.com"}
                 }
                })
            .Property(Send.MjTemplateID, "1")
            .Property(Send.MjTemplateLanguage, "True")
            .Property(Send.MjTemplateErrorDeliver, "deliver")
            .Property(Send.MjTemplateErrorReporting, "air-traffic-control@mailjet.com");
         MailjetResponse response = await client.PostAsync(request);
         if (response.IsSuccessStatusCode)
         {
            Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
            Console.WriteLine(response.GetData());
         }
         else
         {
            Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
            Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
            Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
         }
      }
   }
}

Common templating errors

  • expression parsing error ## Unknown identifier: var:day ## near ## {{var:day ## : This error indicates that the "day" variable is not defined in your Vars. It can be fixed by adding default value for the variable or making sure that you pass all the variables required by the template.
  • expression parsing error ## Unknown identifier: day ## near ## {{day ## : This error is similar to the previous one, except for the absence of namespace (var or data). It can indicates that you forgot to specify whether you want to use a Send API variable var:day or a contact property data:day. It can also indicate that you are trying to use a template variable that is neither define in a set function nor a loop statement.
  • not valid template ## near ## y}}</html> ## : This error occurs when the statement is not finished - missing {% endif %}
  • "var:day" is not an array value : This error is generally returned when you try to loop on a non-array value.