Why your app needs SMS

If you are building an app or website in Uganda, SMS is one of the highest-impact features you can add. Common uses:

Yoola SMS gives you a free REST API you can call from any language. You pay only for the SMS you send.

Step 1: Get your API key

  1. Create a free account at yoolasms.com/register.
  2. Log in and open API Key in the dashboard.
  3. Copy your key and keep it private. Anyone who has it can spend your credits.
  4. Top up with Mobile Money when you are ready to send beyond your free test SMS.

Step 2: The send endpoint

POST https://yoolasms.com/api/v1/send
Content-Type: application/json

{
  "api_key": "YOUR_API_KEY",
  "phone": "256772123456",
  "message": "Your OTP is 123456",
  "sender": "YoolaSMS"
}

A typical response looks like this:

{
  "status": "success",
  "message_id": 12345,
  "recipients": 1,
  "successful": 1,
  "failed": 0,
  "credits_used": 1,
  "credits_refunded": 0,
  "balance": 284
}

Important: "success" means the network accepted your message. It is not a confirmation that the handset received it. Use the delivery report (below) to follow a message later.

Several recipients in one call

Pass a comma-separated list in phone:

"phone": "256772123456,256752987654,256702111222"

The response tells you how many succeeded and failed. Credits for failed recipients are returned to your balance automatically (see credits_refunded).

Code samples

PHP

<?php
$data = [
    "api_key" => "YOUR_API_KEY",
    "phone"   => "256772123456",
    "message" => "Hello from your app!",
    "sender"  => "YoolaSMS"
];

$ch = curl_init("https://yoolasms.com/api/v1/send");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);

if (($result["status"] ?? "") === "success") {
    echo "Sent. Balance: " . $result["balance"];
} else {
    echo "Not sent: " . json_encode($result);
}
?>

Python

import requests

response = requests.post(
    "https://yoolasms.com/api/v1/send",
    json={
        "api_key": "YOUR_API_KEY",
        "phone":   "256772123456",
        "message": "Hello from your Python app!",
        "sender":  "YoolaSMS",
    },
    timeout=20,
)
print(response.json())

JavaScript (Node.js 18 or newer)

async function sendSMS() {
  const response = await fetch("https://yoolasms.com/api/v1/send", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      api_key: process.env.YOOLA_API_KEY,
      phone: "256772123456",
      message: "Hello from Node.js!",
      sender: "YoolaSMS",
    }),
  });
  console.log(await response.json());
}
sendSMS();

Python Django (in a view)

import requests
from django.conf import settings
from django.http import JsonResponse

def send_welcome(request):
    phone = request.POST.get("phone")
    r = requests.post(
        "https://yoolasms.com/api/v1/send",
        json={
            "api_key": settings.YOOLA_API_KEY,
            "phone":   phone,
            "message": "Welcome to MyApp!",
            "sender":  "YoolaSMS",
        },
        timeout=20,
    )
    return JsonResponse({"sent": r.json().get("status") == "success"})

Laravel

use Illuminate\Support\Facades\Http;

$response = Http::post("https://yoolasms.com/api/v1/send", [
    "api_key" => config("services.yoola.key"),
    "phone"   => $user->phone,
    "message" => "Welcome to MyApp, {$user->name}!",
    "sender"  => "YoolaSMS",
]);

return response()->json($response->json());

Prefer a ready-made library? Free PHP, Python and Node.js libraries and a WordPress/WooCommerce plugin are on the API page.

OTP codes: the easy way and the DIY way

The easy way: Yoola Verify creates, sends and checks the code for you, including expiry and retry limits. You make two calls, verify-send and verify-check. Details are on the API page.

The DIY way (if you want to store codes yourself):

<?php
// 1. Generate a secure code
$otp = random_int(100000, 999999);

// 2. Store only a hash, with an expiry
$stmt = $pdo->prepare(
    "INSERT INTO otps (phone, otp_hash, expires_at) VALUES (?, ?, NOW() + INTERVAL 5 MINUTE)"
);
$stmt->execute([$phone, password_hash((string)$otp, PASSWORD_DEFAULT)]);

// 3. Send it with Yoola SMS (use the same call as the PHP sample above)
$message = "Your verification code is {$otp}. Valid for 5 minutes. Do not share it.";
?>

Also limit wrong attempts (five is a good number) and limit how often one phone number can request a code, otherwise bots can drain your balance.

Best practices for production

1. Keep your API key out of your code

Use environment variables and never commit the key to Git. Never put it inside a mobile app or a web page that visitors can view.

YOOLA_API_KEY=your_key_here

2. Always check the response

Check status on every call. Errors such as insufficient credits come back as normal JSON, not as an HTTP failure, so your code must read them.

3. Be careful with retries

If a request times out, you do not know whether the SMS was sent. Retrying blindly can message the customer twice. Check your own log or the delivery report first, then retry once at most.

4. Validate numbers before sending

Reject obviously wrong numbers on your side to save credits:

function isValidUgandaNumber($phone) {
    $phone = preg_replace('/[^0-9]/', '', $phone);
    return preg_match('/^(256|0)7[0-9]{8}$/', $phone) === 1;
}

5. Log every SMS

Keep your own table with the phone, the message, the message_id and the status, for audits and customer disputes.

6. Watch your balance

Every send returns your remaining balance. Alert your team when it gets low so important messages are never blocked:

if ($result["balance"] < 100) {
    mail($adminEmail, "SMS credits low", "Only " . $result["balance"] . " credits left.");
}

Common API questions

Are there rate limits?

Yes. Sending is limited per account to protect customers and networks from abuse, and very large sends are queued and processed automatically in the background. If you need higher limits for a verified, high-volume use case, contact support@yoolasms.com.

Can I send outside Uganda?

Yes. Include the country code in the number, for example 254 for Kenya, 255 for Tanzania, 250 for Rwanda. Rates differ by country, see the Coverage page. Some international routes are enabled per account, so ask support if a country is blocked.

How do I check delivery?

The send response confirms the network accepted the message. To follow it afterwards, call the delivery_report endpoint with your message_id. Customers can also open the Delivery Report page in their dashboard.

How do I test without wasting money?

Every new account gets free test SMS. Send to your own phone first. Do not load-test with real customer numbers.

Ready to integrate?

Get your free API key in about two minutes. The API is free to use, you only pay for the SMS you send.

Get your free API key →

Or read the full API documentation.