Documentation https://console.spacesoft.in v5.4

Last Update: 30 Okt 2019

Welcome Back

Intro

SPACESOFT 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

Whatsapp Number Verification for Sender

  1. Select Device menu then click setting to Scan QR Code section, please scan the QR Code that appears
  2. If you successfully scan the QR Code then contact us (IT support) for service activation.
  3. We will activate your service, 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
  3. it's better not to use the business WhatsApp

API

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://console.spacesoft.in, can be seen in the menu: Device - Setting
url Required aHR0cHM6Ly9jb25zb2xlLndhYmxhcy5jb20= is base64_encode from https://console.spacesoft.in

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
        }
    }
}

Restart Device

when you switch to web.whatsapp.com and want to connect to https://console.spacesoft.in

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' => '91XXXXXXX',
];

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, "https://console.spacesoft.in/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);

?>
Request parameters:
Authorization Required Your Token from https://console.spacesoft.in, can be seen in the menu: Device - Setting
phone Required Target phone number. You can use the country code prefix or not. Example: 081223xxxx

Send 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 = "Your_Key_Here";
$data = [
    'phone' => '91XXXXXXX',
    'message' => 'hellow world',
];

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, "https://console.spacesoft.in/api/send-message.php");
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://console.spacesoft.in, 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 (\n), double newline (\n2)

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

Send Simple Message

Send message with simple code

GETapi/send-message?token={your-token}&phone={receiver-number}&message={text-message}
<?php
$resutl = file_get_content("https://console.spacesoft.in/api/send-message?token=E9yhDV489MY0JfPRg7VceSGA9kgyCR3k3dmCSIrIRvbJk3S&phone=917354673546&message=hello")

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

?>

Send Group 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

POST /api/send-image

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://console.spacesoft.in, 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
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
POST /api/send-image-from-local

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://console.spacesoft.in, 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
support extension jpg, jpeg, png, gif
POST /api/send-image-group

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://console.spacesoft.in, 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
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

Send Image 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://console.spacesoft.in, 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
support extension jpg, jpeg, png, gif

Send Document

POST/api/send-document

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://console.spacesoft.in, 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 document on the format: UTF-8 or UTF-16 string
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

Send Document 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://console.spacesoft.in, 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
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
POST /api/send-video

You must login to see this sample code

Request parameters:
Authorization Required Your Token from https://console.spacesoft.in, 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
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
POST /api/schedule
<?php
$curl = curl_init();
$token = "";
$data = [
    'phone' => '91XXXXXXX',
    '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, "https://console.spacesoft.in/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://console.spacesoft.in, 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 (\n)
date Required set the date when the message will be sent.
time Required set the time when the message will be sent.
GET /api/report

Report and Tracking Message

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

curl_setopt($curl, CURLOPT_HTTPHEADER,
    array(
        "Authorization: $token",
    )
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "https://console.spacesoft.in/api/report?from=2019-01-01&to=2019-08-08");
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://console.spacesoft.in, can be seen in the menu: Device - Setting
from Optional start date
to Optional end date

Webhook Receive Message

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:

POSThttps://your-domain.com/webhook.php
<?php
/**
 * all data POST sent from https://console.spacesoft.in
 * you must create URL what can receive POST data
 * we will sent data like this: 
 * id = message ID - string
 * phone = sender phone - string
 * message = content of message - text
 * pushName = Sender Name like contact name - string
 * groupId = Group ID if message from group - string
 * groupSubject = Group Name - string
 * timestamp = time send message - integer
 * image = name of the image file when receiving image message
 * file = name of the file file when receiving document/video message
 * url = URL of image/document/video
 */
extract($_POST);

/**
 * Save to database table inbox
 */
$conn = new mysqli("localhost", "user123", "password123", "bot_db");
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO inbox (message_id, phone, message)
VALUES ($id, $phone, $message)";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "
" . $conn->error; } if($conn->close()) { echo null; } ?>
<?php

extract($_POST);
/**
 * for auto reply or bot 
 */
 
echo "your phone: $phone \n";

if($message == 'hello') {
    echo "your message: $message";
} else {
    echo "I am still learning";
}

?>

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
phone string sender number, example: 62821144818
pushName string sender name example: Peter
message string content of message
groupId string Group ID if message coming from group whatsapp, example: 6282111444818-84267713. So your Group ID is 84267713
groupSubject string Group Name
image string name of image
file string name of file like document or video
url url string URL from image / document / video

Webhook Tracking Message

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:

POSThttps://your-domain.com/tracking.php
<?php
/**
 * all data POST sent from https://console.spacesoft.in
 * you must create URL what can receive POST data
 * we will sent data like this: 
 * id = message ID - string
 * phone
 * status = status of message - string
 * device_id = device ID - string
 */
extract($_POST);

?>
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
device_id string ID your device
PHP Client
https://github.com/saputradharma/spacesoft-client-php

Thanks to saputradharma.

Send SMS

Send a message to a new or existing phone number.

POSTapi/sms/send
<?php
$curl = curl_init();
$token = "";
$data = [
    'phone' => '91XXXXXXX',
    '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, "https://console.spacesoft.in/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://console.spacesoft.in, 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.

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
<?php
/**
 * all data POST sent from https://console.spacesoft.in
 * 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
 */
extract($_POST);

?>
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
<?php
/**
 * all data POST sent from https://console.spacesoft.in
 * you must create URL what can receive POST data
 * we will sent data like this: 
 * serial_number = string
 * data = string
 */
extract($_POST);

?>
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