Documentation
Getting Started
API Reference
SMS API
Contacts API
OTP API
Voice API
MMS API
WhatsApp API
Viber API
HTTP API
HTTP Endpoints
HTTP SMS API
Quick Start Guide
Get your first API call working in 5 minutes with step-by-step instructions.
1. Create an Account
Sign up for a free account at OpenSMS. No credit card required.
2. Get Your API Key
After signing up, go to your dashboard and copy your API key from the settings page.
3. Send Your First SMS
Using cURL
curl -X POST https://api.opensms.co.ke/v3/sms/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "+254712345678",
"message": "Hello from OpenSMS!"
}'
Using PHP
<?php
$ch = curl_init('https://api.opensms.co.ke/v3/sms/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'phone' => '+254712345678',
'message' => 'Hello from OpenSMS!'
]));
$response = curl_exec($ch);
$result = json_decode($response, true);
print_r($result);
?>
Using Python
import requests
url = 'https://api.opensms.co.ke/v3/sms/send'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
data = {
'phone': '+254712345678',
'message': 'Hello from OpenSMS!'
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
Using Node.js
const axios = require('axios');
const url = 'https://api.opensms.co.ke/v3/sms/send';
const headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
};
const data = {
phone: '+254712345678',
message: 'Hello from OpenSMS!'
};
axios.post(url, data, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));
4. Check the Response
A successful response looks like this:
{
"status": "success",
"message_id": "msg_123456",
"phone": "+254712345678",
"message": "Hello from OpenSMS!",
"cost": 1,
"balance": 99
}