Welcome to the OLIN SMS API documentation. Our API allows you to send SMS messages, manage your account balance, and track message delivery programmatically.
The API uses token-based authentication. You need to login first to get an authentication token, then include it in subsequent requests.
curl -X POST http://sms.scholar.ke/api/login \
-H "Content-Type: application/json" \
-d '{
"email": "your@email.com",
"password": "your_password"
}'
Response
{
"code": 200,
"state": "success",
"data": {
"user": { ... },
"token": "1|abc123...",
"message": "Login successful"
}
}
Include the token in the Authorization header for all protected endpoints:
Authorization: Bearer YOUR_TOKEN_HERE
/api/register
Register a new user account
/api/login
Login and get authentication token
/api/logout
Logout and revoke token
/api/balance
Get your current SMS balance
/api/topup
Initiate M-Pesa STK Push payment
/api/pool
Queue messages for sending (single or group)
/api/messages
Retrieve messages with optional filtering
/api/delivery
Get delivery reports for specific messages
cURL
curl -X POST http://sms.scholar.ke/api/pool \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"to": "0712345678",
"message": "Hello from OLIN SMS!",
"mode": "single"
}'
PHP (using Guzzle)
<?php
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'http://sms.scholar.ke/api/',
'headers' => [
'Authorization' => 'Bearer YOUR_TOKEN',
'Content-Type' => 'application/json',
]
]);
$response = $client->post('pool', [
'json' => [
'to' => '0712345678',
'message' => 'Hello from OLIN SMS!',
'mode' => 'single'
]
]);
$result = json_decode($response->getBody(), true);
print_r($result);
JavaScript (using Fetch)
const sendSMS = async () => {
const response = await fetch('http://sms.scholar.ke/api/pool', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: '0712345678',
message: 'Hello from OLIN SMS!',
mode: 'single'
})
});
const data = await response.json();
console.log(data);
};
sendSMS();
Python (using Requests)
import requests
url = 'http://sms.scholar.ke/api/pool'
headers = {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
}
data = {
'to': '0712345678',
'message': 'Hello from OLIN SMS!',
'mode': 'single'
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
curl -X POST http://sms.scholar.ke/api/pool \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"to": [1, 2, 3],
"message": "Bulk message to multiple groups",
"mode": "group"
}'
curl -X POST http://sms.scholar.ke/api/balance \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Response
{
"code": 200,
"state": "success",
"data": {
"balance": 1500,
"account_number": "ABC123",
"sender_id": "OLIN_SMS"
}
}
All API responses follow a consistent format. Errors include detailed information to help you debug issues.
Error Response Format
{
"code": 400,
"state": "error",
"data": {
"message": "Invalid phone number format",
"errors": {
"phone": ["The phone field is required."]
}
}
}
Common HTTP Status Codes
Store your token securely
Never expose your API token in client-side code or public repositories.
Check balance before sending
Always verify you have sufficient balance before pooling messages.
Handle errors gracefully
Implement proper error handling and retry logic in your application.
Validate phone numbers
Ensure phone numbers are in valid Kenyan format (0712345678 or +254712345678).
Use HTTPS in production
Always use HTTPS to ensure secure communication with the API.
If you have questions or need assistance integrating with our API, please don't hesitate to reach out.
Contact Support