SMS
The client.sms resource handles single sends, client-side send-many, server-side bulk, and message logs. Types are camelCase (messageId, creditsUsed, toPhone).
Send a single message
Phone numbers are normalized to E.164 by default; pass skipPhoneNormalization: true to keep your format as-is:
const result = await client.sms.send(
{
to: '0712345678',
message: 'Welcome to SendAfrica!',
from: 'SENDAFRICA', // optional registered sender ID
},
{
idempotencyKey: 'order-123', // optional safe retries
}
)
console.log(result.messageId, result.creditsUsed, result.requestId)Returns a typed SendSmsResult: messageId, status, cost, creditsUsed, requestId, timestamp.
Send many (client-side, paced)
Different messages to many recipients, with per-message failure collection instead of aborting the batch:
const res = await client.sms.sendMany(
[
{ to: '0712345678', message: 'Hi Ali' },
{ to: '0765432109', message: 'Hi Zainab', idempotencyKey: 'm2' },
],
{ rateLimitPerSec: 10.0 } // default 10
)
console.log(res.results.length, res.failed)Per-message failures are collected in res.failed ({index, to, error}).
Server-side bulk SMS
One message to many recipients in a single API call. The SDK caps at 100 recipients; the server reports and refunds partial failures per recipient.
const bulk = await client.sms.bulk({
to: ['0712345678', '0765432109'],
message: 'Black Friday starts now!',
from: 'MYBRAND',
})
console.log(bulk.total, bulk.sent, bulk.failed)
for (const r of bulk.results) {
console.log(r.to, r.status, r.messageId, r.error)
}Message logs
const logs = await client.sms.logs({
page: 1,
perPage: 25,
status: 'delivered', // pending | sent | delivered | failed
search: '0712345678',
dateFrom: '2026-09-01T00:00:00Z',
})
for (const entry of logs.items) {
console.log(entry.toPhone, entry.status, entry.creditsUsed, entry.deliveredAt)
}With a dashboard JWT (instead of the API key):
const logs = await client.sms.logsJwt(jwtToken, { page: 1, perPage: 25, status: 'sent' })Client-side SMS analysis
const info = getSmsPartInfo('Hello world from SendAfrica 🇹🇿')
console.log(info) // { encoding: 'UCS-2', length: ..., parts: 1, creditsRequired: 1 }No network call — runs entirely locally. See SMS Calculator.
Reference
| Method | Endpoint | Returns |
|---|---|---|
sms.send(params, options?) | POST /sms | SendSmsResult |
sms.sendMany(messages, options?) | Loops POST /sms | BulkSMSResult |
sms.bulk({to, message, from?}) | POST /sms/bulk | BulkSendResult |
sms.logs(query?) | GET /sms/logs | MessageLogListResponse |
sms.logsJwt(jwtToken, query?) | GET /sms/logs (JWT) | MessageLogListResponse |
Delivery confirmation is asynchronous — see Webhooks and Delivery Status.