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://www.blacksms.in/sms
WhatsApp OTP
POST
https://www.blacksms.in/wasms
Bulk SMS Campaign
POST
https://www.blacksms.in/endpoints/v1/bulk-sms
Request Format
1. OTP Send API (SMS & WhatsApp)
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Your API key | Yes |
| Content-Type | application/json | Yes |
Request Body Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| sender_id | String | Your sender ID (YOUR_SENDER_ID) | Yes |
| variables_values | String | The OTP value to send (4-6 digits) | Yes |
| numbers | String | Recipient's 10-digit mobile number | Yes |
2. Bulk SMS Campaign API
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Your API key | Yes |
| Content-Type | application/json | Yes |
Request Body Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| title | String | Campaign Reference Title (e.g. "Promo broadcast") | Yes |
| message | String | SMS Message content (max 160 GSM chars / 70 Unicode chars) | Yes |
| contacts | Array | Array of valid 10-digit mobile numbers (e.g. ["9876543210","9123456789"]) | Yes |
Code Examples
OTP Sending API Integration
cURL
curl -X POST https://www.blacksms.in/sms \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sender_id": "YOUR_SENDER_ID", "variables_values": "123456", "numbers": "9876543210"}'
PHP
<?php
$data = [
"sender_id" => "YOUR_SENDER_ID",
"variables_values" => "123456",
"numbers" => "9876543210"
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.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://www.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'
})
})
.then(r => r.json())
.then(data => console.log(data));
Bulk SMS Campaign API Integration
cURL
curl -X POST https://www.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://www.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://www.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://www.blacksms.in/bulk-sms/campaign/12",
"invalid_ignored": 0,
"invalid_list": []
}
Error
{
"success": false,
"message": "Error description details"
}