{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/template_language/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab"]},"type":"markdown"},"seo":{"title":"Send a stored Template","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Use TemplateID in a Mailjet Send API payload to reference a stored template, avoiding repeated full message content on every API call.","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":"send-a-stored-template","__idx":0},"children":["Send a stored Template"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the TemplateID property in your Send API payload to specify the ID of the template you created."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\ncurl -s \\\n\t-X GET \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/campaigndraft/$ID/schedule\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nView : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$response = $mj->get(Resources::$CampaigndraftSchedule, ['id' => $id]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n *\n */\nconst mailjet = require('node-mailjet').connect(\n  process.env.MJ_APIKEY_PUBLIC,\n  process.env.MJ_APIKEY_PRIVATE\n)\nconst request = mailjet\n  .get('campaigndraft')\n  .id($ID)\n  .action('schedule')\n  .request()\nrequest\n  .then(result => {\n    console.log(result.body)\n  })\n  .catch(err => {\n    console.log(err.statusCode)\n  })\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\nrequire 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\nend\nvariable = Mailjet::Campaigndraft_schedule.find($ID)\np variable.attributes['Data']\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nView : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n\"\"\"\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\nid = '$ID'\nresult = mailjet.campaigndraft_schedule.get(id=id)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"templates-error-management","__idx":1},"children":["Templates error management"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Send API offers two payload properties to allow error management:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TemplateErrorReporting"]},": Email Address where a message with the error description is sent to."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["blocked"]}," status in the Mailjet statistics."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If an error occurs when the template error reporting is enabled, a message from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["templating-language-error@mailjet.com"]}," with subject ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["^start"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nView : CampaizefgnDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resdfsources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$response = $mj->get(Resources::$CampaigndraftSchedule, ['id' => $id]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\ncurl -s \\\n\t-X GET \\\n\t--user \"$MsdfJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/campaigndraft/$ID/schedule\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nView : CampaizefgnDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resdfsources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$response = $mj->get(Resources::$CampaigndraftSchedule, ['id' => $id]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n *\n */\nconst mailjet = require('node-mailjet').connect(\n  process.env.MJ_APIKEY_PUBLIC,\n  process.env.MJ_sdfPIKEY_PRIVATE\n)\nconst request = mailjet\n  .get('campaigndraft')\n  .id($ID)\n  .action('schedule')\n  .request()\nrequest\n  .then(result => {\n    console.log(result.body)\n  })\n  .catch(err => {\n    console.log(err.statusCode)\n  })\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\nrequire 'mailjet'\nMailjet.configure dogsdf |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\nend\nvariable = Mailjet::Campaigndraft_schedule.find($ID)\np variable.attributes['Data']\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nView : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n\"\"\"\nfrom mailjsdfet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\nid = '$ID'\nresult = mailjet.campaigndraft_schedule.get(id=id)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n *\n */\nconst mailjet = require('node-mailjet').connect(\n  process.env.MJ_APIKEY_PUBLIC,\n  process.env.MJ_sdfPIKEY_PRIVATE\n)\nconst request = mailjet\n  .get('campaigndraft')\n  .id($ID)\n  .action('schedule')\n  .request()\nrequest\n  .then(result => {\n    console.log(result.body)\n  })\n  .catch(err => {\n    console.log(err.statusCode)\n  })\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# View : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\nrequire 'mailjet'\nMailjet.configure dogsdf |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\nend\nvariable = Mailjet::Campaigndraft_schedule.find($ID)\np variable.attributes['Data']\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nView : CampaignDraft data. Newsletter and CampaignDraft objects are differentiated by the EditMode values.\n\"\"\"\nfrom mailjsdfet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\nid = '$ID'\nresult = mailjet.campaigndraft_schedule.get(id=id)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["^end"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"common-templating-errors","__idx":2},"children":["Common templating errors"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expression parsing error ## Unknown identifier: var:day ## near ## {{var:day ##"]}," : This error indicates that the \"day\" variable is not defined in your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expression parsing error ## Unknown identifier: day ## near ## {{day ##"]}," : This error is similar to the previous one, except for the absence of namespace (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["var"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data"]},"). It can indicates that you forgot to specify whether you want to use a Send API variable ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["var:day"]}," or a contact property ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data:day"]},". It can also indicate that you are trying to use a template variable that is neither define in a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["set"]}," function nor a loop statement."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["not valid template ## near ## y}}</html> ##"]}," : This error occurs when the statement is not finished - missing {% endif %}"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"var:day\" is not an array value"]}," : This error is generally returned when you try to loop on a non-array value."]}]}]},"headings":[{"value":"Send a stored Template","id":"send-a-stored-template","depth":1},{"value":"Templates error management","id":"templates-error-management","depth":2},{"value":"Common templating errors","id":"common-templating-errors","depth":3}],"frontmatter":{"title":"Templating Language Send Stored Template","seo":{"description":"Use TemplateID in a Mailjet Send API payload to reference a stored template, avoiding repeated full message content on every API call.","title":"Send a stored Template"}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/template_language/using-template-with-send-api/send_stored_template","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}