Send a Template

You can use the "Send template" API anytime you want to send a message to a client if it is more than 24 hours since client's last message, or if you send a message to a new client. you can even send the template during the 24 hours session time if you wish.


More Remarks

  • You can only send template messages to private people, not groups.

  • If you send a template message to the client, and the client did not reply yet, and you want to send another message to him, you must use the template message again.

  • The billing is per "conversation". conversation means a 24 hours session between you and the client (this 24 hours conversation session is unrelated to the 24 hours timer for template message).

  • You can send unlimited template messages within the 24 hours session time of a conversation.

  • 24 hours session conversation starts when you send a message to the client.

  • Every time the user replies, the template message session resets. which means that you don't have to use template message during this 24 hours template message session.

  • If your template has variables, you must provide all variables data (inside bodyVariable parameter).

  • The entire template body + variables should not exceed 1024 characters.


Settings:

URL

https://api.99digital.co.il/whatsapp/v2/sendTemplate

Method

JSON via POST


Body:


Parameter

Description / Example

Mandatory

apiKey

Your API key for the service

yes

from

your WhatsApp account. international number without +. for example: 972771234567

yes

to

The number you want to send the message to. for example: 972501234567

yes

name

The template name

yes

headerType

1 for none, 3 for image, 4 for video, 5 for document

yes

headerLink

in case you used image/video/document header, this is the link for image or video or document

limitation:

image - 5 MB

document - 100 MB

video - 16 MB

only if you used 3/4/5 as headerType

bodyVariable1-10

in case you used variables {{1}} to {{10}} with your body when submitting the template, this is where you provide them. Each item as a variable (1 to 10), not array. 

Two important rules:

1. you can not use \n new line inside a variable.

2. you can not use 4 or more consecutive spaces inside a variable

only if you used variables in the 'body'

websiteVariable

in case you used call to action button, and you chose dynamic "website" with variable {{1}} there is where you use it. you should put the variable information, not the full website address.

no

websiteVariable2

in case you used second website for call to action button, and you used dynamic variable. this is where you provide the {{1}} for the second website. you should put the variable information, not the full website address.

no

couponCode

in case you used coupon code in the template, here you put the code. 15 digits maximum.

no

couponExpiration

in case you used coupon code in the template, and set 'true' for code expiration, here you put the GMT timestamp (seconds) for the date and time that the code will no longer be available.bare in mind that for Israel time you must add GMT+2 or GMT+3

no

pdfFilename

In case you used headerType as document, and provided a document link in headerLink, here you can put the filename that will show for the end user when receiving the PDF file.

Priority:

1. if 'pdfFilename' is provided, it will be used.

2. if 'pdfFilename' is not provided by you, we will use the pdf file name from the headerLink URL directly.

3. if the headerLink filename is not available for any reason, we will put the default text: "קובץ מצורף - לחץ כאן"

no

showRequest

You can get back in the response an object with all the request you sent (without the 'apiKey')

default is off (0)

1 - enable

no

otp

If your template is authentication template, here is where you provide the code

maximum 15 characters 

(can be a combination of numbers, letters, special characters etc)

note: authentication template can only be visible from a mobile phone. if the end user is using WhatsApp Web, the code will not be available for him

Only if authentication template is used

localStorage

Whenever you provide headerLink url, we deliver this URL to WhatsApp. They download the link in order to deliver it with your template.

If for any reason your file link is not accessible by Meta and open to the internet, you can request us to download the image and provide WhatsApp with alternative url to use, and not your own.


This will download the file, save it in our servers locally, deliver a new link for WhatsApp to use and then remove the file instantly.

default value is - 0 (disable)

enable - 1

** please note that using this feature may delay the response back from our server due to the operation described above.

no


Body example:

On create a template page, on the first example, we created a template named "website_welcome" , in English, without header, and 6 variables in the body that looks like this:

"*Hello {{1}}* and thank you for joining our exclusive website store!\nOur company has many secrets to discover.\nFor future connection, we received your phone number: {{2}} and your email address: {{3}}.\nYou can find shirts, hats, shoes and gloves at discounted prices. Hold on, wait a minute, i found something interesting! just for this week we offer: {{4}} at discounted price: {{5}} only when you buy it online or in-store shop at: {{6}}.\nWhat would you like to discover?".

This is how you should send the template to your customer:


{
"apiKey": "your-api-key",
"from": "972501234567",
"to": "972509876543",
"name": "website_welcome",
"headerType": 1,
"bodyVariable1": "John",
"bodyVariable2": "0509876543",
"bodyVariable3": "john@example.com",
"bodyVariable4": "Shoes and Hats",
"bodyVariable5": "50% off",
"bodyVariable6": "Israel",
"showRequest": 0
}


Another body example:

For a template named "website_signup_image_logo", in Hebrew, with image header, and 2 variables in the body that looks like this:

תודה שהצטרפת אלינו.

קוד הכניסה שלך הוא: {{1}}

אנחנו רוצים להודות לך ולברך אותך בברכת התחלה חדשה.

בברכה, צוות {{2}}


and the request will look like this:

{
"apiKey": "your-api-key",
"from": "972501234567",
"to": "972509876543",
"name": "website_signup_image_logo",
"headerType": 3,
"headerLink": "https link to jpg file",
"bodyVariable1": "43143",
"bodyVariable2": "קידום אתרים"
}



Response:

{
"status": "OK",
"unique": "65dfd4r4dref34rdfxd34r",
"timestamp": 1600115719,
"from": "972507654321",
"to": "972501234567",
"body": "Hello John Thank you for joining our exclusive website",
"templateTimeLeft": "400",
"conversationTimeLeft": "800",
"reason": 1 
}

Response-Explain:

Parameter

Description

status

OK or FAIL

**Note: OK status doesn't mean the message arrived to the end user. it only means that the system received your request.

You should listen to webhooks to see the status of your message.

unique

unique ID for any message

timestamp

time stamp

from

your WhatsApp account

to

the number that the message was sent to

body

the BODY of the template, including the variables

templateTimeLeft

amount of minutes left since client's last message. if passed, you must use Template Message. This value resets every time the client is sending you a message.

Even though you sent a template now, if the templateTimeLeft value is more than 0, it means that you don't have to use a template.

originalRequest

original request object, if you enabled this in 'showRequest' when sending the request.

reason

'reason' is the status explanation in case of FAIL

1

not FAIL. the status is OK

2

Your "from" number account does not exist

3

wrong apiKey

4

 'to' is either empty or wrong number format or WhatsApp number does not exist

6

WhatsApp error or template rejected

12

Template name does not exist

14

headerLink is mandatory for your template

15

You must provide headerVariable for this template, without special characters such as **

17

bodyVariable must be equal to the number of variables used when creating the template, and must not be empty.

18

You must provide websiteVariable for this template

19

The template you created is too long (more than 1024), create another one

20

The template needs a coupon code / expiration time or the coupon code / expiration time is too long or invalid

21

WhatsApp has rejected the sending of the template due to high volume sending. please try to send again.

22

rate limit error, try again

23

otp is required for authentication template and must not exceed 15 characters

24

When localStorage is used, the headerLink provided is inconnrect or access denied