Skip to Content
SMS APIHow to Send SMSHow to Send a Single SMS

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/send

Authorization

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Sample Request Body

{ "source": "sms_leopard", "message": "Hello from SMSLeopard API", "destination": [ { "number": "07000000001" } ], "status_url": "", "status_secret": "" }

Code Examples

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, use SMS_Leopard for 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 when status_url is provided).
  • shorten_url - true to replace each URL in message with a short link (optional, default false). Set it only when the message contains a URL.
  • whitespace - true to keep whitespace at the start of message (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:

StatusMeaning
queuedAccepted for sending
invalid_phoneThe number is not valid
in_denylistThe recipient opted out of messages from this sender ID
restricted_send_timePromotional message to a Safaricom number outside 08:00 to 18:00
unresolvable_variablesThe message still has {placeholders} without a value
airtel_message_length_exceededMessage to an Airtel number longer than 548 characters
failedRejected 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.