Sendexa LogoDocs

Bulk SMS

Send high-volume SMS campaigns with comprehensive validation, real-time processing status, and detailed delivery reports. Perfect for marketing campaigns, notifications, and alerts.

Bulk SMS Campaign Tutorial (4:30 mins)
How to send bulk SMS campaigns with Sendexa API
4:30

Batch Processing

Process up to 10,000 messages per request with automatic rate limiting

Smart Validation

Pre-flight validation checks all numbers before processing starts

Detailed Reporting

Comprehensive success/failure reports with per-message breakdown

Credit Protection

Credits only deducted for successfully sent messages

10,000

Maximum messages per request

100 KB

Maximum request size

50

Maximum concurrent bulk jobs

24h

Job retention period

POST
/v1/sms/bulk
Bulk
Async

Bulk Upload Methods

{
"campaignName": "Summer Sale 2024",
"senderId": "StorePromo",
"messages": [
{
"to": "0555539152",
"message": "Hi John! Get 20% off today with code SAVE20",
"reference": "cust_12345"
},
{
"to": "0241234567",
"message": "Hi Sarah! Flash sale - 30% off all items!",
"reference": "cust_67890"
},
{
"to": "0209876543",
"message": "Hi Mike! Limited time offer - Buy 1 Get 1 Free",
"reference": "cust_24680"
}
],
"options": {
"scheduledFor": "2024-01-16T09:00:00Z",
"priority": "high",
"webhookUrl": "https://api.myapp.com/webhooks/bulk-status"
}
}

Request Schema

interface BulkSMSRequest {
/** Campaign name for reporting (optional) */
campaignName?: string;
/** Default sender ID for all messages */
senderId: string;
/** Array of messages (max 10,000) */
messages: Array<{
to: string; // Phone number
message: string; // Message content
reference?: string; // Your internal reference
senderId?: string; // Override default sender
}>;
/** Processing options */
options?: {
scheduledFor?: string; // ISO 8601 timestamp
priority?: 'high' | 'normal' | 'low';
webhookUrl?: string; // Status updates webhook
retryFailed?: boolean; // Auto-retry failed
maxRetries?: number; // Max retry attempts
encoding?: 'gsm' | 'unicode'; // Message encoding
};
}

Processing Pipeline

1

Validation

Checking phone numbers and sender IDs

~2s per 1000
2

Credit Check

Verifying sufficient balance

<1s
3

Queuing

Adding to processing queue

<1s
4

Processing

Sending to carriers

~5s per 1000
5

Reporting

Generating delivery report

~2s

Response

{
"success": true,
"message": "Bulk job accepted for processing",
"data": {
"jobId": "bulk_123456789_abc",
"status": "processing",
"totalMessages": 5000,
"estimatedCompletion": "2024-01-15T10:35:00Z",
"progress": 0,
"webhookUrl": "https://api.myapp.com/webhooks/bulk-status"
}
}
Throughput

2,500/second

Messages per second

Avg Latency

4.2s

End-to-end delivery

Success Rate

97.5%

Last 24 hours

Queue Length

1234

Pending messages

Implementation Examples

import requests
import base64
import csv
from typing import List, Dict
import time
class BulkSMSManager:
def __init__(self, api_key: str, api_secret: str):
self.base_url = "https://api.sendexa.co/v1"
self.auth = base64.b64encode(f"{api_key}:{api_secret}".encode()).decode()
self.headers = {
"Authorization": f"Basic {self.auth}",
"Content-Type": "application/json"
}
def send_bulk_from_csv(self, csv_path: str, sender_id: str, campaign: str = None):
"""Send bulk SMS from CSV file"""
messages = []
with open(csv_path, 'r') as file:
reader = csv.DictReader(file)
for row in reader:
messages.append({
"to": row['phone'],
"message": row['message'],
"reference": row.get('reference', '')
})
# Process in batches of 1000
batch_size = 1000
all_results = []
for i in range(0, len(messages), batch_size):
batch = messages[i:i + batch_size]
payload = {
"campaignName": campaign or f"Batch_{i//batch_size}",
"senderId": sender_id,
"messages": batch
}
# Submit batch
response = requests.post(
f"{self.base_url}/sms/bulk",
headers=self.headers,
json=payload
)
result = response.json()
if result.get('success'):
job_id = result['data']['jobId']
print(f"Batch {i//batch_size + 1} submitted: {job_id}")
# Monitor this batch
batch_result = self.monitor_bulk_job(job_id)
all_results.append(batch_result)
else:
print(f"Batch failed: {result.get('message')}")
return self.aggregate_results(all_results)
def monitor_bulk_job(self, job_id: str, poll_interval: int = 5):
"""Monitor bulk job until completion"""
while True:
response = requests.get(
f"{self.base_url}/sms/bulk/{job_id}",
headers=self.headers
)
data = response.json()
status = data['data']['status']
progress = data['data'].get('progress', 0)
print(f"Job {job_id}: {status} - {progress}% complete")
if status in ['completed', 'failed']:
return data['data']
time.sleep(poll_interval)
def aggregate_results(self, results: List[Dict]) -> Dict:
"""Aggregate results from multiple batches"""
aggregated = {
"total_messages": 0,
"successful": 0,
"failed": 0,
"total_credits": 0
}
for result in results:
aggregated["total_messages"] += result.get("totalMessages", 0)
aggregated["successful"] += result.get("successful", 0)
aggregated["failed"] += result.get("failed", 0)
aggregated["total_credits"] += result.get("totalCreditsUsed", 0)
aggregated["success_rate"] = f"{(aggregated['successful'] / aggregated['total_messages'] * 100):.1f}%"
return aggregated
# Usage
manager = BulkSMSManager('api_key', 'api_secret')
results = manager.send_bulk_from_csv('campaign.csv', 'StorePromo', 'SummerSale')
print(results)

Best Practices for Bulk SMS

Do's

  • ✓ Validate phone numbers before submitting
  • ✓ Use reference IDs for tracking responses
  • ✓ Implement webhooks for status updates
  • ✓ Split large campaigns into batches
  • ✓ Monitor credit balance before sending

Don'ts

  • ✗ Don't send during restricted hours (9pm-6am)
  • ✗ Don't use special characters in sender IDs
  • ✗ Don't exceed 1530 characters per message
  • ✗ Don't ignore failed message reports
  • ✗ Don't retry failed messages without analysis

Performance Optimization Tips

Batch Size Optimization

Optimal batch size is 500-1000 messages per request. Larger batches may timeout, smaller batches increase API calls.

Schedule Smartly

Schedule campaigns during business hours (8am-8pm) for best delivery rates. Avoid Monday mornings and Friday evenings.

Pre-validation

Validate all numbers client-side before submitting to reduce failures and save time.

Advanced Features

A/B Testing

Test different message variants with automatic winner selection

Dynamic Segmentation

Automatically segment recipients based on delivery patterns

Export Reports

Download detailed CSV reports of all bulk operations