POST/api/v1/sms-api/send-bulk/

Send Bulk SMS

Send the same SMS message to multiple recipients in a single API call. Perfect for campaigns, notifications, and alerts to large groups.

Authentication Required

This endpoint requires a Bearer token. Get your API key from your dashboard.

Common Use Cases

Marketing campaigns
Event reminders & invitations
Emergency alerts
Product announcements
System notifications
Group communications

Bulk Sending Best Practices

  • Recommended batch size: 1,000-5,000 recipients per request
  • Check balance first: Use /calculate-cost/ to estimate total cost
  • Rate limits apply: Consider your account's per-hour/per-day limits
  • Track with batch_id: Use the returned batch_id to monitor delivery
  • Invalid numbers: Invalid phone numbers are automatically skipped

Request Parameters

ParameterTypeRequiredDescription
phone_numberarrayRequiredArray of recipient phone numbers in international format
Example: ["+254712345678", "+254722334455"]
text_messagestringRequiredSMS message content to be sent to all recipients
Example: Hello from RoyceBulkSMS API
sender_idstringRequiredYour approved sender ID. Must be registered with your account.
Example: RoyceLTD
callback_urlstringOptionalWebhook URL to receive delivery status updates for all messages
Example: https://yourapp.com/webhooks/sms
client_refstringOptionalYour internal campaign/batch reference ID for tracking
Example: campaign-12345
scheduled_atstringOptionalSchedule all messages for future delivery (ISO 8601 format, UTC)
Example: 2025-01-15T10:30:00Z

Code Examples

import requests
import json

# Configuration
# Get your API key from: https://roycetalk.com/
# Format: XXXX_XXXXXXXXXXXXXXXXXXXXXXXX_
API_URL = "https://roycetalk.com/api/v1/sms-api/send-bulk/"
BEARER_TOKEN = "XXXX_XXXXXXXXXXXXXXXXXXXXXXXX_"

def send_bulk_sms(phone_numbers: list, message: str, sender_id: str):
    """
    Send bulk SMS to multiple recipients via RoyceBulkSMS API
    
    Args:
        phone_numbers: List of recipient phone numbers (format: +254XXXXXXXXX)
        message: SMS message content
        sender_id: Your approved sender ID
        
    Returns:
        dict: API response with batch status
    """
    
    # Request headers with Bearer token
    headers = {
        "Authorization": f"Bearer {BEARER_TOKEN}",
        "Content-Type": "application/json"
    }
    
    # Request payload
    payload = {
        "phone_number": phone_numbers,
        "sender_id": sender_id,
        "text_message": message
    }
    
    try:
        # Make POST request
        response = requests.post(API_URL, json=payload, headers=headers)
        
        # Check if request was successful
        if response.status_code == 200:
            result = response.json()
            print("✓ Bulk SMS queued successfully!")
            print(f"Batch ID: {result['data']['batch_id']}")
            print(f"Total Recipients: {result['data']['total_recipients']}")
            print(f"Messages Queued: {result['data']['messages_queued']}")
            print(f"Messages Failed: {result['data']['messages_failed']}")
            print(f"Total Cost: KES {result['data']['total_cost']}")
            print(f"Balance: {result['data']['balance_remaining']} units")
            return result
            
        elif response.status_code == 403:
            error = response.json()
            print(f"✗ Authentication Error: {error['error']['message']}")
            return None
            
        elif response.status_code == 400:
            error = response.json()
            print(f"✗ Validation Error: {error['message']}")
            if 'errors' in error and error['errors']:
                for err in error['errors']:
                    print(f"  - {err['message']}")
            return None
            
        else:
            print(f"✗ Unexpected Error: {response.status_code}")
            print(response.text)
            return None
            
    except requests.exceptions.RequestException as e:
        print(f"✗ Request failed: {str(e)}")
        return None

# Example usage
if __name__ == "__main__":
    # List of recipients
    recipients = [
        "+254712345678",
        "+254722334455",
        "+254733445566"
    ]
    
    result = send_bulk_sms(
        phone_numbers=recipients,
        message="Hello! This is a bulk message to all recipients.",
        sender_id="RoyceLTD"
    )
    
    if result:
        print("\nFull Response:")
        print(json.dumps(result, indent=2))

Response Examples

{
  "success": true,
  "data": {
    "batch_id": "ba25e6fe-7aee-4df4-8f2c-062475061c62",
    "total_recipients": 3,
    "messages_queued": 3,
    "messages_failed": 0,
    "total_units": 3,
    "total_cost": "1.50",
    "balance_remaining": 9908,
    "message_ids": [
      "f2672215-c20b-452a-9b6b-1ba51884c55e",
      "a1234567-c20b-452a-9b6b-1ba51884c55e",
      "b7890123-c20b-452a-9b6b-1ba51884c55e"
    ]
  },
  "message": "Bulk SMS queued successfully - 3 messages",
  "meta": {
    "timestamp": "2025-11-28T13:49:13.265444+00:00",
    "api_version": "v1"
  },
  "errors": []
}

Response Fields

batch_id

Unique identifier for this bulk send. Use this to track delivery status.

total_recipients

Total number of phone numbers in your request.

messages_queued

Number of messages successfully queued for delivery.

messages_failed

Number of messages that failed validation (invalid numbers, etc.).

message_ids

Array of individual message IDs. Use these to track specific deliveries.

SMS Units & Pricing

Cost per recipient:Same as single SMS (KES 0.50 per unit)

Example:100 recipients × 1 unit = 100 units (KES 50.00)

Tip: Use the /calculate-cost/ endpoint to estimate exact costs before sending.

Tracking Bulk Delivery

Option 1: Check Batch Status

Use the batch_id to check overall status:

GET /api/v1/sms-api/batches/{batch_id}/

Option 2: Webhooks (Recommended)

Provide a callback_url to receive automatic delivery status updates for each message.

Option 3: Check Individual Messages

Use individual message_ids from the response:

GET /api/v1/sms-api/messages/{message_id}/

Rate Limiting

API keys have configurable rate limits (per minute/hour/day). Large bulk sends may be throttled. For very large campaigns (>10,000 recipients), contact support to adjust your limits or split into multiple batches.