Phone Numbers
Top-level helpers handle Tanzania phone validation and normalization.
import {
normalizeTzPhone,
isValidTzPhone,
TZ_MOBILE_PREFIXES,
} from 'sendafrica'
normalizeTzPhone('0712345678') // '+255712345678'
isValidTzPhone('0712345678') // true
console.log(TZ_MOBILE_PREFIXES)
// ['071','072','073','074','075','076','077','078','068','069']| Helper | Description |
|---|---|
normalizeTzPhone(input) | Converts 0712345678, 255..., +255... to E.164 +255...; throws InvalidPhoneNumberError otherwise. |
isValidTzPhone(input) | Returns boolean. |
TZ_MOBILE_PREFIXES | Allowed Tanzania mobile prefixes ('071'–'078', '068', '069'). |
Inside client.sms.send(...), phone numbers are normalized automatically by default. Pass skipPhoneNormalization: true in the request to send the value exactly as given. International destinations must be present in GET /v1/rates to be billable.
Last updated on