BSB Messaging API

Powerful, reliable messaging infrastructure for SMS and WhatsApp. Build seamless communication experiences with our developer-friendly API.

99.9%
Uptime SLA
<1s
Avg Latency
200+
Countries

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

Managing API Keys & Secrets

Getting Started

To manage your API credentials:

  1. Navigate to MANAGE APIs
  2. Your API key and secret can be generated from the API Keys & Secrets page
  3. For enhanced security, we recommend regenerating your API secret immediately
  4. 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.

Example Header
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.

Example Headers
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_key parameter in all APIs.
  • API Secret: Used as the api_secret parameter in all APIs. Should be regenerated for security.
  • API Secured Key: Required for secured APIs. Used in the API-Secured-Key header. Must be set for secured API endpoints to work.
Base URL
https://www.bestsmsbulk.com/bestsmsbulkapi
1
Send SMS (Text HTTP)
GET POST
https://www.bestsmsbulk.com/bestsmsbulkapi/sendSmsAPI.php

Parameters

Parameter Description
api_keyRequiredYour API key (from API Keys & Secrets page)
api_secretRequiredYour API secret (from API Keys & Secrets page)
messageRequiredSMS content to send
senderidRequiredSender ID (case sensitive)
destinationRequiredPhone number(s) in format: 96170XXXXXX. Multiple numbers separated by ;
dateOptionalSchedule date (YYYY-MM-DD)
timeOptionalSchedule time (HH:mm, 24h format)
PHP
<?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
?>
C#
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());
    }
}
Python
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
Node.js
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)

ResponseDescription
message Field is emptyMessage parameter missing
destination Field is emptyDestination parameter missing
senderid is not authorizedSender ID not approved for your account
Invalid API credentialsInvalid API key or secret
API key is set, you cannot use this API linkUse Secured API instead
No creditsInsufficient balance
Error 101Balance update failed
Error 102Message insertion failed
2
Send SMS (JSON HTTP)
POST JSON Body

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.

https://www.bestsmsbulk.com/bestsmsbulkapi/sendSmsAPIJson.php

Request Body (JSON Array)

ParameterDescription
api_keyRequiredYour BSB API key
api_secretRequiredYour BSB API secret
messageRequiredSMS content to send
senderidRequiredSender ID (case sensitive)
destinationRequiredPhone number(s), separated by ;
dateOptionalSchedule date (YYYY-MM-DD)
timeOptionalSchedule time (HH:mm:ss)
PHP
<?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);
?>
Python
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())
Node.js
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

ResponseDescription
{"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
3
Get Delivery Status
POST JSON Body

JSON Array Input Required

This endpoint accepts a JSON array with your credentials. Set Content-Type: application/json header.

https://www.bestsmsbulk.com/bestsmsbulkapi/getSmsStatusJson.php

Request Body (JSON Array)

ParameterDescription
api_keyRequiredYour BSB API key
api_secretRequiredYour BSB API secret
limitOptionalNumber of statuses to retrieve (default: 1000)
PHP
<?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);
?>
Python
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)
Node.js
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

StatusDescription
DELIVEREDMessage delivered successfully
PENDINGMessage queued, awaiting delivery
FAILEDMessage delivery failed
SENTMessage sent to carrier

Error Responses

ResponseDescription
wrong json formatMalformed JSON body
{"status": 300, "message": "Invalid API credentials"}Invalid API key or secret
No msgs sent todayNo messages found for today
4
Combined SMS & WhatsApp
GET POST
https://www.bestsmsbulk.com/bestsmsbulkapi/common/sendSmsWpAPITemplate.php
ParameterDescription
api_keyRequiredYour BSB API key
api_secretRequiredYour BSB API secret
destinationRequiredPhone number(s), separated by ;
routeRequiredsms or wp (WhatsApp)
messageSMS OnlySMS message content
senderidSMS OnlySender ID (case sensitive)
templateWhatsAppApproved template name
variablesWhatsAppTemplate variables (comma-separated)
mediaWhatsAppMedia file URL

Success Response (Plain Text)

confirmationID;recipientNumber;numSMSParts

Example: 110099887;96170123456;1

Error Responses (Plain Text)

ResponseDescription
destination Field is emptyDestination parameter missing
Invalid API credentialsInvalid API key or secret
API key is set, you cannot use this API linkUse Secured API instead
No creditsInsufficient balance
5
WhatsApp OTP
GET POST
https://www.bestsmsbulk.com/bestsmsbulkapi/common/sendSmsWpAPI.php
ParameterDescription
api_keyRequiredYour BSB API key
api_secretRequiredYour BSB API secret
destinationRequiredPhone number(s)
messageRequiredOTP code only (e.g., "123456")
routeRequiredsms 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)

ResponseDescription
message Field is emptyMessage PArameter is missing
destination Field is emptyDestination parameter missing
Invalid API credentialsInvalid API key or secret
API key is set, you cannot use this API linkUse Secured API instead
No creditsInsufficient balance
6
Submit WhatsApp Template to Meta
POST WhatsApp Business

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.

https://www.bestsmsbulk.com/bestsmsbulkapi/common/submitMetaTemplateAPI.php

Required Parameters

Parameter Description
api_keyRequiredYour BSB API key
api_secretRequiredYour BSB API secret
templateNameRequiredTemplate name (lowercase letters, numbers, underscores only)
templateCategoryRequiredMARKETING, UTILITY, or AUTHENTICATION
bodyTextRequiredTemplate body text (max 1024 characters). Use {{1}}, {{2}} for variables

