Documentation API Gateway

Last Update: 28 January 2021

Welcome Back

Intro

WABLAS is WhatsApp API gateway service for sending and receiving messages, notification, scheduler, reminder, group message, tracking, and chatbots with simple integration for your business

Our API was designed to be extremely easy to use and accessible to everyone, no matter the programing language or frameworks you use

Step 1: Whatsapp Number Verification for Sender

  1. Select Device menu then click Scan QR Code Icon.
  2. Please wait a moment, the qr code image will appear immediately. then you can do a scan with the whatsapp application
  3. Please wait about 5 minutes, You will get a WhatsApp notification if your device is connected to Wablas.
  4. If you successfully scan the QR Code and after 5 minutes can't connected, please contact us (IT support).
  5. If the service is active you can send text messages or images, with the API that we have provided.

Note:

  1. Prohibited from accessing the website https://web.whatsapp.com
  2. If you log out of your WhatsApp application or change WhatsApp number, make sure to scan the QR code again

API v1

Domain or Host for sending messages, according to each server where the service is registered

[reseller] Create New Device

you can create new device

POST/api/device
<?php
$curl = curl_init();
$token = "";
$data = [
    'package' => 'dsadads'
    'sender' => '081XXXXXXX',
    'periode' => 'monthly',
    'payment' => 'PAYPAL'
];

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/device");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
package Required Package Serial of every packages. you can see on the https://sawit.wablas.com/pricing/whatsapp
sender Required Phone number for sender. You can use the country code prefix or not. Example: 081223xxxx
periode Required Only monthly or quarterly peroid
payment Required Your can using PAYPAL, BCA, MANDIRI, BNI and BRI
callback Optional URL will received incoming message
tracking Optional URL will received incoming status of message

Response:


{
    "status": true,
    "message": "successfully",
    "data": {
        "sender": "6281XXX",
        "name": "Device ID XXX",
        "device_id": "XXXX",
        "token": "",
        "api_url": "https://wablas.com",
        "invoice": {
            "number": "INV20001XXX",
            "total": {
                "idr": "249.243",
                "usd": "19.00"
            },
            "status": "pending"
        }
    }
}
                                        

[reseller] Extend Package for Device

extend package for every device

POST/api/device/extend
<?php
$curl = curl_init();
$token = "";
$data = [
    'package' => 'dsadads'
    'device_d' => '081XXXXXXX',
    'periode' => 'monthly',
    'payment' => 'PAYPAL'
];

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/device/extend");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
package Required Package Serial of every packages. you can see on the https://sawit.wablas.com/pricing/whatsapp
device_id Required Unix ID for device
periode Required Only monthly or quarterly peroid
payment Required Your can using PAYPAL, BCA, MANDIRI, BNI and BRI

Scan QR Code

Generate new QR Code image

GETgenerate/qr.php?token=xxxx&url=yyy

Response:

scan qr code
Request parameters:
Token Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
url Required aHR0cHM6Ly9zYXdpdC53YWJsYXMuY29t is base64_encode from https://sawit.wablas.com

Info Device

Info your device detail, like quota and status.

GETapi/device/info?token=xxxx

Response:


{
    "status": true,
    "message": "successfully",
    "data": {
        "user_id": "W000x",
        "project_id": "1",
        "sender": "62081xxxxx",
        "product_id": 1,
        "whatsapp": {
            "quota": "200",
            "expired": "2050-03-29",
            "status": "disconnected" //connected or disconnected
        },
        "sms": {
            "quota": 0,
            "expired": "2019-12-30",
            "status": "inactive" // active or inactive
        },
        "last_update": "2020-09-25 20:15:00"
    }
}

Restart Device

when you switch to web.whatsapp.com and want to connect to https://sawit.wablas.com

GETapi/device/reconnect?token=xxxx

Response:


{
    "status": true,
    "message": "successfully",
    "device_": "1"
}

Change Sender

you can change your sender anytime

POST/api/device/change-sender
<?php
$curl = curl_init();
$token = "";
$data = [
    'phone' => '081XXXXXXX',
];

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/device/change-sender");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>

Change Device Name

you can change your device name anytime

POST/api/device/change-name
<?php
$curl = curl_init();
$token = "";
$data = [
    'name' => 'Device X',
];

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/device/change-name");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
name Required Must string. Example: Device X

Send Whatsapp Message

