BSB Messaging API
Powerful, reliable messaging infrastructure for SMS and WhatsApp. Build seamless communication experiences with our developer-friendly API.
Quick Integration
Get started in minutes with our simple REST API. Just authenticate and start sending messages.
Multi-Language SDKs
Code samples available in PHP, C#, Python, and Node.js to accelerate your development.
Enterprise Security
Advanced API key authentication for secured endpoints. Your data is always protected.
Authentication
Learn about the authentication methods available in our API
Authentication Methods
Standard APIs (1-6): Use api_key and api_secret parameters for authentication.
Secured APIs (7-8): Require API-Secured-Key header and api_key/api_secret parameters in POST body.
Get your API credentials: Navigate to MANAGE APIs to view or generate your API key and secret.
New: API Keys & Secrets Management
Manage your API credentials securely from: MANAGE APIs
Generate, regenerate, and manage your API keys and secrets with industry-standard security practices.
API Key Required for Secured Endpoints
To use Secured Messaging API or AI Chatbot API, you must generate an API key from: MANAGE APIs
Getting Started
To manage your API credentials:
- Navigate to MANAGE APIs
- Your API key and secret can be generated from the API Keys & Secrets page
- For enhanced security, we recommend regenerating your API secret immediately
- Generate a new API key if you need to rotate your credentials
API Key
Your API key is a unique identifier used for authentication. Include it in the API-Key header for secured endpoints.
API-Key: your-api-key-here
API Secret
Your API secret is a sensitive credential used for authentication in standard APIs. It's passed as the api_secret parameter.
Important: The secret is only shown once after generation. Make sure to copy it immediately.
API Secured Key
Your API secured key is required for secured API endpoints (Messaging API Secured, AI Chatbot API).
Include it in the API-Secured-Key header. You also need to pass api_key and api_secret in the POST body.
Important: This key is mandatory for secured APIs. The key is only shown once after generation.
API-Secured-Key: your-api-secured-key-here
Security Best Practices
- Never share your API key or secret publicly
- Store credentials securely (use environment variables or secure vaults)
- Regenerate your secret regularly for enhanced security
- Rotate API keys if you suspect they've been compromised
- Use different keys for different applications when possible
Field Explanations
- API Key: Your unique API key identifier. Used as the
api_keyparameter in all APIs. - API Secret: Used as the
api_secretparameter in all APIs. Should be regenerated for security. - API Secured Key: Required for secured APIs. Used in the
API-Secured-Keyheader. Must be set for secured API endpoints to work.
Parameters
| Parameter | Description |
|---|---|
| api_keyRequired | Your API key (from API Keys & Secrets page) |
| api_secretRequired | Your API secret (from API Keys & Secrets page) |
| messageRequired | SMS content to send |
| senderidRequired | Sender ID (case sensitive) |
| destinationRequired | Phone number(s) in format: 96170XXXXXX. Multiple numbers separated by ; |
| dateOptional | Schedule date (YYYY-MM-DD) |
| timeOptional | Schedule time (HH:mm, 24h format) |
<?php
$url = "https://www.bestsmsbulk.com/bestsmsbulkapi/sendSmsAPI.php";
$data = [
'api_key' => 'your-api-key-here',
'api_secret' => 'your-api-secret-here',
'senderid' => 'SENDERID',
'destination' => '96170123456',
'message' => 'Hello, this is a test SMS!'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
// Response: confirmationID;recipientNumber;numSMSParts
?>
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
var values = new Dictionary<string, string>
{
{ "api_key", "your-api-key-here" },
{ "api_secret", "your-api-secret-here" },
{ "senderid", "SENDERID" },
{ "destination", "96170123456" },
{ "message", "Hello, this is a test SMS!" }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync(
"https://www.bestsmsbulk.com/bestsmsbulkapi/sendSmsAPI.php",
content
);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
import requests
url = "https://www.bestsmsbulk.com/bestsmsbulkapi/sendSmsAPI.php"
data = {
"api_key": "your-api-key-here",
"api_secret": "your-api-secret-here",
"senderid": "SENDERID",
"destination": "96170123456",
"message": "Hello, this is a test SMS!"
}
response = requests.post(url, data=data)
print(response.text)
# Response: confirmationID;recipientNumber;numSMSParts
const https = require('https');
const querystring = require('querystring');
const postData = querystring.stringify({
api_key: 'your-api-key-here',
api_secret: 'your-api-secret-here',
senderid: 'SENDERID',
destination: '96170123456',
message: 'Hello, this is a test SMS!'
});
const options = {
hostname: 'www.bestsmsbulk.com',
path: '/bestsmsbulkapi/sendSmsAPI.php',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData)
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => console.log('Response:', data));
});
req.write(postData);
req.end();
Success Response (Plain Text)
confirmationID;recipientNumber;numSMSParts
Example: 110099887;96170123456;1
For multiple recipients (each on new line):
110099887;96170123456;1
110099888;96170789012;1
Error Responses (Plain Text)
| Response | Description |
|---|---|
message Field is empty | Message parameter missing |
destination Field is empty | Destination parameter missing |
senderid is not authorized | Sender ID not approved for your account |
Invalid API credentials | Invalid API key or secret |
API key is set, you cannot use this API link | Use Secured API instead |
No credits | Insufficient balance |
Error 101 | Balance update failed |
Error 102 | Message insertion failed |
JSON Array Input Required
This endpoint accepts a JSON array of message objects. You can send multiple messages in a single request. Set Content-Type: application/json header.
Request Body (JSON Array)
| Parameter | Description |
|---|---|
| api_keyRequired | Your BSB API key |
| api_secretRequired | Your BSB API secret |
| messageRequired | SMS content to send |
| senderidRequired | Sender ID (case sensitive) |
| destinationRequired | Phone number(s), separated by ; |
| dateOptional | Schedule date (YYYY-MM-DD) |
| timeOptional | Schedule time (HH:mm:ss) |
<?php
$url = "https://www.bestsmsbulk.com/bestsmsbulkapi/sendSmsAPIJson.php";
// JSON array - can send multiple messages at once
$data = [
[
'api_key' => 'your_api_key',
'api_secret' => 'your_api_secret',
'senderid' => 'SENDERID',
'destination' => '96170123456',
'message' => 'Hello, this is message 1!'
],
[
'api_key' => 'your_api_key',
'api_secret' => 'your_api_secret',
'senderid' => 'SENDERID',
'destination' => '96170789012',
'message' => 'Hello, this is message 2!'
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
?>
import requests
url = "https://www.bestsmsbulk.com/bestsmsbulkapi/sendSmsAPIJson.php"
# JSON array - can send multiple messages at once
data = [
{
"api_key": "your_api_key",
"api_secret": "your_api_secret",
"senderid": "SENDERID",
"destination": "96170123456",
"message": "Hello, this is message 1!"
},
{
"api_key": "your_api_key",
"api_secret": "your_api_secret",
"senderid": "SENDERID",
"destination": "96170789012",
"message": "Hello, this is message 2!"
}
]
response = requests.post(url, json=data)
print(response.json())
const https = require('https');
// JSON array - can send multiple messages at once
const data = JSON.stringify([
{
api_key: 'your_api_key',
api_secret: 'your_api_secret',
senderid: 'SENDERID',
destination: '96170123456',
message: 'Hello, this is message 1!'
},
{
api_key: 'your_api_key',
api_secret: 'your_api_secret',
senderid: 'SENDERID',
destination: '96170789012',
message: 'Hello, this is message 2!'
}
]);
const options = {
hostname: 'www.bestsmsbulk.com',
path: '/bestsmsbulkapi/sendSmsAPIJson.php',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => console.log(JSON.parse(body)));
});
req.write(data);
req.end();
Success Response
{
"status": 201,
"message": "Messages successfully queued",
"data": [
{
"status": 201,
"confirmationid": 12345678,
"recipient": "96170123456",
"numberofsmspermsg": 1
}
]
}
Error Responses
| Response | Description |
|---|---|
{"status": 300, "message": "Invalid JSON format"} | Malformed JSON body |
{"status": 300, "message": "Message field is empty"} | Message missing |
{"status": 300, "message": "Sender ID field is empty"} | Sender ID missing |
{"status": 300, "message": "Destination field is empty"} | Destination missing |
{"status": 300, "message": "Invalid API credentials"} | Invalid API key or secret |
{"status": 300, "message": "Sender ID is not authorized"} | Sender ID not approved |
{"status": 300, "message": "Insufficient credits"} | No balance available |
JSON Array Input Required
This endpoint accepts a JSON array with your credentials. Set Content-Type: application/json header.
Request Body (JSON Array)
| Parameter | Description |
|---|---|
| api_keyRequired | Your BSB API key |
| api_secretRequired | Your BSB API secret |
| limitOptional | Number of statuses to retrieve (default: 1000) |
<?php
$url = "https://www.bestsmsbulk.com/bestsmsbulkapi/getSmsStatusJson.php";
// JSON array format required
$data = [
[
'api_key' => 'your_api_key',
'api_secret' => 'your_api_secret',
'limit' => 100
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$statuses = json_decode($response, true);
print_r($statuses);
?>
import requests
url = "https://www.bestsmsbulk.com/bestsmsbulkapi/getSmsStatusJson.php"
# JSON array format required
data = [
{
"api_key": "your_api_key",
"api_secret": "your_api_secret",
"limit": 100
}
]
response = requests.post(url, json=data)
statuses = response.json()
print(statuses)
const https = require('https');
// JSON array format required
const data = JSON.stringify([
{
api_key: 'your_api_key',
api_secret: 'your_api_secret',
limit: 100
}
]);
const options = {
hostname: 'www.bestsmsbulk.com',
path: '/bestsmsbulkapi/getSmsStatusJson.php',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => console.log(JSON.parse(body)));
});
req.write(data);
req.end();
Success Response
[
{
"ack": "12345678",
"opstatus": "DELIVERED",
"recipient": "96170123456"
},
{
"ack": "12345679",
"opstatus": "PENDING",
"recipient": "96170789012"
}
]
Possible opstatus Values
| Status | Description |
|---|---|
DELIVERED | Message delivered successfully |
PENDING | Message queued, awaiting delivery |
FAILED | Message delivery failed |
SENT | Message sent to carrier |
Error Responses
| Response | Description |
|---|---|
wrong json format | Malformed JSON body |
{"status": 300, "message": "Invalid API credentials"} | Invalid API key or secret |
No msgs sent today | No messages found for today |
| Parameter | Description |
|---|---|
| api_keyRequired | Your BSB API key |
| api_secretRequired | Your BSB API secret |
| destinationRequired | Phone number(s), separated by ; |
| routeRequired | sms or wp (WhatsApp) |
| messageSMS Only | SMS message content |
| senderidSMS Only | Sender ID (case sensitive) |
| templateWhatsApp | Approved template name |
| variablesWhatsApp | Template variables (comma-separated) |
| mediaWhatsApp | Media file URL |
Success Response (Plain Text)
confirmationID;recipientNumber;numSMSParts
Example: 110099887;96170123456;1
Error Responses (Plain Text)
| Response | Description |
|---|---|
destination Field is empty | Destination parameter missing |
Invalid API credentials | Invalid API key or secret |
API key is set, you cannot use this API link | Use Secured API instead |
No credits | Insufficient balance |
| Parameter | Description |
|---|---|
| api_keyRequired | Your BSB API key |
| api_secretRequired | Your BSB API secret |
| destinationRequired | Phone number(s) |
| messageRequired | OTP code only (e.g., "123456") |
| routeRequired | sms or wp |
OTP Message Format
For WhatsApp OTP, the message will be sent as: "[YOUR_OTP] is your verification code. For your security, do not share this code."
Success Response (Plain Text)
confirmationID;recipientNumber;numSMSParts
Example: 110099887;96170123456;1
Error Responses (Plain Text)
| Response | Description |
|---|---|
message Field is empty | Message PArameter is missing |
destination Field is empty | Destination parameter missing |
Invalid API credentials | Invalid API key or secret |
API key is set, you cannot use this API link | Use Secured API instead |
No credits | Insufficient balance |
Create WhatsApp Message Templates
Submit new message templates directly to Meta for approval. Supports text templates with variables, text headers, media headers (IMAGE, VIDEO, DOCUMENT), and buttons.
Required Parameters
| Parameter | Description |
|---|---|
| api_keyRequired | Your BSB API key |
| api_secretRequired | Your BSB API secret |
| templateNameRequired | Template name (lowercase letters, numbers, underscores only) |
| templateCategoryRequired | MARKETING, UTILITY, or AUTHENTICATION |
| bodyTextRequired | Template body text (max 1024 characters). Use {{1}}, {{2}} for variables |
Optional Parameters
| Parameter | Description |
|---|---|
| templateLanguageOptional | Language code (default: en_US) |
| headerTypeOptional | TEXT, IMAGE, VIDEO, or DOCUMENT |
| headerTextOptional | Text for header (if headerType is TEXT) |
| headerMediaOptional | File upload for media header (use multipart/form-data) |
| footerTextOptional | Footer text |
| bodyExampleConditional | Comma-separated sample values for body variables. Required if bodyText has variables |
| headerExampleConditional | Comma-separated sample values for header variables. Required if headerText has variables |
| button1typeOptional | Button type: URL, PHONE_NUMBER, or QUICK_REPLY |
| button1textOptional | Button display text |
| button1urlOptional | URL or phone number for button |
Important Validation Rules
• If bodyText contains variables like {{1}}, {{2}}, then bodyExample is REQUIRED
• If headerText contains variables, then headerExample is REQUIRED
• If headerType is IMAGE/VIDEO/DOCUMENT, then headerMedia file is REQUIRED
<?php
$url = "https://www.bestsmsbulk.com/bestsmsbulkapi/common/submitMetaTemplateAPI.php";
$data = [
'api_key' => 'your_api_key',
'api_secret' => 'your_api_secret',
'templateName' => 'order_confirmation',
'templateCategory' => 'UTILITY',
'bodyText' => 'Hi {{1}}, your order #{{2}} has been confirmed and will be delivered by {{3}}.',
'bodyExample' => 'John,12345,tomorrow', // Required when using variables
'footerText' => 'Thank you for shopping with us!',
'button1type' => 'URL',
'button1text' => 'Track Order',
'button1url' => 'https://example.com/track'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
// Success Response:
// {
// "success": true,
// "message": "Template submitted successfully for approval",
// "data": {
// "template_id": "123456789",
// "template_name": "order_confirmation",
// "status": "PENDING"
// }
// }
?>
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
var values = new Dictionary<string, string>
{
{ "api_key", "your_api_key" },
{ "api_secret", "your_api_secret" },
{ "templateName", "order_confirmation" },
{ "templateCategory", "UTILITY" },
{ "bodyText", "Hi {{1}}, your order #{{2}} has been confirmed." },
{ "bodyExample", "John,12345" }, // Required when using variables
{ "footerText", "Thank you for your order!" },
{ "button1type", "URL" },
{ "button1text", "Track Order" },
{ "button1url", "https://example.com/track" }
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync(
"https://www.bestsmsbulk.com/bestsmsbulkapi/common/submitMetaTemplateAPI.php",
content
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Status: {response.StatusCode}");
Console.WriteLine($"Response: {result}");
}
}
import requests
url = "https://www.bestsmsbulk.com/bestsmsbulkapi/common/submitMetaTemplateAPI.php"
# For template with image header, use multipart/form-data
files = {
'headerMedia': ('promo.jpg', open('/path/to/promo.jpg', 'rb'), 'image/jpeg')
}
data = {
"api_key": "your_api_key",
"api_secret": "your_api_secret",
"templateName": "summer_promo",
"templateCategory": "MARKETING",
"headerType": "IMAGE", # IMAGE, VIDEO, or DOCUMENT
"bodyText": "Hi {{1}}! Check out our summer sale with up to {{2}}% off!",
"bodyExample": "valued customer,50", # Required when using variables
"footerText": "Limited time offer",
"button1type": "URL",
"button1text": "Shop Now",
"button1url": "https://example.com/sale"
}
response = requests.post(url, data=data, files=files)
print(response.json())
# For text-only template (no media), simpler request:
# response = requests.post(url, data=data)
const https = require('https');
const querystring = require('querystring');
// Authentication template (OTP)
const postData = querystring.stringify({
api_key: 'your_api_key',
api_secret: 'your_api_secret',
templateName: 'login_otp',
templateCategory: 'AUTHENTICATION',
bodyText: '{{1}} is your verification code. Valid for {{2}} minutes.',
bodyExample: '123456,5' // Required when using variables
// Note: AUTHENTICATION templates automatically get a "Copy Code" button
});
const options = {
hostname: 'www.bestsmsbulk.com',
path: '/bestsmsbulkapi/common/submitMetaTemplateAPI.php',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData)
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => {
console.log('Status:', res.statusCode);
console.log('Response:', JSON.parse(data));
});
});
req.write(postData);
req.end();
# Text template with variables
curl -X POST "https://www.bestsmsbulk.com/bestsmsbulkapi/common/submitMetaTemplateAPI.php" \
-d "api_key=your_api_key" \
-d "api_secret=your_api_secret" \
-d "templateName=welcome_message" \
-d "templateCategory=MARKETING" \
-d "bodyText=Welcome {{1}}! Thanks for joining us." \
-d "bodyExample=John" \
-d "footerText=We are glad to have you!"
# Template with IMAGE header (use -F for multipart/form-data)
curl -X POST "https://www.bestsmsbulk.com/bestsmsbulkapi/common/submitMetaTemplateAPI.php" \
-F "api_key=your_api_key" \
-F "api_secret=your_api_secret" \
-F "templateName=product_launch" \
-F "templateCategory=MARKETING" \
-F "headerType=IMAGE" \
-F "headerMedia=@/path/to/image.jpg" \
-F "bodyText=Introducing our new product: {{1}}" \
-F "bodyExample=Summer Collection" \
-F "button1type=URL" \
-F "button1text=Learn More" \
-F "button1url=https://example.com/product"
# Template with VIDEO header
curl -X POST "https://www.bestsmsbulk.com/bestsmsbulkapi/common/submitMetaTemplateAPI.php" \
-F "api_key=your_api_key" \
-F "api_secret=your_api_secret" \
-F "templateName=video_promo" \
-F "templateCategory=MARKETING" \
-F "headerType=VIDEO" \
-F "headerMedia=@/path/to/video.mp4" \
-F "bodyText=Watch our latest video!"
Success Response
{
"success": true,
"message": "Template submitted successfully for approval",
"data": {
"template_id": "1234567890123456",
"template_name": "order_confirmation",
"status": "PENDING",
"response": {
"id": "1234567890123456",
"status": "PENDING",
"category": "UTILITY"
},
"json_variables": {
"body_variables": ["John", "12345", "tomorrow"]
}
}
}
Error Responses
| Response | Description |
|---|---|
{"error": true, "message": "templateName field is empty"} | Template name missing |
{"error": true, "message": "Invalid API credentials"} | Invalid API key or secret |
{"error": true, "message": "Template name can only contain lowercase letters, numbers, and underscores"} | Invalid template name format |
{"error": true, "message": "Body text contains variables ({{1}}, {{2}}) but no sample examples provided..."} | Variables detected but bodyExample not provided |
{"error": true, "message": "Not enough sample values provided..."} | Fewer examples than variables |
{"error": true, "message": "headerType is set to IMAGE but no 'headerMedia' file was provided..."} | Media header type set but no file uploaded |
{"error": true, "message": "Invalid file type for IMAGE header..."} | Wrong file format for header type |
{"error": true, "message": "Body text exceeds the maximum limit of 1024 characters..."} | Body text too long |
{"error": true, "message": "No active WhatsApp account found..."} | WhatsApp Business API not configured |
{"error": true, "message": "Meta API Error..."} | Error from Meta API (includes error details) |
Supported Media Formats
| Header Type | Supported Formats |
|---|---|
IMAGE | JPEG, PNG, WEBP |
VIDEO | MP4, 3GPP |
DOCUMENT |
API Secured Key Authentication Required
This endpoint requires an API-Secured-Key header and api_key/api_secret parameters in the POST body. Generate your API credentials from: MANAGE APIs
Required Headers
| Header | Value |
|---|---|
| API-Secured-KeyRequired | Your API secured key (from API Keys & Secrets page) |
| Content-TypeRequired | application/json |
Request Body (JSON)
| Parameter | Type | Description |
|---|---|---|
| api_keyRequired | string | Your API key (from API Keys & Secrets page) |
| api_secretRequired | string | Your API secret (from API Keys & Secrets page) |
| destinationRequired | string | Phone number(s), separated by ; |
| messageRequired | string | Message content |
| routeOptional | string | sms or wp (default: wp) |
| senderidSMS Only | string | Sender ID for SMS |
| templateWhatsApp | string | WhatsApp template name |
| variablesWhatsApp | string | Template variables (comma-separated) |
<?php
$url = "https://www.bestsmsbulk.com/bestsmsbulkapi/common/messaging_api_secured_json.php";
$data = [
'api_key' => 'your-api-key-here',
'api_secret' => 'your-api-secret-here',
'destination' => '96170123456',
'message' => 'Hello from Secured API!',
'route' => 'wp',
'template' => 'your_template',
'variables' => 'var1,var2'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'API-Secured-Key: YOUR_API_SECURED_KEY_HERE' // Required! From API Keys & Secrets
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Code: $httpCode\n";
echo "Response: $response";
?>
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
// Add required API-Secured-Key header
client.DefaultRequestHeaders.Add("API-Secured-Key", "YOUR_API_SECURED_KEY_HERE");
var data = new
{
api_key = "your-api-key-here",
api_secret = "your-api-secret-here",
destination = "96170123456",
message = "Hello from Secured API!",
route = "wp",
template = "your_template",
variables = "var1,var2"
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://www.bestsmsbulk.com/bestsmsbulkapi/common/messaging_api_secured_json.php",
content
);
Console.WriteLine($"Status: {response.StatusCode}");
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
import requests
import json
url = "https://www.bestsmsbulk.com/bestsmsbulkapi/common/messaging_api_secured_json.php"
headers = {
"Content-Type": "application/json",
"API-Secured-Key": "YOUR_API_SECURED_KEY_HERE" # Required! From API Keys & Secrets
}
data = {
"api_key": "your-api-key-here",
"api_secret": "your-api-secret-here",
"destination": "96170123456",
"message": "Hello from Secured API!",
"route": "wp",
"template": "your_template",
"variables": "var1,var2"
}
response = requests.post(url, json=data, headers=headers)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.json()}")
const https = require('https');
const data = JSON.stringify({
api_key: 'your-api-key-here',
api_secret: 'your-api-secret-here',
destination: '96170123456',
message: 'Hello from Secured API!',
route: 'wp',
template: 'your_template',
variables: 'var1,var2'
});
const options = {
hostname: 'www.bestsmsbulk.com',
path: '/bestsmsbulkapi/common/messaging_api_secured_json.php',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-Secured-Key': 'YOUR_API_SECURED_KEY_HERE', // Required! From API Keys & Secrets
'Content-Length': Buffer.byteLength(data)
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => {
console.log('Status:', res.statusCode);
console.log('Response:', JSON.parse(body));
});
});
req.write(data);
req.end();
Success Response - SMS
[
{
"message": "SMS message sent successfully",
"status": 200,
"confirmationid": 12345678,
"recipient": "96170123456",
"numberofunits": 1
}
]
Success Response - WhatsApp
[
{
"message": "WhatsApp message sent successfully",
"status": 200,
"confirmationid": 12345678,
"recipient": "96170123456"
}
]
Error Responses
| HTTP Code | Response | Description |
|---|---|---|
403 | {"status": 403, "message": "Forbidden: Missing API Key"} | API-Key header missing |
403 | {"status": 403, "message": "Forbidden: Invalid API Key"} | API key not found or inactive |
403 | {"status": 403, "message": "Forbidden: Invalid API-Secured-Key"} | API-Secured-Key doesn't match API secret |
400 | {"status": 400, "message": "Invalid JSON input"} | Malformed JSON body |
400 | {"status": 400, "message": "API key mismatch"} | API key doesn't match provided credentials |
400 | {"status": 400, "message": "Destination is required"} | Destination missing |
400 | {"status": 400, "message": "Message is required"} | Message missing (SMS route) |
400 | {"status": 400, "message": "senderid is not authorized"} | Sender ID not approved |
400 | {"status": 400, "message": "No credits"} | Insufficient balance |
AI-Powered Chatbot Integration
Integrate our intelligent chatbot into your application. Requires API-Secured-Key header and api_key/api_secret parameters in POST body for authentication.
Required Headers
| Header | Value |
|---|---|
| API-Secured-KeyRequired | Your API secured key (from API Keys & Secrets page) |
| Content-TypeRequired | application/json |
Request Body (JSON)
| Parameter | Description |
|---|---|
| api_keyRequired | Your API key (from API Keys & Secrets page) |
| api_secretRequired | Your API secret (from API Keys & Secrets page) |
| messageRequired | User message to the chatbot |
| fromRequired | User identifier/phone number |
| dateOptional | Date (YYYY-MM-DD) |
| timeOptional | Time (HH:mm:ss) |
Success Response
{
"status": "success",
"message": "Hi there! 👋 How can I assist you today?"
}
Error Responses
| HTTP Code | Response | Description |
|---|---|---|
405 | Method Not Allowed: Only POST requests are accepted. | Only POST method allowed |
403 | {"status": 403, "message": "Forbidden: Missing API-Secured-Key header"} | API-Secured-Key header missing |
403 | {"status": 403, "message": "Forbidden: Invalid API Key"} | API key not valid |
403 | {"status": 403, "message": "Forbidden: Invalid API-Secured-Key"} | API-Secured-Key doesn't match configured key |
403 | {"status": 403, "message": "Forbidden: Invalid API Secret"} | API secret doesn't match |
400 | {"status": 400, "message": "api_key is required in POST body"} | api_key parameter missing |
400 | {"status": 400, "message": "api_secret is required in POST body"} | api_secret parameter missing |
400 | {"status": 400, "message": "Invalid JSON input"} | Malformed JSON body |
400 | {"status": 400, "message": "Destination is required"} | 'from' field missing |
400 | {"status": 400, "message": "Message is required"} | Message missing |
Shopify Integration
Automatically send WhatsApp or SMS notifications for Shopify store events
Automated Order Notifications
Connect your Shopify store to automatically send WhatsApp or SMS messages to customers when orders are placed, paid, shipped, or cancelled. Messages are sent instantly via webhooks.
Step-by-Step Shopify Setup
Open Shopify Settings
In your Shopify admin, go to Settings → Notifications → Webhooks (scroll to bottom of page)
Create a Webhook
Click "Create webhook" button
Select Event
Choose the event you want to trigger a message (e.g., Order creation, Order payment, Order fulfillment)
Set Format to JSON
Make sure Format is set to JSON
Save the Webhook
Click Save. Repeat for each event you want to trigger messages.
URL Parameters
| Parameter | Description |
|---|---|
| api_keyRequired | Your BSB API key |
| api_secretRequired | Your BSB API secret |
| routeOptional | sms or wp (WhatsApp). Default: sms |
| senderidSMS Only | Sender ID for SMS messages |
| templateWhatsApp | WhatsApp template name (if using templates instead of default messages) |
| variablesWhatsApp | Template variables (comma-separated) |
Supported Shopify Events
| Event | Shopify Topic | Default Message |
|---|---|---|
| Order Created | orders/create |
Thank you [Name] for your order #[OrderID]. Total: $[Total] |
| Order Paid | orders/paid |
Payment received for order #[OrderID]. Thank you! |
| Order Updated | orders/updated |
Your order #[OrderID] has been updated. |
| Order Cancelled | orders/cancelled |
Your order #[OrderID] has been canceled. |
| Order Shipped | orders/fulfilled |
Your order #[OrderID] has been shipped. Tracking: [TrackingNumber] |
| Partially Shipped | orders/partially_fulfilled |
Part of your order #[OrderID] has been shipped. |
| New Customer | customers/create |
Welcome [Name]! Thank you for signing up. |
Complete Webhook URL Examples
# Basic WhatsApp webhook URL
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET&route=wp
# Example with actual credentials:
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php?api_key=your_api_key&api_secret=your_api_secret&route=wp
# SMS webhook URL with Sender ID
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET&route=sms&senderid=MYSTORE
# Example:
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php?api_key=your_api_key&api_secret=your_api_secret&route=sms&senderid=SHOPIFY
# WhatsApp with approved template
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET&route=wp&template=order_confirmation
# Note: Template variables are automatically extracted from the Shopify order data
# Available variables: customer_name, order_id, total_price, tracking_number
Important Notes
• Customer phone number must be present in the Shopify order (shipping address or customer info)
• Messages are sent automatically when Shopify triggers the webhook
• Each message deducts from your BSB balance (SMS or WhatsApp credits)
• For WhatsApp, ensure you have an active WhatsApp Business account configured
Success Response
{"success": "Message sent successfully"}
Error Responses
| Response | Description |
|---|---|
{"error": "Invalid webhook data"} | Shopify payload is malformed or missing order ID |
{"error": "Webhook topic missing"} | Shopify didn't send the X-Shopify-Topic header |
{"error": "Customer phone number is missing"} | No phone number in order shipping address or customer data |
{"error": "Unhandled event type: [event]"} | Event type not supported |
{"error": "api_key is required"} | API key not provided in URL |
{"error": "api_secret is required"} | API secret not provided in URL |
{"error": "Invalid API credentials"} | Invalid API key or secret (HTTP 401) |
{"error": "Sender ID is not authorized"} | SMS sender ID not approved for your account |
{"error": "Insufficient credits"} | Not enough SMS credits |
{"error": "No Credits"} | Not enough WhatsApp credits |
Testing Your Webhook
You can test the webhook using cURL or a REST client:
# Test Order Creation Webhook
curl -X POST "https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET&route=wp" \
-H "Content-Type: application/json" \
-H "X-Shopify-Topic: orders/create" \
-d '{
"id": 123456789,
"order_number": "1001",
"total_price": "99.99",
"customer": {
"first_name": "John",
"last_name": "Doe"
},
"shipping_address": {
"phone": "+96170123456"
},
"line_items": [
{"name": "Test Product"}
]
}'
Troubleshooting
| Issue | Solution |
|---|---|
| Messages not sending | Check that the customer has a valid phone number in their shipping address |
| Invalid API credentials error | Verify your API key and secret are correct and URL-encoded if they contain special characters |
| Insufficient credits | Top up your SMS or WhatsApp balance in the BSB dashboard |
| Webhook failing in Shopify | Check Shopify's webhook logs at Settings → Notifications → Webhooks → View logs |
| Phone number format issues | Ensure phone numbers include country code (e.g., +961 for Lebanon) |
Abandoned Cart Recovery
Automatically send WhatsApp or SMS to customers who abandon their cart with a discount code
Recover Lost Sales Automatically
When customers add items to cart but don't complete purchase, automatically send them a WhatsApp/SMS reminder with a discount code after a configurable delay (default: 1 hour).
How It Works
Customer adds to cart
BSB stores cart data
Wait 1 hour (configurable)
Send recovery message
Setup Instructions
Create WhatsApp Template
Create a template named abandoned_cart with these variables:
{{1}}= Customer name{{2}}= Item count{{3}}= Cart total with currency{{4}}= Discount code
Add Webhooks in Shopify
Go to Settings → Notifications → Webhooks and add these 3 webhooks (see table below):
Start Recovering Sales!
That's it! Customers who abandon checkout will automatically receive a recovery message after 1 hour (configurable via URL parameter).
Required Webhooks
| Event | Webhook URL |
|---|---|
Checkout creation |
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/checkoutWebhook.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET |
Checkout update |
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/checkoutWebhook.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET |
Order creation |
https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/checkoutWebhook.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET |
Optional URL Parameters
| Parameter | Description |
|---|---|
| api_keyRequired | Your BSB API key |
| api_secretRequired | Your BSB API secret |
| discountOptional | Discount code to include in message (e.g., SAVE10) |
| delayOptional | Minutes to wait before sending (default: 60) |
Pro Tip: Include Discount Code in URL
Add &discount=SAVE10 to automatically include a discount code in recovery messages:
...checkoutWebhook.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET&discount=SAVE10
Example Recovery Message
Hi John! 👋
You left 2 item(s) in your cart worth $99.99.
Use code SAVE10 for 10% off!
Complete your order →
Success Response
{"success": "Checkout stored", "cart_id": 12345}
Error Responses
| Response | Description |
|---|---|
{"error": "Invalid webhook data"} | Shopify payload missing or invalid |
{"error": "api_key is required"} | API key not in URL |
{"error": "api_secret is required"} | API secret not in URL |
{"error": "Invalid API credentials"} | Invalid API key or secret (HTTP 401) |
{"message": "Checkout received but no phone number"} | Customer didn't provide phone (cart not stored) |
{"message": "Checkout already converted to order"} | Cart was already converted to order (normal for sequential webhooks) |
HTTP Status Codes
Need Help?
Our support team is here to assist you with any questions or issues.