Templates

Creating templates

To create a new message template you can use the /templates endpoint.

The following fields are required:

  • messageTemplateName: The name of the template to be stored.
  • subject: The first line or identifier of the SMS.
  • body: At least one of the Body fields must be populated (SMS, email, voice or web).
  • email: The email content for the message. If no email is required, an empty object must be presented.
  • voice: The voice content for the message. If no voice call is required, an empty object must be presented.
  • web: The web content for the message. If no web content is required, an empty object must be presented.

High-level request elements

messageTemplateName

String

Specifies the name of the message template to be used within message requests.

messageTemplateDescription

String

Specifies the description of the message template so others can understand its purpose.

responseTemplateId

String

Specifies the ID of the response rule that should be associated with this message template.

See Response rules for more information.

subject

String

Specifies the first line of the SMS message or voice call, and the subject of the email message.

body

String

Specifies the content of the SMS message.

email

Object

Email object described below. Used for sending email messages.

voice

Object

Voice object described below. Used for sending voice calls to mobile phones and landlines.

web

Object

Web object described below. Used for web publishing and rich messages.

social

Object

Social object described below. Used for publishing content to social media (Twitter, Facebook, LinkedIn).

type

String

Allows the user to modify the message behaviour for replies and DLRs (delivery receipts). For example:

  • defaultNoReply: Used to reject any replies to this message.
  • noDlr: Used to specify that DLRs should not be enabled for this message.

features

Object

Allows the user to modify the push notifications properties if these are configured in the company.

pushOptions:

  • notifications: Enabled/disabled.
  • escalationMins: Number of minutes to wait for a push notification response.

Note: All the options above are the same as provided in the /messages endpoint. See Messages.

  • JSON
  • XML

Creating templates

The following API calls allow users to manage templates using the Whispir API:

{{codeStart}}

HTTP 1.1 POST https://api.<region>.whispir.com/templates?apikey=[your_key]

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

Content-Type: application/vnd.whispir.template-v1+json

{

"messageTemplateName": "Sample SMS Template",

"messageTemplateDescription": "Template to provide an example on developers.whispir.com",

"subject" : "Test SMS Message",

"body" : "This is the body of my test SMS message",

"email" : {},

"voice" : {},

"web" : {}

}

{{codeEnd}}

The sample code above will create a simple SMS-only message template within the default workspace.

The expected response to this call is a HTTP 201 - Created response.