Creating templates

  • JSON
  • XML

Creating templates

The following API call will generate a message Template for the SMS channel

{{codeStart}}

# To save the Template in a User-defined workspace

POST https://api.<region>.whispir.com/workspaces/:workspace_id/templates

# To save the Template in the default workspace

POST https://api.<region>.whispir.com/templates

 

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",

"subject" : "Test SMS Message",

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

"email" : {},

"voice" : {},

"web" : {}

}

{{codeEnd}}

Request Body Details

messageTemplateName

(required)

String

Specifies the name of the message template to be stored

subject

(required)

String

Specifies the subject of the email message and the first part after the recipient accepts to listen to the message delivered via voice call. Independently from playing an active role or not in your selected channel[s], it MUST be sent along with the request and its value canNOT be left empty

body

(required)

String

The first one in the payload above under subject represents the content of the SMS. Every channel [SMS, email, etc] though presents a body field and - in order for a Template to be valid - at least one of them must be populated

messageTemplateDescription

String

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

responseTemplateId

String

Specifies the ID of the Response Rule that should be associated with this message template. Do not insert in the payload when unused

See Response rules for more information.

email

Object

Email object, as described in the Email Messages section. If the email is not required, you can either present an empty object or omit it

voice

Object

Voice object, as described in the Voice Messages section. If no Voice Message is required, you can either present an empty object or omit it

web

Object

Web object, as described in the Web and Social Publishing section. If there is no web content to be published, you can either present an empty object or omit it

social

Object

Social object, as described in the Web and Social Publishing section. If there is no Social content to be published, you can either present an empty object or omit it

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.

Sample Response

201 - Created

In this case the Location header in the Response Headers will show the direct link to the template. Depending on the endpoint of choice we will respectively have:

https://api.<region>.whispir.com/workspaces/:workspace_id/templates/:template_id

https://api.<region>.whispir.com/templates/:template_id

NOTE: if the Location Header containing the template_id wasn't collected at the time of sending please refer to Retrieving Templates

  • JSON
  • XML

{{codeStart}}

{

"messageTemplateName": "Sample SMS Template",

"subject": "Test SMS Message",

"tags": "",

"dlr": {

"period": "",

"rule": "",

"type": "",

"publishToWeb": false,

"expiryDay": 0,

"expiryHour": 0,

"expiryMin": 0,

"feedIds": "",

"bool": false

},

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

"type": "default",

"email": {

"type": "",

"body": "",

"footer": ""

},

"web": {

"type": "",

"body": ""

},

"voice": {},

"responseTemplateId": "",

"id": "4B7C9E1223F3B191",

"link": [

{

"uri": "https://api.au.whispir.com/workspaces/5E89F4525738D415/templates/4B7C9E1223F3B191",

"rel": "self",

"method": "GET",

"host": "api.au.whispir.com",

"port": -1

},

{

"uri": "https://api.au.whispir.com/workspaces/5E89F4525738D415/templates/4B7C9E1223F3B191",

"rel": "updateTemplate",

"method": "PUT",

"host": "api.au.whispir.com",

"port": -1

},

{

"uri": "https://api.au.whispir.com/workspaces/5E89F4525738D415/templates/4B7C9E1223F3B191",

"rel": "deleteTemplate",

"method": "DELETE",

"host": "api.au.whispir.com",

"port": -1

}

]

}

{{codeEnd}}