{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/template_language/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["code-snippet"]},"type":"markdown"},"seo":{"title":"Templating Language Overview","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Mailjet templating language supports variables, conditions, loops, and multiple data sources for transactional emails, with syntax similar to Jinja2 and Twig.","image":"https://dev.mailjet.com/og-image.png","lang":"en-US","keywords":["Mailjet API","Email API","Content API","SMTP Relay","transactional email","email delivery","Send API","email templates","developer documentation"],"meta":[{"name":"og:type","content":"website"},{"name":"og:site_name","content":"Mailjet Developer Documentation"},{"name":"twitter:card","content":"summary_large_image"},{"name":"robots","content":"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"},{"name":"googlebot","content":"index, follow, max-snippet:-1, max-image-preview:large"}],"jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://dev.mailjet.com/#organization","name":"Mailjet","alternateName":"Sinch Mailjet","url":"https://www.mailjet.com","logo":"https://assets.mailjet.com/lib/images/mailjetLogo/mj_logo_with_text_color.png","parentOrganization":{"@type":"Organization","name":"Sinch","url":"https://www.sinch.com"}},{"@type":"WebSite","@id":"https://dev.mailjet.com/#website","name":"Mailjet Developer Documentation","description":"Official developer documentation for the Mailjet Email API, Content API and SMTP Relay.","url":"https://dev.mailjet.com/","inLanguage":"en-US","publisher":{"@id":"https://dev.mailjet.com/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://dev.mailjet.com/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]},"llmstxt":{"hide":false,"title":"Mailjet Developer Documentation","description":"Developer documentation for the Mailjet Email API, Content API and SMTP Relay - guides, API references and code samples for sending, templating and tracking email at scale.","details":{"content":"Mailjet (part of Sinch) provides APIs for sending and managing email.\n\nThis documentation covers four main areas:\n\n- **Email API** - the Send API (v3 and v3.1) for transactional and marketing email,\n  plus contact management, segmentation, campaigns, statistics, webhooks, the Parse API\n  and the Mailjet Templating Language.\n- **Content API** - programmatic management of email templates, template contents,\n  images, labels and authentication tokens (v1).\n- **SMTP Relay** - sending through Mailjet's SMTP servers, including custom headers.\n- **API Reference** - the complete, generated reference for every endpoint, built directly\n  from the OpenAPI specifications.\n\nBase URL for all REST APIs: `https://api.mailjet.com`.\nAuthentication uses HTTP Basic auth with an API key and secret key.\n\n## Machine-readable entry points\n\nPrefer these when you need the API surface in as few requests as possible:\n\n- `/openapi/openapi-mailjet.md` - the **complete** Email API reference (every endpoint,\n  grouped by resource) as a single Markdown document.\n- `/openapi/openapi-passport.md` - the **complete** Content API reference as a single\n  Markdown document.\n- `/_bundle/openapi/openapi-mailjet.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Email API.\n- `/_bundle/openapi/openapi-passport.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Content API.\n- `/sitemap.xml` - every indexable URL on this site.\n\nEvery page on this site is also available as clean Markdown by appending `.md` to its URL."},"sections":[{"title":"Email API","description":"Sending, contacts, campaigns, statistics, webhooks and templating.","includeFiles":["docs/email-api/**/*.md"],"excludeFiles":[]},{"title":"Content API","description":"Manage templates, template contents, images, labels and tokens.","includeFiles":["docs/content-api/**/*.md","docs/content-api.md"],"excludeFiles":[]},{"title":"SMTP Relay","description":"Send email through Mailjet's SMTP servers.","includeFiles":["docs/smtp-relay/**/*.md"],"excludeFiles":[]},{"title":"API Reference","description":"Complete generated reference for every Mailjet API endpoint.","includeFiles":["openapi/openapi-mailjet.yaml","openapi/openapi-passport.yaml","docs/api-reference/**/*.md"],"excludeFiles":[]},{"title":"Migrating from Mandrill","description":"Guides for switching from Mandrill to Mailjet.","includeFiles":["docs/mandrill/**/*.md"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"templating-language-overview","__idx":0},"children":["Templating Language Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mailjet's template language allows you to push the boundaries of the personalisation of an email."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["More than just substitutions of a text, it lets you leverage conditions, loops, functions and multiple data sources."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["With the Mailjet's template language for transactional messages, designing and building dynamic emails, that can highly adapt to your recipients' profiles, has never been easier."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mailjet Template language is available for transactional messages only."," ","As Mailjet templating language is following a syntax close to the one used by the most popular template languages, such as ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://jinja.palletsprojects.com/en/stable/"},"children":["Jinja2"]}," or ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://twig.symfony.com/"},"children":["Twig"]},", it can be already familiar to you."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Go beyond simple personalization tags by adding logic into your email to include/remove sections of the delivered message."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Additionally, Mailjet's Template API allows you to store your templates on the Mailjet system. There is no need to provide the whole content of your message at each call to the Send API anymore, just use your predefined template."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can create your template, leveraging our template language, in multiple ways: either through ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.mailjet.com/products/email-marketing/email-editor/"},"children":["Passport"]}," - our drag and drop email design tool - ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://mjml.io/"},"children":["MJML"]}," - the open source responsive email framework we created - or even with simple HTML."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The syntax is:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"./code_snippets/temp_lang_overview1.html","language":"html","title":"HTML result","header":{"title":"HTML result","controls":{"copy":{}}},"lang":"html","source":"<html>\n  <body>\n    {% if data:age > 45 %}\n    <ul>\n      <li>{{data:age}}</li>\n    </ul>\n    {% endif %}\n  </body>\n</html>"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"templating-language-for-everyone-from-beginners-to-power-users","__idx":1},"children":["Templating language for everyone, from beginners to power users"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MJML and templating language, a superhero duo"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Today, flexibility and personalization are a must-have in the email industry. Transactional emails imply more and more complex business logic, and one can often struggle trying to juggle a lot of different templates, when they could just have one personalized email that adapts to several use cases. Having a separate template for men and another one for women, or creating specific campaigns to recommend different things based on your customer's previous purchases is not viable."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["It is in this kind of situations that a templating language comes in handy. OK, let’s be a bit naive and accept that you could write your own. But to be able to implement a tokenizer and a grammar, you need to have a good knowledge in the field and, at the end of the day, you might just be reinventing the wheel when you could have been focusing on your core business instead... You could instead use nice libraries such as ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://handlebarsjs.com/"},"children":["Handlebars"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://jinja.pocoo.org/"},"children":["Jinja"]}," or ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://twig.sensiolabs.org/"},"children":["Twig"]},", but then you’ll still need to write or host a dedicated service to handle the templating processing."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["So, let’s recap: MJML for producing responsive HTML emails without effort, plus a templating language to bring them to life with conditional blocks and variables. This combo can change your life as a developer."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["But, enough words, you’ll definitely want some action. You will find here four tutorials that will explain you step by step how to solve very common issues in template creation."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/tutorials/receipt"},"children":["How to create an e-receipt email template"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/tutorials/welcome"},"children":["How to create a welcome email template"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/tutorials/abandoned_cart"},"children":["How to create an abandoned cart email template"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/tutorials/digest"},"children":["How to create an digest email template"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"github-demos","__idx":2},"children":["Github Demos"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find some use case samples on ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples"},"children":["Github"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/all_in_one_transac/"},"children":["All in one transactional"]}," : one template rules all your simple transactional messages. Make it easy to manage a single canvas for all your messages"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/electronic_ticket/"},"children":["Mailjet Air Electronic ticket"]}," : depending on the destination, the seat class and booking of a car to the airport, the layout changes and offers specific call to actions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/question_answer/"},"children":["Question / Answers / Comment notifications"]}," : alerts for new question, comment and answer (Quandora like) with specific call to action depending on the alerts"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/ecommerce/"},"children":["All in one Ecommerce"]}," : one template to support all your order, payment, shipping... notifications."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/white_label/"},"children":["White label"]}," : handle several brands with one transactional template"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/rss_to_email/"},"children":["RSS to email"]}," : pull a RSS feed and send it by email (simple loop sample)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/products_list/"},"children":["Product list"]}," : simple product list (loop sample)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/zigzag_loop/"},"children":["Product list in zigzag"]}," : product list with alternative image side (loop sample)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-templating-samples/tree/master/samples/ecommerce_receipt/"},"children":["Ecommerce receipt"]}," : list of product purchased and total price of purchase (loop sample)"]}]}]},"headings":[{"value":"Templating Language Overview","id":"templating-language-overview","depth":1},{"value":"Templating language for everyone, from beginners to power users","id":"templating-language-for-everyone-from-beginners-to-power-users","depth":2},{"value":"Github Demos","id":"github-demos","depth":2}],"frontmatter":{"title":"Templating Language Overview","seo":{"description":"Mailjet templating language supports variables, conditions, loops, and multiple data sources for transactional emails, with syntax similar to Jinja2 and Twig.","title":"Templating Language Overview"}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/template_language/template_lang_overview","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}