Phone Numbers
SendAfrica’s SDKs normalize recipient phone numbers for you before they touch the network.
Accepted formats
| Format | Example | Result |
|---|---|---|
| Tanzania local | 0712345678 | Normalized to +255712345678 |
International with + | +255712345678 | Passed through |
International without + | 255712345678 | Normalized with country code |
Tanzania mobile prefixes are 071–078, 068, and 069. Anything else fails validation and raises InvalidPhoneError locally — before any request is sent.
Why normalization matters
- The API expects E.164 on the wire; the SDK converts local numbers for you.
- Validation happens before the network call, so typos fail fast instead of costing credits.
- International destinations must be present in
GET /v1/ratesto be billable.
Test your own numbers
from sendafrica.utils import normalize_phone, is_valid_tz_mobile
normalize_phone("0712345678") # '+255712345678'
is_valid_tz_mobile("0712345678") # TrueThe same logic runs inside sms.send — send a top-up OTP to your own phone and check the message arrives with the to as you typed it.
Last updated on