Bulk SMS API in Kenya: Send Your First SMS in 5 Minutes

By Brian Published 4 min read

If your website, app or school system needs to send OTPs, receipts, reminders or alerts, you do not send them by hand: you call an SMS API. This quick-start shows how to send your first SMS in Kenya with the Brilio SMS API in about five minutes, with copy-paste examples in cURL, Python, Node.js and PHP.

Short answer: create an API key in your portal, then send a POST request to https://sms-api.briliotechnologies.com/v1/messages/send/ with your key in the Authorization header and the Sender ID, message and phone numbers in the body. A sandbox key lets you test without sending real messages or paying. Bulk SMS starts from KES 0.70 per SMS on Safaricom.

Step 1: get an API key

  1. Sign up and verify your email.
  2. In your portal, open Settings → API Keys and create a key.
  3. Start with a sandbox key: requests behave exactly like live ones, but no SMS is sent and your wallet is not charged. Switch to a live key when you are ready.

Keep the key secret: put it in an environment variable, never in front-end code.

Step 2: send a message

Every request goes to one endpoint:

POST https://sms-api.briliotechnologies.com/v1/messages/send/
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

with a body like this:

{
  "send_path": "direct",
  "sms_type": "transactional",
  "sender_id": "BRILIOTECH",
  "message": "Your verification code is 482913. It expires in 5 minutes.",
  "recipients": ["0712345678"]
}
Field What to send
send_path direct for up to 50 numbers in recipients; group to send to a saved contact group; file_upload for a CSV
sms_type transactional for OTPs, alerts and receipts; promotional for marketing
sender_id Your approved Sender ID, for example your business name
message The text. 160 characters is one SMS (70 if it contains emoji)
recipients Phone numbers such as 0712345678 or 254712345678

cURL

curl -X POST https://sms-api.briliotechnologies.com/v1/messages/send/ \
  -H "Authorization: Bearer $BRILIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"send_path":"direct","sms_type":"transactional","sender_id":"BRILIOTECH","message":"Your code is 482913.","recipients":["0712345678"]}'

Python

import os
import requests

response = requests.post(
    "https://sms-api.briliotechnologies.com/v1/messages/send/",
    headers={"Authorization": f"Bearer {os.environ['BRILIO_API_KEY']}"},
    json={
        "send_path": "direct",
        "sms_type": "transactional",
        "sender_id": "BRILIOTECH",
        "message": "Your code is 482913.",
        "recipients": ["0712345678"],
    },
    timeout=30,
)
print(response.status_code, response.json())

Node.js

const response = await fetch("https://sms-api.briliotechnologies.com/v1/messages/send/", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRILIO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    send_path: "direct",
    sms_type: "transactional",
    sender_id: "BRILIOTECH",
    message: "Your code is 482913.",
    recipients: ["0712345678"],
  }),
});
console.log(response.status, await response.json());

PHP

<?php
$ch = curl_init("https://sms-api.briliotechnologies.com/v1/messages/send/");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("BRILIO_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "send_path" => "direct",
        "sms_type" => "transactional",
        "sender_id" => "BRILIOTECH",
        "message" => "Your code is 482913.",
        "recipients" => ["0712345678"],
    ]),
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE) . " " . $response;

Step 3: read the response

A successful send returns 201 with a summary:

Field Meaning
batch_id Your reference for the send, shown in your portal's campaign history
transaction_id The network reference, useful when contacting support
total_recipients How many numbers the message went to
cost_kes What was charged to your wallet

Common errors: 401 means the API key is missing or wrong, 429 means you are sending too fast (wait and retry), and 502 means the network could not process the request (safe to retry).

Sending to more than 50 people

  • Contact groups: save your customers or members as a group once, then send with "send_path": "group" and the group's contact_group_id.
  • CSV upload: send a file with an msisdn column using "send_path": "file_upload". Any other column can be used as a placeholder, for example [balance], so every person gets their own details.

Tips for production

  1. Use transactional for OTPs and receipts, promotional for marketing. They are treated differently by the networks.
  2. Register your Sender ID early. Until it is approved you cannot send under your own name. See Sender ID registration in Kenya.
  3. Keep OTPs short and say how long they are valid.
  4. Retry safely: retry only on 429 and 502, with a short wait.
  5. Watch delivery reports in the portal to spot numbers that never receive messages.

The full reference, including groups, scheduling and every field, is in our developer documentation.

Related guides: Bulk SMS prices in Kenya · How to build a USSD menu · How to choose a bulk SMS provider

Frequently asked questions

Is there a free way to test the SMS API?

Yes. A sandbox API key behaves like a live key, but no SMS is sent and your wallet is not charged.

How much does it cost to send SMS through the API?

The same as sending from the portal: from KES 0.70 per SMS on Safaricom, lower as you send more. There is no monthly fee for API access.

Can I send OTPs with the SMS API?

Yes. Send them as transactional messages under your approved Sender ID.

How many numbers can I send to in one request?

Up to 50 numbers with direct. For more, use a contact group or a CSV upload in a single request.

Which programming languages are supported?

Any language that can make an HTTPS request: Python, PHP, Node.js, Java, C#, Go and others. The examples above cover the most common ones.

Ready to integrate? Get started with bulk SMS in Kenya.

Your Partner In Communications & Automation.