Every message template you define can be customized for the recipient using variables. This makes it very easy to send everyone personalized messages. Announcements and notifications sent by your application will be significantly more engaging if they are targeted at a specific recipient instead of being intentionally left generic for mass-mailing purposes.

Message variable is defined by wrapping a word in doubled curly braces like {{name}} or {{profile_url}}. Anywhere in your message, either HTML or plain-text, you can define variables where you would otherwise be putting content. For instance, instead of putting “Dear user,” you could replace this with “Dear {{name}},” and send through the user’s name as one of the variables in the API call. Like so:

  {
    "api_key" : "PROJECT_API_KEY",
    "uid" : "27cf6ede7501a32d54d22abe17e3c154d2cae7f3",
    "arguments" : {
      "recipients" : {
        "recipient_1@example.com" : {
          "name" : "John Doe",
          "status" : "awesome"
        },
        "recipient_2@example.com" : {
          "name" : "Bob Bobowich",
          "status" : "great"
        }
      },
      "content" : "Hello, {{name}}. You are {{status}}. Sincerely {{company}}.",
      "variables" : {
        "company" : "PostageApp"
      }
    }
  }

From the above example two recipients will receive emails with the following content:

Hello, John Doe. You are awesome. Sincerely PostageApp.

and

Hello, Bob Bobowich. You are great. Sincerely PostageApp.

Although the name of the variable should consist entirely of of letters, numbers and underscores, the content of the variable sent via the API call is not restricted. Keep in mind that the same content is substituted for all instances of this variable in both plain-text and HTML versions.

NOTE: The variable name must be in all lower caps. As of right now, camel case (varName) does not seem to work with Message Variables, but a fix will be made soon.