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
Note:
Generate new QR Code image
GETgenerate/qr.php?token=xxxx&url=yyy
Response:
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 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
}
}
}
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"
}
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);
?>
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 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);
?>
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 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 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
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 |
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 |
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 |
POST/api/send-image-group-from-local
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 |
POST/api/send-document
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 |
POST/api/send-document-group
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 |
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 |
<?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);
?>
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. |
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);
?>
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 |
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 ).
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 |
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);
?>
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 |
https://github.com/saputradharma/spacesoft-client-php
Thanks to saputradharma.
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);
?>
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. |
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);
?>
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 |
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);
?>
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 |