How to Send a Single SMS
You can send a single SMS to one or many recipients by making a HTTP POST request with the following:
Endpoint
https://api.smsleopard.com/v1/sms/sendAuthorization
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=Sample Request Body
{
"source": "sms_leopard",
"message": "Hello from SMSLeopard API",
"destination": [
{
"number": "07000000001"
}
],
"status_url": "",
"status_secret": ""
}Code Examples
Curl
curl -u API_KEY:API_SECRET -H "Content-Type: application/json" -X POST https://api.smsleopard.com/v1/sms/send -d '{"source": "SMSLeopard", "message": "Hello from SMSLeopard API", "destination": [{"number": "+254710000001"}, {"number": "+254710000002"}], "status_url": "https://your-status.url", "status_secret": "supersecret"}'Payload
source- A Sender ID of your smsleopard business account. If you have not yet been assigned any, useSMS_Leopardfor testing purposes. Click here to learn more.message- The SMS you intend to send to the recipient.destination- An array of recipient objects with the numbers you intend to send the message to.destination → number- The specific recipient phone number you intend to send SMS to.status_url- A callback URL to receive delivery reports on (optional).status_secret- A secret value that you provide, only to be shared between you and us that you will use to verify updates sent from us (required whenstatus_urlis provided).shorten_url-trueto replace each URL inmessagewith a short link (optional, defaultfalse). Set it only when the message contains a URL.whitespace-trueto keep whitespace at the start ofmessage(optional). By default whitespace is trimmed from both ends.
Example of a Successful Response
Status code: 201
{
"success": true,
"message": "Sent to 1/1. Cost KES 0.90",
"recipients": [
{
"id": "eb4647b2-2695-4aba-958e-0b39d965f6d0",
"cost": 0.9,
"number": "+254700000001",
"status": "queued"
}
]
}Each recipient’s status is one of:
| Status | Meaning |
|---|---|
queued | Accepted for sending |
invalid_phone | The number is not valid |
in_denylist | The recipient opted out of messages from this sender ID |
restricted_send_time | Promotional message to a Safaricom number outside 08:00 to 18:00 |
unresolvable_variables | The message still has {placeholders} without a value |
airtel_message_length_exceeded | Message to an Airtel number longer than 548 characters |
failed | Rejected for another reason |
Only queued recipients are sent. If none is queued, the response is 400 with "message": "no valid recipients" and the same list. See Invalid number.