Send a message to a new or existing chat. The message will be added to the queue to send and send even if the phone is disconnected from the Internet or authorization is not passed. This function serves to send information, promos, news or other messages to the user

POST/api/send-message
<?php
$curl = curl_init();
$token = "";
$payload = [
    "data" => [
        [
            'phone' => '081xxx',
            'message' => 'try message 1',
            'secret' => false, // or true
            'priority' => false, // or true
        ],
        [
            'phone' => '085xxx',
            'message' => 'try message 2',
            'secret' => false, // or true
            'priority' => false, // or true
        ],
        ...
    ]
];

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
        "Content-Type: application/json"
    )
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($payload) );
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/v2/send-bulk/text");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
message Required Text message to be sent. Format: UTF-8 or UTF-16 string. for single newline (\n1 or PHP_EOL), double newline (\n2 or PHP_EOL PHP_EOL). maximum character is 1000
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Sample Python Code: https://pastebin.com/jYRcen73

Response:


{
    "status": true,
    "message": "successfully sent text",
    "data": {
        "quota": "unlimited",
        "message": [
            {
                "id": "STRKW2dy5b3Qq60Hi3e9RCund1PS6lZ9",
                "phone": "081XXXXXXX",
                "message": "hellow world",
                "status": "pending"
            }
        ]
    }
}
                                        

Send Simple Whatsapp Message

Send whatsapp message with simple code

GETapi/send-message?token={your-token}&phone={receiver-number}&message={text-message}
<?php
$resutl = file_get_contents("{ domain_api }/api/send-message?token=xxxxx&phone=6281223&message=hello")

echo "<pre>";
print_r($result);

?>

Send Group Whatsapp Message

Send a message to a whatsapp group chat. The message will be added to the queue to send and send even if the phone is disconnected from the Internet or authorization is not passed. This function serves to send information, promos, news or other messages to the whatsapp group

POST/api/send-group

You must login to see this sample code

Send Image Whatsapp Message

POST/api/send-image

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
caption Optional Text image must on the format: UTF-8 or UTF-16 string. maximum 700 character
image Required URL of image file to be sent. Make sure the image has been uploaded on the server and can be accessed by the public.
support extension jpg, jpeg, png, gif
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Send image whatsapp message from local

POST/api/send-image-from-local

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
caption Optional Text image must on the format: UTF-8 or UTF-16 string. maximum 700 character
support extension jpg, jpeg, png, gif
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Send Image Whatsapp Message to a Group

POST/api/send-image-group

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
groupId Required The ID number of WhatsApp group. You can check on message menu to looking ID Whatsapp group. Example: 15423xxxx
phone Required Whatsapp numbers who is creator of group and don't forget sender number must be admin of group. You can use the country code prefix or not. Example: 081223xxxx
caption Optional Text image must on the format: UTF-8 or UTF-16 string. maximum 700 character
image Required URL of image file to be sent. Make sure the image has been uploaded on the server and can be accessed by the public.
support extension jpg, jpeg, png, gif
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Send Image whatsapp message to a group from local

POST/api/send-image-group-from-local

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
groupId Required The ID number of WhatsApp group. You can check on message menu to looking ID Whatsapp group. Example: 15423xxxx
phone Required Whatsapp numbers who is creator of group and don't forget sender number must be admin of group. You can use the country code prefix or not. Example: 081223xxxx
caption Optional Text image must on the format: UTF-8 or UTF-16 string. maximum 700 character
support extension jpg, jpeg, png, gif
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Send Document Whatsapp Message

POST/api/send-document

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
document Required The document file URL to be sent. Make sure documents have been uploaded on the server and can be accessed by the public.
caption Required Text image must on the format: UTF-8 or UTF-16 string. maximum 700 character
support extension doc, docx, pdf, odt, csv, ppt, pptx, xls, xlsx, mp3, ogg, jpg, jpeg, png
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Send document whatsapp message from local

POST/api/send-document-from-local

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
support extension doc, docx, pdf, odt, csv, ppt, pptx, xls, xlsx, mp3, ogg, jpg, jpeg, png

Send Document Whatsapp Message to a Group

POST/api/send-document-group

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
groupId Required The ID number of WhatsApp group. You can check on message menu to looking ID Whatsapp group. Example: 15423xxxx
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
caption Optional Text document on the format: UTF-8 or UTF-16 string. maximum 700 character
document Required The document file URL to be sent. Make sure documents have been uploaded on the server and can be accessed by the public.
support extension doc, docx, pdf, odt, csv, ppt, pptx, xls, xlsx, mp3, ogg, jpg, jpeg, png
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Send Video Whatsapp Message

