Skip to main content

Send SMS

Send a single SMS message to one recipient. This is the most common SMS operation: ideal for OTPs, transactional alerts, and notifications. For sending to many recipients in one request, use Bulk SMS.

๐Ÿ“ก Endpointโ€‹

POST /v1/sms/send

Base URL: https://api.afriroute.ai

๐Ÿ”‘ Authenticationโ€‹

Authorization: Bearer $AFRIROUTE_API_KEY
Content-Type: application/json

๐Ÿ“ฅ Request Parametersโ€‹

FieldTypeRequiredDescription
tostringYesRecipient phone number in E.164 format (e.g. +251911234567)
fromstringYesRegistered sender ID or phone number (alphanumeric, 3-11 chars)
textstringYesMessage content (up to 1600 characters / multiple parts)
callback_urlstringNoWebhook URL to receive delivery reports
metadataobjectNoCustom key-value data echoed back in callbacks

๐Ÿ“ค Example Requestโ€‹

curl -X POST https://api.afriroute.ai/api/v1/sms/send \
-H "Authorization: Bearer $AFRIROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+251911234567",
"from": "AFRIROUTE",
"text": "Your OTP is 123456. Valid for 5 minutes.",
"callback_url": "https://yourapp.com/webhooks/sms",
"metadata": { "order_id": "ord_9981" }
}'
const response = await fetch('https://api.afriroute.ai/api/v1/sms/send', {
method: 'POST',
headers: {
'Authorization': 'Bearer $AFRIROUTE_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: '+251911234567',
from: 'AFRIROUTE',
text: 'Your OTP is 123456. Valid for 5 minutes.',
callback_url: 'https://yourapp.com/webhooks/sms'
})
});

const data = await response.json();
console.log(data.message_id); // msg_abc123xyz
import requests

response = requests.post(
'https://api.afriroute.ai/api/v1/sms/send',
headers={'Authorization': 'Bearer $AFRIROUTE_API_KEY'},
json={
'to': '+251911234567',
'from': 'AFRIROUTE',
'text': 'Your OTP is 123456. Valid for 5 minutes.',
'callback_url': 'https://yourapp.com/webhooks/sms',
},
)
print(response.json()['message_id'])

โœ… Responseโ€‹

200 OK

{
"message_id": "msg_abc123xyz",
"status": "queued",
"to": "+251911234567",
"from": "AFRIROUTE",
"parts": 1,
"cost": 0.05,
"currency": "ETB",
"created_at": "2026-05-28T10:30:00Z"
}
FieldDescription
message_idUnique identifier; use it to fetch status
statusOne of queued, sent, delivered, failed
partsNumber of message segments billed
costTotal cost for this message
currencyISO 4217 currency code (e.g. ETB)

๐Ÿ”ข Message Segmentsโ€‹

Standard GSM-7 messages fit 160 characters per part. Including any non-GSM (Unicode) character switches the message to UCS-2 encoding, reducing capacity to 70 characters per part. Longer text is split into concatenated parts, and you are billed per part (parts in the response).

๐Ÿ’ก Best Practicesโ€‹

  • Validate numbers in E.164 format before sending.
  • Use a registered sender ID for the best deliverability โ€” see Sender IDs.
  • Keep transactional messages under 160 characters to bill a single part.
  • Always set callback_url so you receive delivery confirmations.
  • Attach metadata (e.g. order or user IDs) to reconcile callbacks with your records.

โš ๏ธ Error Handlingโ€‹

{
"error": {
"code": "INVALID_PHONE",
"message": "The 'to' field is not a valid E.164 number",
"timestamp": "2026-05-28T10:30:00Z"
}
}
HTTPCodeResolution
400INVALID_PHONEUse E.164 format including country code
400INVALID_SENDER_IDRegister or correct your sender ID
401UNAUTHORIZEDCheck your API key
402INSUFFICIENT_BALANCETop up your account
429RATE_LIMITEDRetry with exponential backoff

See the full list in Error Codes.


Last Updated: May 2026 ยท Need help? Contact Support โ†’