Using a template alias

Refer to a template using its alias instead of name or id


If you wish to reference a template by an alias instead of its id, you can set the exact alias you want by replacing its default alias and then referencing that in your API call to send a message with the template. You can set a template's alias in the Dashboard or using the Message templates API.

To reference a template by its alias, the alias must be unique per workspace.

Setting an alias using the Dashboard

  1. Open the template whose alias you want to set.
  2. Click on the Alias input and provide the desired name (e.g. otp_v2).

images-messages-templates-aliases

Setting an alias using the Message Template API

You can set an alias when creating a template using the Create message template API or you can use the Update message template API for existing templates.

A message template alias only allows alphanumeric characters, hyphens (-) or underscores (_). For example, otp-V2 is allowed but otp:V2 or OTP v2 are not.

Using template alias when sending a message

You can use a message template alias when sending a message via the Send a message API or the Send bulk messages API.

For example:

{
  "to": "+254722000000",
  "template": {
    "alias": "counseling_promo",
    "model": {
      "student": {
        "name": "John"
      }
    }
  },
  "stream": "marketing"
}