POST/api/send-video

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
caption Optional Text video on the format: UTF-8 or UTF-16 string. maximum 700 character
video Required Video URL file to be sent. Make sure the video has been uploaded on the server and is publicly accessible.
support extension mp4, mpeg
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Send Video Whatsapp Message to a Group

POST/api/send-video-group

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
groupId Required The ID number of WhatsApp group. You can check on chats menu to looking ID Whatsapp group. Example: 15423xxxx
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx
caption Optional Text document on the format: UTF-8 or UTF-16 string. maximum 700 character
video Required Video URL file to be sent. Make sure the video has been uploaded on the server and is publicly accessible.
support extension mp4, mpeg
secret Required if the value is true, after successfully sending the message, it will be deleted from the database
prioprity Required if the value is true, the message is sent first from another message queue

Create Schedule Whatsapp Message

POST/api/schedule
<?php
    $curl = curl_init();
    $token = "";
    $data = [
        'phone' => '081XXXXXXX',
        'message' => 'hi',
        'date' => '2019-01-22',
        'time' => '14:30',
    ];

    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array(
            "Authorization: $token",
        )
    );
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/schedule");
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($curl);
    curl_close($curl);

    echo "<pre>";
    print_r($result);

    ?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Whatsapp numbers that will receive messages. You can use the country code prefix or not. Example: 081223xxxx
message Required text format: UTF-8 or UTF-16 string. for newline (\n1 or PHP_EOL), double newline (\n2 or PHP_EOL PHP_EOL). Maximum 1000 character
date Required set the date when the message will be sent.
time Required set the time when the message will be sent.

Update Schedule Whatsapp Message

POST/api/schedule/{schedule_id}
<?php
    $curl = curl_init();
    $token = "";
    $schedule_id = "";
    $data = [
        'phone' => '081XXXXXXX',
        'message' => 'hi',
        'date' => '2019-01-22',
        'time' => '14:30',
    ];

    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array(
            "Authorization: $token",
        )
    );
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/schedule/$schedule_id");
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($curl);
    curl_close($curl);

    echo "<pre>";
    print_r($result);

    ?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Whatsapp numbers that will receive messages. You can use the country code prefix or not. Example: 081223xxxx
message Required text format: UTF-8 or UTF-16 string. for newline (\n1 or PHP_EOL), double newline (\n2 or PHP_EOL PHP_EOL). Maximum 1000 character
date Required set the date when the message will be sent.
time Required set the time when the message will be sent.

Delete Schedule Whatsapp Message

GET/api/schedule/{schedule_id}
<?php
    $curl = curl_init();
    $token = "";
    $schedule_id = "";

    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array(
            "Authorization: $token",
        )
    );
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/schedule/$schedule_id");
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($curl);
    curl_close($curl);

    echo "<pre>";
    print_r($result);

    ?>

Report Message

GET/api/report

Report Message, The last 30 days. Update every weekly, Sunday at 00:00

<?php
$curl = curl_init();
$token = "";

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/report?from=2019-01-01&to=2019-08-08&limit=10");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
from Optional start date
to Optional end date
limit Optional defult 10 row and max 100 row

Report Outbox Message

GET/api/report-realtime

Report Message, The last 7 days

<?php
$curl = curl_init();
$token = "";

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/report-realtime");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
limit Optional defult 10 row and max 100 row

Remove Pending Whatsapp Message

Cancel sending whatsapp message.

POST/api/remove-pending-message
<?php
    $curl = curl_init();
    $token = "";
    $data = [
        'start_date' => '2019-01-22',
        'end_date' => '2019-01-22',
    ];

    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array(
            "Authorization: $token",
        )
    );
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/remove-pending-message");
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($curl);
    curl_close($curl);

    echo "<pre>";
    print_r($result);

    ?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
start_date Required -
end_date Required -

Resend Whatsapp Message

resend whatsapp messages. Messages that can be resend are messages in the last 7 days

POST/api/resend-message
<?php
    $curl = curl_init();
    $token = "";
    $data = [
        'start_date' => '2019-01-22',
        'end_date' => '2019-01-22',
    ];

    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array(
            "Authorization: $token",
        )
    );
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/resend-message");
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($curl);
    curl_close($curl);

    echo "<pre>";
    print_r($result);

    ?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
