Grow with us: Join Postmark's new referral partner program and start earning
x

How do I use a template alias?

By default, all templates include an alias. If you wish to reference a template by an alias instead of its Template ID, you can set the exact alias that you want to use and then reference that in your API call to send an email with the template. You can choose a template's alias using Postmark's UI or Templates API.

Set an alias using Postmark's UI

  1. Open the template you want to set an alias for.
  2. While viewing the template, click on the current alias.
  3. Edit the alias for your template to use for referencing when sending (i.e., welcome_new).

Note: Be sure to update your integration codebase that sends using the alias, if you ever change an existing alias.

Creating a template alias

Set an alias using the Templates API

To set an alias, edit the template using a PUT call to https://api.postmarkapp.com/templates/{templateIdOrAlias} with the alias you want to set included in the body:

{
  "Name": "Template Name"
  "Alias":"my-alias" 
}

Once you have your alias set, you can now use it to send an email with that template. You will still send the request to send to the same endpoint but instead of including a “TemplateId” field for identifying the template, you will use your alias for the template in a “TemplateAlias” field, like this:

{
  "TemplateAlias": "my-alias",   
  "TemplateModel": {     
    "user_name": "John Smith",
    "company": {       
      "name": "ACME"
    }   
  },   
  "From": "sender@example.com",
  "To": "receiver@example.com" 
}
Last updated June 11th, 2020

Still need some help?

Our customer success team has your back!