{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab"]},"type":"markdown"},"seo":{"title":"Create a Template - Mailjet Email API","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Create reusable email templates via POST /template with parameters like Name, Locale, and OwnerType, then reference them by ID at send time to save content.","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":"create-a-template","__idx":0},"children":["Create a Template"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Email templates are prewritten / preformatted emails, which are used to quickly send messages to your recipients. This helps you save time when needing to reuse content - instead of adding the email content every time, you can just reference the template ID."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can create a template using our ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://app.mailjet.com/templates/marketing"},"children":["Email Editor"]},". To create a template via the API, use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /template"]},"."]},{"$$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":"curl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/template \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"Author\":\"John Doe\",\n      \"Categories\":\"array\",\n      \"Copyright\":\"Mailjet\",\n      \"Description\":\"Used to send out promo codes.\",\n      \"EditMode\":\"1\",\n      \"IsStarred\":\"false\",\n      \"IsTextPartGenerationEnabled\":\"true\",\n      \"Locale\":\"en_US\",\n      \"Name\":\"Promo Codes\",\n      \"OwnerType\":\"user\",\n      \"Presets\":\"string\",\n      \"Purposes\":\"array\"\n\t}'\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\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3']);\n$body = [\n  'Author' => \"John Doe\",\n  'Categories' => \"array\",\n  'Copyright' => \"Mailjet\",\n  'Description' => \"Used to send out promo codes.\",\n  'EditMode' => \"1\",\n  'IsStarred' => \"false\",\n  'IsTextPartGenerationEnabled' => \"true\",\n  'Locale' => \"en_US\",\n  'Name' => \"Promo Codes\",\n  'OwnerType' => \"user\",\n  'Presets' => \"string\",\n  'Purposes' => \"array\"\n];\n$response = $mj->post(Resources::$Template, ['body' => $body]);\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":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"template\", {'version': 'v3'})\n\t.request({\n      \"Author\":\"John Doe\",\n      \"Categories\":\"array\",\n      \"Copyright\":\"Mailjet\",\n      \"Description\":\"Used to send out promo codes.\",\n      \"EditMode\":\"1\",\n      \"IsStarred\":\"false\",\n      \"IsTextPartGenerationEnabled\":\"true\",\n      \"Locale\":\"en_US\",\n      \"Name\":\"Promo Codes\",\n      \"OwnerType\":\"user\",\n      \"Presets\":\"string\",\n      \"Purposes\":\"array\"\n    })\nrequest\n\t.then((result) => {\n\t\tconsole.log(result.body)\n\t})\n\t.catch((err) => {\n\t\tconsole.log(err.statusCode)\n\t})\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":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3\"\nend\nvariable = Mailjet::Template.create(\n  author: \"John Doe\",\n  categories: \"array\",\n  copyright: \"Mailjet\",\n  description: \"Used to send out promo codes.\",\n  edit_mode: \"1\",\n  is_starred: \"false\",\n  is_text_part_generation_enabled: \"true\",\n  locale: \"en_US\",\n  name: \"Promo Codes\",\n  owner_type: \"user\",\n  presets: \"string\",\n  purposes: \"array\"\n)\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":"from 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), version='v3')\ndata = {\n  'Author': \"John Doe\",\n  'Categories': \"array\",\n  'Copyright': \"Mailjet\",\n  'Description': \"Used to send out promo codes.\",\n  'EditMode': \"1\",\n  'IsStarred': \"false\",\n  'IsTextPartGenerationEnabled': \"true\",\n  'Locale': \"en_US\",\n  'Name': \"Promo Codes\",\n  'OwnerType': \"user\",\n  'Presets': \"string\",\n  'Purposes': \"array\"\n}\nresult = mailjet.template.create(data=data)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.ClientOptions;\nimport com.mailjet.client.resource.Template;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"), new ClientOptions(\"v3\"));\n      request = new MailjetRequest(Template.resource)\n            .property(Template.AUTHOR, \"John Doe\")\n            .property(Template.CATEGORIES, \"array\")\n            .property(Template.COPYRIGHT, \"Mailjet\")\n            .property(Template.DESCRIPTION, \"Used to send out promo codes.\")\n            .property(Template.EDITMODE, \"1\")\n            .property(Template.ISSTARRED, \"false\")\n            .property(Template.ISTEXTPARTGENERATIONENABLED, \"true\")\n            .property(Template.LOCALE, \"en_US\")\n            .property(Template.NAME, \"Promo Codes\")\n            .property(Template.OWNERTYPE, \"user\")\n            .property(Template.PRESETS, \"string\")\n            .property(Template.PURPOSES, \"array\")\n      );\n      response = client.post(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"package main\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\tmailjet \"github.com/mailjet/mailjet-apiv3-go\"\n\t\"github.com/mailjet/mailjet-apiv3-go/resources\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tvar data []resources.Template\n\tmr := &Request{\n\t  Resource: \"template\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.Template { \n\t  Author:\"John Doe\",\n\t  Categories:\"array\",\n\t  Copyright:\"Mailjet\",\n\t  Description:\"Used to send out promo codes.\",\n\t  EditMode:\"1\",\n\t  IsStarred:\"false\",\n\t  IsTextPartGenerationEnabled:\"true\",\n\t  Locale:\"en_US\",\n\t  Name:\"Promo Codes\",\n\t  OwnerType:\"user\",\n\t  Presets:\"string\",\n\t  Purposes:\"array\"\n      }\n\t}\n\terr := mailjetClient.Post(fmr, &data)\n\tif err != nil {\n\t  fmt.Println(err)\n\t}\n\tfmt.Printf(\"Data array: %+v\\n\", data)\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"))\n         {\n            Version = ApiVersion.V3,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Template.Resource,\n         }\n             .Property(Template.Author, \"John Doe\")\n             .Property(Template.Categories, \"array\")\n             .Property(Template.Copyright, \"Mailjet\")\n             .Property(Template.Description, \"Used to send out promo codes.\")\n             .Property(Template.EditMode, \"1\")\n             .Property(Template.IsStarred, \"false\")\n             .Property(Template.IsTextPartGenerationEnabled, \"true\")\n             .Property(Template.Locale, \"en_US\")\n             .Property(Template.Name, \"Promo Codes\")\n             .Property(Template.OwnerType, \"user\")\n             .Property(Template.Presets, \"string\")\n             .Property(Template.Purposes, \"array\");\n         MailjetResponse response = await client.PostAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To add the email content, use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /template/{template_ID}/detailcontent"]},". Keep in mind that the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]}," request will reset the values of all properties not specified in the payload to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]},". If you have already set a value to a property (e.g. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Html-part"]},") and want to keep it while setting the value of another (e.g. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Text-part"]},"), use a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," request instead."]},{"$$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":"curl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/template/$template_ID/detailcontent \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"Headers\":\"\",\n      \"Html-part\":\"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n      \"MJMLContent\":\"\",\n      \"Text-part\":\"Dear passenger, welcome to Mailjet! May the delivery force be with you!\"\n\t}'\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\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3']);\n$body = [\n  'Headers' => \"\",\n  'Html-part' => \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n  'MJMLContent' => \"\",\n  'Text-part' => \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\"\n];\n$response = $mj->post(Resources::$TemplateDetailcontent, ['id' => $id, 'body' => $body]);\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":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"template\", {'version': 'v3'})\n\t.id($template_ID)\n\t.action(\"detailcontent\")\n\t.request({\n      \"Headers\":\"\",\n      \"Html-part\":\"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n      \"MJMLContent\":\"\",\n      \"Text-part\":\"Dear passenger, welcome to Mailjet! May the delivery force be with you!\"\n    })\nrequest\n\t.then((result) => {\n\t\tconsole.log(result.body)\n\t})\n\t.catch((err) => {\n\t\tconsole.log(err.statusCode)\n\t})\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":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3\"\nend\nvariable = Mailjet::Template_detailcontent.create(id: $template_ID,\n  headers: \"\",\n  html_part: \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n  mjmlcontent: \"\",\n  text_part: \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\"\n)\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":"from 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), version='v3')\nid = '$template_ID'\ndata = {\n  'Headers': \"\",\n  'Html-part': \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n  'MJMLContent': \"\",\n  'Text-part': \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\"\n}\nresult = mailjet.template_detailcontent.create(id=id, data=data)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.ClientOptions;\nimport com.mailjet.client.resource.TemplateDetailcontent;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"), new ClientOptions(\"v3\"));\n      request = new MailjetRequest(TemplateDetailcontent.resource, ID)\n            .property(TemplateDetailcontent.HEADERS, )\n            .property(TemplateDetailcontent.HTMLPART, \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\")\n            .property(TemplateDetailcontent.MJMLCONTENT, )\n            .property(TemplateDetailcontent.TEXTPART, \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\")\n      );\n      response = client.post(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"package main\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\tmailjet \"github.com/mailjet/mailjet-apiv3-go\"\n\t\"github.com/mailjet/mailjet-apiv3-go/resources\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tvar data []resources.TemplateDetailcontent\n\tmr := &Request{\n\t  Resource: \"template\",\n\t  ID: RESOURCE_ID,\n\t  Action: \"detailcontent\",\n\t}\n\tfmr := &FullRequest{\n\t  Info: mr,\n\t  Payload: &resources.TemplateDetailcontent { \n\t  Headers:\"\",\n\t  Html-part:\"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n\t  MJMLContent:\"\",\n\t  Text-part:\"Dear passenger, welcome to Mailjet! May the delivery force be with you!\"\n      }\n\t}\n\terr := mailjetClient.Post(fmr, &data)\n\tif err != nil {\n\t  fmt.Println(err)\n\t}\n\tfmt.Printf(\"Data array: %+v\\n\", data)\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"))\n         {\n            Version = ApiVersion.V3,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = TemplateDetailcontent.Resource,\n            ResourceId = ResourceId.Numeric(ID)\n         }\n             .Property(TemplateDetailcontent.Headers, )\n             .Property(TemplateDetailcontent.Htmlpart, \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\")\n             .Property(TemplateDetailcontent.MJMLContent, )\n             .Property(TemplateDetailcontent.Textpart, \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\");\n         MailjetResponse response = await client.PostAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Headers"]}," to specify your sender and/or reply-to addresses, as well as the Subject line of your email."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response-example","__idx":1},"children":["API Response Example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"From\": \"\\\"Mailjet pilot\\\" <pilot@mailjet.com>\",\n  \"Subject\": \"Welcome\",\n  \"Reply-to\": \"copilot@mailjet.com\"\n}\n"},"children":[]}]},"headings":[{"value":"Create a Template","id":"create-a-template","depth":1},{"value":"API Response Example","id":"api-response-example","depth":3}],"frontmatter":{"title":"Mailjet Email API","seo":{"title":"Create a Template - Mailjet Email API","description":"Create reusable email templates via POST /template with parameters like Name, Locale, and OwnerType, then reference them by ID at send time to save content."}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/email-templates/create-template","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}