start_date Required -
end_date Required -

URL Webhook For Receive Incoming Whatsapp Message

POST https://yourdomain.com/webhook

Retrieve new incoming messages from WhatsApp, so every time a new message is sent, we will forward it to this URL. The webhooks URL can be set on menu: Device - setting - webhook receive.

Make sure you have a domain that can be accessed publicly as namadomain.com, then place the webhook file in the folder, so that later your webhook URL is https://yourdomain.com/webhook.php
The following is the data that will be sent to your webhook URL:

<?php
header("Content-Type: text/plain");
/**
 * all data POST sent from https://sawit.wablas.com
 * you must create URL what can receive POST data
 * we will sent data like this:

 * # Text:
 * =============================
 * id = message ID - string
 * phone = sender phone - string
 * message = content of message - string
 * pushName = Sender Name like contact name - string (optional)
 * thumbProfile = profile picture - string (optional)
 * groupId = Group ID if message from group - string (optional)
 * groupSubject = Group Name - string (optional)
 * timestamp = time send message - integer
 * category = text - string
 * receiver = sender number - integer

 * # Image
 * ============================
 * id = message ID - string
 * phone = sender phone - string
 * message = content of message - string
 * pushName = Sender Name like contact name - string (optional)
 * thumbProfile = profile picture - string (optional)
 * groupId = Group ID if message from group - string (optional)
 * groupSubject = Group Name - string (optional)
 * timestamp = time send message - integer
 * receiver = sender number - integer
 * image = name of the image file when receiving image message
 * url = URL of image
 * category = image - string

 * # Document, video and audio
 * ===========================
 * id = message ID - string
 * phone = sender phone - string
 * message = content of message - string
 * pushName = Sender Name like contact name - string (optional)
 * thumbProfile = profile picture - string (optional)
 * groupId = Group ID if message from group - string (optional)
 * groupSubject = Group Name - string (optional)
 * timestamp = time send message - integer
 * receiver = sender number - integer
 * file = name of the file when receiving media message
 * url = URL of file
 * category = document/video/audio - string

 * # Location and Live Location
 * ===========================
 * id = message ID - string
 * phone = sender phone - string
 * pushName = Sender Name like contact name - string (optional)
 * thumbProfile = profile picture - string (optional)
 * groupId = Group ID if message from group - string (optional)
 * groupSubject = Group Name - string (optional)
 * timestamp = time send message - integer
 * receiver = sender number - integer
 * file = name of the file when receiving media message (optional)
 * url = URL of file (optional)
 * address - string (optional)
 * location - string (optional)
 * latitude - integer
 * longitude - integer
 * accuracy - integer (optional)
 * speed - integer (optional)
 * category = location - string
 */

/**
 * Save to database table inbox
 */
