Tokens you control
Create and revoke API tokens from the portal at any time.
A small REST API for bulk, subscription and on-demand messages. Create a token in the portal and send your first message with one request.
Every request goes to https://app.sharasms.co.ke and carries your token in the Authorization header. Your short_code_id is shown in the portal.
curl -X POST https://app.sharasms.co.ke/api/messages/new \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"message": "Your code is 482913",
"phone": "2547xxxxxxxx",
"short_code_id": "<short_code_id>"
}'
$ch = curl_init('https://app.sharasms.co.ke/api/messages/new');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'message' => 'Your code is 482913',
'phone' => '2547xxxxxxxx',
'short_code_id' => $shortCodeId,
]),
]);
$response = curl_exec($ch);
{
"message": "Our offices are closed on Friday.",
"phone": ["2547xxxxxxxx", "2541xxxxxxxx"],
"short_code_id": "<short_code_id>"
}
curl -X POST https://app.sharasms.co.ke/api/messages/new/subscription \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"message": "Today's tip: ...",
"phone": "2547xxxxxxxx",
"short_code_id": "<short_code_id>"
}'
curl -X POST https://app.sharasms.co.ke/api/messages/new/on-demand \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"message": "Here is the result you asked for.",
"phone": "2547xxxxxxxx",
"short_code_id": "<short_code_id>",
"linkid": "<linkid>"
}'
Create and revoke API tokens from the portal at any time.
Numbers that are not valid are skipped and logged, while the rest of the batch still goes out.
Numbers on your blacklist are never sent to, even when they appear in an API request.
If you do not have enough units for a request, the API returns a 422 error and nothing is sent.
Kenyan numbers are routed to the right network automatically. International numbers are supported too.
Follow the status of every message from the portal.
Create an account in a minute, buy units from KES 0.40 each, and start sending today.