Nyota SMS
Sending Messages
Dispatching single transactional messages and bulk broadcasts.
You can dispatch SMS messages to a single recipient or broadcast to an array of up to 1,000 recipients in a single call.
Phone Number Normalization
The Nyota API automatically validates and standardizes Kenyan phone numbers. You can supply numbers in any common format:
0712345678➔2547123456780112345678➔254112345678+254712345678➔254712345678712345678➔254712345678
1. Single Transactional SMS (OTP / Alerts)
Use for real-time verification codes, booking confirmations, or security alerts.
import { NyotaSms } from "@nyota/sms-sdk";
const sms = new NyotaSms({ apiKey: process.env.NYOTA_API_KEY! });
const response = await sms.messages.send({
recipient: "0787654321",
message: "Your Nyota verification code is 482910.",
senderId: "NYOTA", // Optional: uses platform default if omitted
});
console.log(`Dispatched! Units deducted: ${response.unitsDeducted}`);2. Bulk SMS Broadcasts
Pass an array of numbers to recipients. The backend will deduplicate numbers, format them, and process carrier batches automatically.
const broadcast = await sms.messages.send({
recipients: ["0787654321", "0712345678", "0712348765"],
message: "Flash sale alert: 20% off all domain registrations this weekend!",
senderId: "MYBRAND",
});
console.log(
`Successfully sent to ${broadcast.successfulDispatches} recipients.`,
);
console.log(`Total units deducted: ${broadcast.unitsDeducted}`);3. Offline Segment & Phone Utilities
Calculate message segments and sanitize phone numbers locally in your application with zero network latency:
import { NyotaSms } from "@nyota/sms-sdk";
// 1. Calculate GSM-7 vs UCS-2 Unicode segments
const info = NyotaSms.calculateSegments("Meeting at 5pm! 😊");
console.log(info);
// => { encoding: 'UCS-2', characterCount: 16, segments: 1, charactersRemainingInSegment: 54, unitsPerRecipient: 1 }
// 2. Normalize Phone Numbers
const cleanPhone = NyotaSms.formatPhoneNumber("0793-464-784");
console.log(cleanPhone); // "254787654321"
const isValid = NyotaSms.isValidPhoneNumber("0712345678"); // trueRaw REST API Example
curl -X POST "https://backend.nyotaimara.com/v1/sms/send" \
-H "Content-Type: application/json" \
-H "x-nyota-api-key: ny_live_..." \
-H "x-idempotency-key: 550e8400-e29b-41d4-a716-446655440000" \
-d '{
"message": "Hello from Nyota SMS!",
"recipients": ["0787654321", "0712345678"]
}'