if(isset($_POST['message'])) {
    $conn = new mysqli("localhost", "userxxx", "passwordxxx", "bot_db");
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    $id = $_POST['id'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];

    $sql = "INSERT INTO inbox (message_id, phone, message) VALUES ($id, $phone, $message)";
    if ($conn->query($sql) === TRUE) {
        echo null;
    } else {
        echo "Error: " . $sql . "
" . $conn->error; } $conn->close(); } ?>
<?php
header("Content-Type: text/plain");
/**
 * for auto reply or bot
 */

if($_POST['message'] == 'hello') {
    echo "Hello too.";
} else {
    echo null;
}

?>
<?php
header('Content-Type: application/json');
/**
 * for auto reply or bot with multiple message. currently only supports text and images
 */

 // message 1
$payload[] = [
    'category' => 'image',
    'message' => 'hello word 1',
    'mime_type' => 'image/png',
    'url_file' => 'https://image.org/test1.png'
];

// message 2
$payload[] = [
    'category' => 'image',
    'message' => 'hello word 2',
    'mime_type' => 'image/jpeg',
    'url_file' => 'https://image.org/test2.jpeg'
];

// message 3
$payload[] = [
    'category' => 'text',
    'message' => 'hello word 3',
];

echo json_encode(['data' => $payload]);

?>

the printed text on the echo will then be sent back to the user as a reply, if you request an automatic reply. if you do not want to reply in print enough "null" ( echo null ).

Body Response:
id string Message ID like random string mandatory
phone string sender number, example: 62821144818 mandatory
pushName string sender name example: Peter optional
message string content of message optional
groupId string Group ID if message coming from group whatsapp, example: 6282111444818-84267713. So your Group ID is 84267713 optional
groupSubject string Group Name optional
image string name of image optional
file string name of file like document or video optional
url url string URL from image / document / video optional

Update URL Webhook

POST/api/device/webhook
<?php
    $curl = curl_init();
    $token = "";
    $data = [
        'url' => 'https://webhook.domain.com',
    ];

    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array(
            "Authorization: $token",
        )
    );
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/device/webhook");
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($curl);
    curl_close($curl);

    echo "<pre>";
    print_r($result);

    ?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
url Required must publicly accessible url domain address

URL Webhook For Tracking Whatsapp Message

POSThttps://your-domain.com/tracking

Retrieve new status of messages from WhatsApp, so every time a new status of message is sent, we will forward it to this URL. The webhooks URL can be set on menu: Device - setting - webhook tracking.

Make sure you have a domain that can be accessed publicly as namadomain.com, then place the webhook file in the folder, so that later your webhook URL is https://yourdomain.com/tracking.php
The following is the data that will be sent to your webhook URL:

<?php
/**
 * all data POST sent from https://sawit.wablas.com
 * you must create URL what can receive POST data
 * we will sent data like this:
 * id = message ID - string
 * phone = whatsapp number of customer
 * status = status of message - string
 * note = information - string
 * deviceId = device ID - string
 */

?>
Body Response:
id string Message ID like random string
phone string Telephone number of the recipient of the message
status string sent, read, cancel, received, reject, pending
deviceId string ID your device

Update URL Tracking

POST/api/device/tracking
<?php
    $curl = curl_init();
    $token = "";
    $data = [
        'url' => 'https://tracking.domain.com',
    ];

    curl_setopt($curl, CURLOPT_HTTPHEADER,
        array(
            "Authorization: $token",
        )
    );
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/device/tracking");
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    $result = curl_exec($curl);
    curl_close($curl);

    echo "<pre>";
    print_r($result);

    ?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
url Required must publicly accessible url domain address
PHP Client
https://github.com/saputradharma/wablas-client-php

Thanks to saputradharma.

https://packagist.org/packages/shadowbane/laravel-wablas

Thanks to shadowbane.

Send SMS

Send a message to a new or existing phone number.

POSTapi/sms/send
<?php
$curl = curl_init();
$token = "";
$data = [
    'phone' => '081XXXXXXX',
    'message' => 'hellow world with SMS',
];

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_URL, "{ domain_api }/api/sms/send");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
Request parameters:
Authorization Required Your Token from https://sawit.wablas.com, can be seen in the menu: Device - Setting
phone Required Whatsapp numbers that will receive messages. You can use the country code prefix or not. Example: 081223xxxx
message Required Text message to be sent. Format: UTF-8 or UTF-16 string. Maximum 1000 character

Send Simple SMS

Send SMS message with simple code

GETapi/sms/send?token={your-token}&phone={receiver-number}&message={text-message}
<?php
$resutl = file_get_contents("{ domain_api }/api/sms/send?token=XXX&phone=6281223&message=hello")

echo "<pre>";
print_r($result);

?>

Forward SMS

send a message to the client where the status message is cancel. The forward URL can be set on menu: Device - SMS gateway setting - forward SMS.

POSThttps://your-domain.com/forward
<?php
/**
 * all data POST sent from https://sawit.wablas.com
 * you must create URL what can receive POST data
 * we will sent data like this:
 * id = message ID - string
 * phone = string
 * message = string
 * device_id = string
 */

?>
Body Response:
id string Message ID like random string
phone string Telephone number of the recipient of the message
message string content of message
device_id string ID your device

Forward Finger Print

URL for received data from finger print

POSThttps://your-domain.com/forward
<?php
/**
 * all data POST sent from https://sawit.wablas.com
 * you must create URL what can receive POST data
 * we will sent data like this:
 * serial_number = string
 * data = string
 */

?>
Body Response:
serial_number string SN from finger print
data string example: 1\t2019-10-27 07:24:21\t0\t1\r\n2\t2019-10-27 07:25:18\t1\t1\r\n1\t2019-10-27 07:26:23\t4\t1\r\n2\t2019-10-27 07:26:53\t5\t1\r\n