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

Send Single SMS

Send an SMS message to a single recipient. This endpoint queues the message for delivery and returns the message status immediately.

Authentication Required

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

Common Use Cases

OTP & verification codes
Order confirmations & receipts
Appointment reminders
Payment notifications
Account alerts
Customer notifications

Request Parameters

ParameterTypeRequiredDescription
phone_numberstringRequiredRecipient phone number in international format
Example: +254712345678
text_messagestringRequiredSMS message content to be sent
Example: Hello from RoyceTalk API
sender_idstringRequiredYour approved sender ID. Must be registered with your account.
Example: RoyceLTD
callback_urlstringOptionalWebhook URL to receive delivery status updates
Example: https://yourapp.com/webhooks/sms
client_refstringOptionalYour internal reference ID for tracking
Example: order-12345
scheduled_atstringOptionalSchedule SMS 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/"
BEARER_TOKEN = "XXXX_XXXXXXXXXXXXXXXXXXXXXXXX_"

def send_sms(phone_number: str, message: str, sender_id: str):
    """
    Send a single SMS via RoyceTalk API
    
    Args:
        phone_number: Recipient phone number (format: +254XXXXXXXXX)
        message: SMS message content
        sender_id: Your approved sender ID
        
    Returns:
        dict: API response with message status
    """
    
    # Request headers with Bearer token
    headers = {
        "Authorization": f"Bearer {BEARER_TOKEN}",
        "Content-Type": "application/json"
    }
    
    # Request payload
    payload = {
        "phone_number": phone_number,
        "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("✓ SMS sent successfully!")
            print(f"Message ID: {result['data']['message_id']}")
            print(f"Status: {result['data']['status']}")
            print(f"Cost: KES {result['data']['cost']}")
            print(f"Balance: {result['data']['balance_after']} 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__":
    result = send_sms(
        phone_number="+254712345678",
        message="Hello, this is a test message from Royce SMS API.",
        sender_id="RoyceLTD"
    )
    
    if result:
        print("\nFull Response:")
        print(json.dumps(result, indent=2))

Response Examples

{
  "success": true,
  "data": {
    "message_id": "f2672215-c20b-452a-9b6b-1ba51884c55e",
    "batch_id": "ba25e6fe-7aee-4df4-8f2c-062475061c62",
    "status": "pending",
    "recipient": "+254712345678",
    "sms_units": 1,
    "cost": "0.50",
    "balance_before": 9911,
    "balance_after": 9910,
    "scheduled_at": null
  },
  "message": "SMS queued successfully",
  "meta": {
    "timestamp": "2025-11-28T13:49:13.265444+00:00",
    "api_version": "v1"
  },
  "errors": []
}

SMS Units & Pricing

1-160 characters:1 SMS unit (KES 0.50)

161-306 characters:2 SMS units (KES 1.00)

307+ characters:Calculated as ceil(length/153) units

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

Integration Guides

Odoo Integration

Install our Odoo app from the Odoo App Store to send SMS directly from your Odoo instance. Supports automated notifications and bulk messaging.

Laravel Package

Use the code example above to integrate RoyceTalk SMS into your Laravel application. Create a service class for reusable SMS functionality.

Rate Limiting

API keys have configurable rate limits. If you exceed your limit, you'll receive a 429 Too Many Requests response. Contact support to adjust your limits.