Optional Parameters

Parameter Description
templateLanguageOptionalLanguage code (default: en_US)
headerTypeOptionalTEXT, IMAGE, VIDEO, or DOCUMENT
headerTextOptionalText for header (if headerType is TEXT)
headerMediaOptionalFile upload for media header (use multipart/form-data)
footerTextOptionalFooter text
bodyExampleConditionalComma-separated sample values for body variables. Required if bodyText has variables
headerExampleConditionalComma-separated sample values for header variables. Required if headerText has variables
button1typeOptionalButton type: URL, PHONE_NUMBER, or QUICK_REPLY
button1textOptionalButton display text
button1urlOptionalURL 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 - Text Template with Variables
<?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"
//   }
// }
?>
C# - Text Template
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}");
    }
}
Python - Template with Image Header
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)
Node.js - Authentication Template
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();
cURL - With Media Header
# 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

ResponseDescription
{"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 TypeSupported Formats
IMAGEJPEG, PNG, WEBP
VIDEOMP4, 3GPP
DOCUMENTPDF
7
Secured Messaging API
POST API Key Required

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

https://www.bestsmsbulk.com/bestsmsbulkapi/common/messaging_api_secured_json.php

Required Headers

HeaderValue
API-Secured-KeyRequiredYour API secured key (from API Keys & Secrets page)
Content-TypeRequiredapplication/json

Request Body (JSON)

ParameterTypeDescription
api_keyRequiredstringYour API key (from API Keys & Secrets page)
api_secretRequiredstringYour API secret (from API Keys & Secrets page)
destinationRequiredstringPhone number(s), separated by ;
messageRequiredstringMessage content
routeOptionalstringsms or wp (default: wp)
senderidSMS OnlystringSender ID for SMS
templateWhatsAppstringWhatsApp template name
variablesWhatsAppstringTemplate variables (comma-separated)
PHP
<?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";
?>
C#
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());
    }
}
Python
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()}")
Node.js
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 CodeResponseDescription
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
8
BSB AI Chatbot API
POST API Key Required

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.

https://www.bestsmsbulk.com/bestsmsbulkapi/bsbaichatbot/bsb_ai_chatbot_api.php

Required Headers

HeaderValue
API-Secured-KeyRequiredYour API secured key (from API Keys & Secrets page)
Content-TypeRequiredapplication/json

Request Body (JSON)

ParameterDescription
api_keyRequiredYour API key (from API Keys & Secrets page)
api_secretRequiredYour API secret (from API Keys & Secrets page)
messageRequiredUser message to the chatbot
fromRequiredUser identifier/phone number
dateOptionalDate (YYYY-MM-DD)
timeOptionalTime (HH:mm:ss)

Success Response

{
  "status": "success",
  "message": "Hi there! 👋 How can I assist you today?"
}

Error Responses

HTTP CodeResponseDescription
405Method 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

Shopify Webhook Integration
POST Webhooks

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.

https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php

Step-by-Step Shopify Setup

1
Open Shopify Settings

In your Shopify admin, go to SettingsNotificationsWebhooks (scroll to bottom of page)

2
Create a Webhook

Click "Create webhook" button

3
Select Event

Choose the event you want to trigger a message (e.g., Order creation, Order payment, Order fulfillment)

4
Set Format to JSON

Make sure Format is set to JSON

5
Enter Webhook URL

Paste the URL with your credentials:

https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/shopifyAPI.php?api_key=YOUR_API_KEY&api_secret=YOUR_API_SECRET&route=wp
6
Save the Webhook

Click Save. Repeat for each event you want to trigger messages.

URL Parameters

Parameter Description
api_keyRequiredYour BSB API key
api_secretRequiredYour BSB API secret
routeOptionalsms or wp (WhatsApp). Default: sms
senderidSMS OnlySender ID for SMS messages
templateWhatsAppWhatsApp template name (if using templates instead of default messages)
variablesWhatsAppTemplate 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

WhatsApp (Default Messages)
# 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 with Sender ID
# 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 Custom Template
# 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

ResponseDescription
{"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:

cURL Test Command
# 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

IssueSolution
Messages not sendingCheck that the customer has a valid phone number in their shipping address
Invalid API credentials errorVerify your API key and secret are correct and URL-encoded if they contain special characters
Insufficient creditsTop up your SMS or WhatsApp balance in the BSB dashboard
Webhook failing in ShopifyCheck Shopify's webhook logs at Settings → Notifications → Webhooks → View logs
Phone number format issuesEnsure 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

Abandoned Cart Webhook
POST Automated

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).

https://www.bestsmsbulk.com/bestsmsbulkapi/shopify/checkoutWebhook.php

How It Works

Customer adds to cart

BSB stores cart data

Wait 1 hour (configurable)

Send recovery message

Setup Instructions

1
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
2
Add Webhooks in Shopify

Go to Settings → Notifications → Webhooks and add these 3 webhooks (see table below):

3
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_keyRequiredYour BSB API key
api_secretRequiredYour BSB API secret
discountOptionalDiscount code to include in message (e.g., SAVE10)
delayOptionalMinutes 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

ResponseDescription
{"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

200 Success
400 Bad Request
401 Unauthorized
403 Forbidden
405 Method Not Allowed
500 Server Error

Need Help?

Our support team is here to assist you with any questions or issues.