Bulk SMS API reference for Sri Lanka
The REST API for sending bulk SMS in Sri Lanka with e-SMS. JSON in, JSON out, over HTTPS, at a flat Rs 0.99 per SMS segment (see pricing). Every request carries an API token you generate in the dashboard under API tokens.
Successful responses carry "status": "success" and a data
object. Failures carry "status": "error" and a readable
message. A 402 means you ran out of credits.
Send a message
| Parameter | Description |
|---|---|
| recipient required | One number, or several separated by commas. Local formats such as 0712345678 are accepted and normalised to 94712345678. |
| sender_id required | An approved sender name on your account. |
| type | plain or unicode. Left out, the encoding is detected from the message. |
| message required | The body of the SMS. |
| schedule_time | Send later, in YYYY-MM-DD HH:MM. |
Response
sms_count is the segments in one message; cost is the
total credits taken, which is segments multiplied by recipients.
Cost a message without sending
Same body as a send. Returns the segment count, encoding and credits required. Useful before a large batch.
Send to a contact group
| Parameter | Description |
|---|---|
| contact_list_id required | The group ID from GET /api/v3/contacts. |
| sender_id required | An approved sender name. |
| message required | The body of the SMS. |
| schedule_time | Send later, in YYYY-MM-DD HH:MM. |
Look up one message
List messages
| Query | Description |
|---|---|
| start_date | Filter from this date and time. |
| end_date | Filter up to this date and time. |
| sms_type | plain or unicode. |
| direction | api or dashboard. |
| page | Page number. 25 per page by default. |
Check your credits
Your contact groups
Returns the groups on your account with their IDs and contact counts.
Rate limits
120 requests a minute per token. Beyond that you get a 429 with a
RateLimit-Reset header telling you how long to wait.
Errors
| Code | Meaning |
|---|---|
| 401 | The token is missing, malformed or revoked. |
| 402 | Not enough credits for this send. |
| 422 | Something in the request is wrong; the message says what. |
| 429 | Rate limited. |
| 500 | Our side failed. The credits are not taken. |