Using templates

We learnt during this section how to create, retrieve, update and delete a Template. It is now time to start sending Messages using them

Whispir templates can be called in two different ways:

  • by messageTemplateId
  • by messageTemplateName

NOTE: please notice that we will be using the Templates to send Messages, so pay attention to the changes in the API endpoints and in the JSON/XML Headers used for this purpose

  • JSON
  • XML

Using templates by messageTemplateId

{{codeStart}}

# To send a Message based on a Template Message saved in a User-defined workspace

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

# To send a Message based on a Template Message saved in the default workspace

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

 

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

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

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

 

{

"to" : "61400400400",

"messageTemplateId" : "BACEB8D46BEF5315"

}

{{codeEnd}}

Using templates by messageTemplateName

{{codeStart}}

# To send a Message based on a Template Message saved in a User-defined workspace

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

# To send a Message based on a Template Message saved in the default workspace

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

 

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

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

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

 

{

"to" : "61400400400",

"messageTemplateName" : "Sample SMS Template"

}

{{codeEnd}}

Sample Response

202 - Accepted