WhatsApp API

Last updated: January 06th, 2025

Send WhatsApp

Call this API to send a pre-defined WhatsApp message to specific phone number

If you need to send same WhatsApp message to 3 different number, call this API 3 times with different "to" parameter.

Endpoint:

https://api.esms.com.my/whatsapp/send

Method:

POST, supported content-type is JSON:

  • application/json; charset=utf-8

* charset behind is necessary when you're sending in Unicode messages, such as Chinese characters.

Parameters:
Name Type Required Description
user String Mandatory This would be your account's api key.
pass String Mandatory This would be your account's api secret.
to String Mandatory

The phone number of target recipient you'd like to send SMS to.

Phone number must be supplied along with country code.

Do not include any non-numeric character, eg: - ( ) or space.

Example: 60123456789

type String Mandatory

The type of predefined template.

Example: otp, feedback, eventConfirmation, eventReminder, shipment, or paymentDue

dlr Numeric Optional

Set to "1" if you'd like to receive DR report. Any other value would be ignored.

Example: 1

dlr-url String Optional

Specify your own DLR receiving endpoint to receive our DR report.

Parameter dlr must be set to 1 for this to take effect.

Example: https://www.yourownsite.com/dlrreceiver

[
  number,
  code,
  name,
  action,
  event,
  brand,
  date,
  time,
  venue,
  amount,
  link
]
String Optional

These are optional depending on the type field, at least a field is mandatory for each type, refer to request sample for details.

Response:

Response would be returned in application/json format.

An example of Successful response would be:

{"status":0,"creditDeducted":1,"message":"ok","id":"88ce9c6e-1707-41b8-95a2-91d228001fc7","parts":1,"type":9}

An example of Failed response would be:

{"status":9,"message":"Invalid phone number, please do not include any non-numeric character","id":"c8d6bb1c-bff6-47d5-9e01-dc2596bbdbe7"}

Name Type Description
status Numeric Status code of the request, kindly refer to below Status mapping table for more details
message String A short description of given status, for more information you may contact our support team at support@esms.com.my
id String ID of this particular request, you may want to keep this ID in your own table for future reference, our DR would be based on this ID.
creditDeducted Numeric The total credit amount deducted from your account.
parts Numeric To show how many parts of WhatsApp this message requires, its usually 1 for WhatsApp.
type Numeric

Type of this message, its usually 9 for WhatsApp.

Response Status Code:
Status Code Description
0Success.
1Insufficient parameters
Please make sure all mandatory parameter exists.
2Invalid calling IP
You are getting this error because you've previously requested your account to be able to call only from certain IP, and you're not calling from the designated IP.
3Invalid username/password combination.
If you believe this is an error, kindly contact our support team at support@esms.com.my.
4Invalid country code
The country code of the phone number you provides is not recognized.
For Malaysia recipients, do remember to send to 60123456789 instead of 0123456789.
5Insufficient credits
Contact your account manager for reload procedures.
6Internal error
You may retry again shortly.
9Invalid "to" parameter
Please include only numeric in "to" parameter
For example, please send 60123456789 instead of 60-12 345 6789
Request Sample:
Type and Request Body Sample of received content

Authentication OTP

{
    "user": "{{user}}",
    "pass": "{{pass}}",
    "type":"otp",
    "to": "60123456789",
    "code": "123456"
}

Feedback Survey Form

{
    "user": "{{user}}",
    "pass": "{{pass}}",
    "type": "feedback",
    "to": "60123456789",
    "name": "John",
    "action": "purchase",
    "link": "https://www.surveymonkey.com/mp/survey-templates/"
}

Event RSVP Confirmation

{
    "user": "{{user}}",
    "pass": "{{pass}}",
    "type": "eventConfirmation",
    "to": "60123456789",
    "event": "Annual Dinner",
    "brand": "Doll Plt"
}

Event Reminder

{
    "user": "{{user}}",
    "pass": "{{pass}}",
    "type": "eventReminder",
    "to": "60123456789",
    "event": "Annual Dinner",
    "name": "Doll Plt",
    "date": "01/01/2025",
    "time": "6pm",
    "venue": "Pavilion KL"
}

Shipment Update

{
    "user": "{{user}}",
    "pass": "{{pass}}",
    "type": "shipment",
    "to": "60123456789",
    "name": "John",
    "number": "31325",
    "venue": "warehouse",
    "code": "T12323",
    "link": "https://tracking.my/gdex/T12323"
}

Payment Due

{
    "user": "{{user}}",
    "pass": "{{pass}}",
    "type": "paymentDue",
    "to": "60123456789",
    "name": "John",
    "amount": "RM 123,45",
    "brand": "XX Plan 24 Month",
    "number": "1234",
    "date": "31/01/25",
    "event": "service disruption",
    "link": "https://www.paypal.com/my/home"
}