BLACK API Documentation

Complete guide to integrate OTP & WhatsApp OTP service with your application.

Integration Steps
1
Set Up Your Environment
Make sure you have PHP with cURL extension enabled on your server.
2
Get Your API Key
Your API key: YOUR_API_KEY
3
Implement the API Call
Use the code examples below to integrate the API in your application.
API Endpoints
SMS OTP
POST https://blacksms.in/sms
WhatsApp OTP
POST https://blacksms.in/wasms
Quick SMS (GET / POST)
GET / POST https://blacksms.in/quick-sms
Bulk SMS Campaign
POST https://blacksms.in/endpoints/v1/bulk-sms
DLT Compliant SMS (Entity + Header + Template)
POST https://blacksms.in/dlt-sms
Request Format
1. OTP Send API (SMS & WhatsApp)
Headers
HeaderValueRequired
AuthorizationYour API keyYes
Content-Typeapplication/jsonYes
Request Body Parameters
ParameterTypeDescriptionRequired
sender_idStringYour sender ID (YOUR_SENDER_ID)Yes
variables_valuesStringThe OTP value to send (4-6 digits)Yes
numbersStringRecipient's 10-digit mobile numberYes
routeIntegerThe route to use (1 to 9)No (default: 1)
2. Bulk SMS Campaign API
Headers
HeaderValueRequired
AuthorizationYour API keyYes
Content-Typeapplication/jsonYes
Request Body Parameters
3. DLT SMS Dispatch API (Approved Sender ID + Message ID + Variables)
Headers
ParameterTypeDescriptionRequired
HeaderValueRequired
AuthorizationYour API key (YOUR_API_KEY)Yes
Content-Typeapplication/jsonYes
Request Body Parameters
ParameterTypeDescriptionRequired
authorizationStringYour API key (Alternative to Authorization Header)Yes
sender_idStringApproved DLT Sender ID / Header approved in DLT Manager (e.g. BLKSMS)Yes
message_idStringAssigned Random Message ID (e.g. 197853) or DLT Template ID (e.g. 1207161234567890123)Yes
numbersString10-digit Indian recipient mobile number(s) (comma separated for multiple)Yes
variables_valuesStringValues for template variables separated by pipe | if multiple (e.g. 123456 or 123456|Rahul)Required if template has variables
Note: Parameter aliases are also supported: header for sender_id, template_id for message_id, mobile for numbers, and variables for variables_values.
Code Examples
DLT SMS API Integration (cURL, PHP, Python, JS)
cURL
curl -X POST https://blacksms.in/dlt-sms \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "sender_id": "BLKSMS",
    "message_id": "197853",
    "numbers": "9876543210",
    "variables_values": "123456|Rahul"
  }'
PHP (cURL)
<?php
$payload = [
    "sender_id"        => "BLKSMS",
    "message_id"       => "197853",
    "numbers"          => "9876543210",
    "variables_values" => "123456|Rahul"
];

$ch = curl_init("https://blacksms.in/dlt-sms");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => json_encode($payload),
    CURLOPT_HTTPHEADER     => [
        "Authorization: YOUR_API_KEY",
        "Content-Type: application/json"
    ],
]);
$response = curl_exec($ch);
curl_close($ch);
$resData = json_decode($response, true);
echo "Status: " . $resData['message'];
?>
Python (requests)
import requests

