Templates

Updating templates

To update existing message templates, you can use a PUT request to 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).

Note: Currently you can't update templates with the same name as a template that already exists in Whispir. You can overcome this by saving the updated template with a new name, and then either changing it back in a subsequent save, or retaining the updated name.

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 for others to understand its purpose.

responseTemplateId

String

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

See 11. Response rules [add link to heading called ‘11. 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 and landlines phones.

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 you 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 you to modify the push notification properties if these are configured in the company.

pushOptions:

  • notifications: enabled/disabled
  • escalationMins: # mins to await a push notifications response

Note: All of the options above are the same as provided in the /messages endpoint. See 7. Messages [add link to heading called '7. Messages'].

  • JSON
  • XML

Updating templates

The following API calls allow users to update template content using the Whispir API:

{{codeStart}}

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

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

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

Accept: application/vnd.whispir.template-v1+json

{

"messageTemplateName": "Sample SMS Template",

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

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

"subject": "Test SMS message",

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

"email" : {

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

"footer" : "This is the footer of my message

(generally where a signature would go)",

"type" : "text/plain"

},

"voice" : {

"header" : "This is the introduction,

read out prior to any key press",

"body" : "This is the body of the voice call,

read out after the key press",

"type" : "ConfCall:,

ConfAccountNo:,

ConfPinNo:,

ConfModPinNo:,

Pin:"

},

"web" : {

"body" : "This is the content of my web publishing

or rich push message",

"type" : "text/plain"

},

"social" : {

"social" : {

"id" : "social",

"body" : "Twitter content"

},

"social" : {

"id" : "social_long",

"body" : "Facebook content",

"type" : "text/plain"

}

},

"type" : "defaultNoReply",

"features" : {

"pushOptions" : {

"notifications" : "enabled",

"escalationMins" : "3"

}

}

}

{{codeEnd}}

The sample code above will update the message template specified by ID: C37DCBAEFF73FEDA45 within the default workspace.

The expected response to this call is a HTTP 204 - No Content response.