url = "https://blacksms.in/dlt-sms"
headers = {
    "Authorization": "YOUR_API_KEY",
    "Content-Type": "application/json"
}
payload = {
    "sender_id": "BLKSMS",
    "message_id": "197853",
    "numbers": "9876543210",
    "variables_values": "123456|Rahul"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
JavaScript (Node.js / fetch)
fetch('https://blacksms.in/dlt-sms', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    sender_id: 'BLKSMS',
    message_id: '197853',
    numbers: '9876543210',
    variables_values: '123456|Rahul'
  })
})
.then(res => res.json())
.then(data => console.log(data));
OTP Sending API Integration
cURL
curl -X POST https://blacksms.in/sms \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sender_id": "YOUR_SENDER_ID", "variables_values": "123456", "numbers": "9876543210", "route": 1}'
PHP
<?php
$data = [
    "sender_id"        => "YOUR_SENDER_ID",
    "variables_values" => "123456",
    "numbers"          => "9876543210",
    "route"            => 1
];
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL            => "https://blacksms.in/sms",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST  => "POST",
    CURLOPT_POSTFIELDS     => json_encode($data),
    CURLOPT_HTTPHEADER     => [
        "Authorization: YOUR_API_KEY",
        "Content-Type: application/json"
    ],
]);
$response = curl_exec($curl);
curl_close($curl);
$result = json_decode($response, true);
?>
JavaScript (fetch)
fetch('https://blacksms.in/sms', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    sender_id: 'YOUR_SENDER_ID',
    variables_values: '123456',
    numbers: '9876543210',
    route: 1
  })
})
.then(r => r.json())
.then(data => console.log(data));
Bulk SMS Campaign API Integration
cURL
curl -X POST https://blacksms.in/endpoints/v1/bulk-sms \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Promo Campaign", "message": "Check out our services!", "contacts": ["9876543210", "9123456789"]}'
PHP
<?php
$data = [
    "title"    => "Promo Campaign",
    "message"  => "Check out our services!",
    "contacts" => ["9876543210", "9123456789"]
];
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL            => "https://blacksms.in/endpoints/v1/bulk-sms",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST  => "POST",
    CURLOPT_POSTFIELDS     => json_encode($data),
    CURLOPT_HTTPHEADER     => [
        "Authorization: YOUR_API_KEY",
        "Content-Type: application/json"
    ],
]);
$response = curl_exec($curl);
curl_close($curl);
$result = json_decode($response, true);
?>
JavaScript (fetch)
fetch('https://blacksms.in/endpoints/v1/bulk-sms', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    title: 'Promo Campaign',
    message: 'Check out our services!',
    contacts: ['9876543210', '9123456789']
  })
})
.then(r => r.json())
.then(data => console.log(data));
Response Format
1. OTP Sending API Response
Success
{ "status": 1, "message": "OTP Sent" }
Error
{ "status": 0, "message": "Error description details" }
2. Bulk SMS Campaign API Response
Success
{
  "success": true,
  "message": "Bulk SMS Campaign created successfully.",
  "campaign_id": 12,
  "provider_campaign_id": "98124",
  "total_contacts": 2,
  "sms_parts": 1,
  "total_cost": 0.40,
  "tracking_url": "https://blacksms.in/bulk-sms/campaign/12",
  "invalid_ignored": 0,
  "invalid_list": []
}
Error
{
  "success": false,
  "message": "Error description details"
}
Email OTP API NEW

Send One-Time Passwords (OTPs) directly to your users' email addresses using your connected SMTP account or Google/Gmail account.

Custom SMTP
Any SMTP provider
Google / Gmail
OAuth — no password
Email OTP Endpoint
POST
https://blacksms.in/endpoints/v1/email-otp
Required Headers
HeaderValueRequired
AuthorizationYour API Key✅
Content-Typeapplication/json✅
Request Body (JSON)
ParameterTypeRequiredDescription
emailstring✅ Recipient email address
template_idinteger— ID of your saved email template. 0 = default built-in template
sender_idstring— Which sender account to use: smtp_1, google_1. Auto-selects if omitted.
variablesobject— Extra template variables e.g. {"name": "Alice"}. Pass {"otp": "123456"} to use a specific OTP.
sender_id Format
  • smtp_<id> — Use a Custom SMTP account (e.g. smtp_1)
  • google_<id> — Use a connected Google account (e.g. google_1)
  • Omit — Auto-selects: SMTP account → Google account

Find IDs in SMTP Accounts or Google Accounts.

Email OTP — Code Examples
Email OTP — Response Format
✅ Success (HTTP 200)
{
  "success":    true,
  "message":    "OTP sent successfully.",
  "request_id": "EML-4A9F3C1B2E",
  "email":      "[email protected]",
  "expires_in": 600,
  "cost":       0.10,
  "balance":    49.90
}
❌ Error
{
  "success":    false,
  "message":    "Invalid email address.",
  "request_id": "EML-1B3D7A9F0C"
}
Error Codes
HTTPMeaning
200OTP sent successfully (₹0.10 deducted)
400Invalid JSON body or missing parameter
401Invalid or missing API key
402Insufficient balance (minimum ₹0.10 required)
403Account suspended
404Template ID not found
405Method not allowed (use POST)
422Invalid email address format
429Rate limit exceeded (60 req/min)
500Email delivery failed
Security Notes
  • OTPs are generated server-side with random_int() (CSPRNG)
  • OTPs are stored as SHA-256 hashes only — never plain text
  • SMTP passwords are encrypted with AES-256-CBC
  • Google OAuth tokens are encrypted and refreshed automatically
  • Rate limiting: 60 requests per minute per API key
Your API Key
YOUR_API_KEY

Keep this key secret.

Need Help?

Questions about integration? Our support team is here to help.

Contact Support