Send an SMS
Needs a key with the sms:send permission.
One message
POST /api/v1/sms/send| Field | Required | Meaning |
|---|---|---|
to | Yes | The recipient in international format: +, country code, number, no spaces. For example +250788123456. |
message | Yes | The text. At most 10 segments unless your server is set up differently. |
reference | No | Your own identifier, up to 100 characters. It comes back in every answer and webhook about this message. |
priority | No | 1 to 10. 1 is sent first. The default is 5. |
scheduledAt | No | When to send it, as an ISO 8601 date in the future. Without it, the message is queued at once. |
curl https://yoursms.ngwije.cloud/api/v1/sms/send \
-H "Authorization: Bearer $YOURSMS_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-10001-confirmation" \
-d '{
"to": "+250788123456",
"message": "Your order has been confirmed.",
"reference": "ORDER-10001"
}'const response = await fetch('https://yoursms.ngwije.cloud/api/v1/sms/send', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.YOURSMS_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': 'order-10001-confirmation',
},
body: JSON.stringify({
to: '+250788123456',
message: 'Your order has been confirmed.',
reference: 'ORDER-10001',
}),
})
const { success, data, error } = await response.json()
if (!success) throw new Error(`${error.code}: ${error.message}`)
console.log(data.messageId, data.status)import os
import requests
response = requests.post(
"https://yoursms.ngwije.cloud/api/v1/sms/send",
headers={
"Authorization": f"Bearer {os.environ['YOURSMS_API_KEY']}",
"Idempotency-Key": "order-10001-confirmation",
},
json={
"to": "+250788123456",
"message": "Your order has been confirmed.",
"reference": "ORDER-10001",
},
timeout=10,
)
body = response.json()
if not body["success"]:
raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
print(body["data"]["messageId"], body["data"]["status"])The server answers 202 Accepted as soon as the message is stored:
{
"messageId": "8f2a1c0e-4b7d-4e2a-9c31-5d0f6a7b8c90",
"status": "QUEUED",
"recipient": "+250788123456",
"createdAt": "2026-12-01T08:30:00Z"
}status is QUEUED, or SCHEDULED if you gave scheduledAt. Accepted does not mean sent. A phone sends the message afterwards. Keep the messageId and find out what happened by reading the message or through a webhook.
Send it once
Networks fail. If your request times out, you cannot know whether the server got it, and sending again might text your customer twice.
Add an Idempotency-Key header: any string of up to 150 characters that names this one message, such as order-10001-confirmation. Then repeat the request as often as you need:
- The first request creates the message.
- A repeat with the same key and the same body returns the first message and creates nothing.
- The same key with a different body is refused with
409 IDEMPOTENCY_KEY_CONFLICT.
Keys belong to your team and do not expire. Derive them from your own data rather than generating a random one per attempt.
At a later time
{
"to": "+250788123456",
"message": "Your appointment is tomorrow at 09:00.",
"scheduledAt": "2026-12-02T06:00:00Z"
}The message stays SCHEDULED until then. You can cancel it before its time.
Many at once
POST /api/v1/sms/bulk{
"messages": [
{ "to": "+250788123456", "message": "We are closed on 25 December.", "reference": "NOTICE-1" },
{ "to": "+250722123456", "message": "We are closed on 25 December.", "reference": "NOTICE-2" },
{ "to": "0788", "message": "We are closed on 25 December." }
]
}Each entry takes the same fields as a single message. One request can hold up to 500 entries by default; a larger one is refused with 400 BULK_TOO_LARGE.
Entries are judged one by one, so one bad number does not stop the rest:
{
"batchId": "3d6f0b1e-2a4c-4f7e-8b9a-1c2d3e4f5a6b",
"total": 3,
"accepted": 2,
"rejected": 1,
"results": [
{ "index": 0, "messageId": "…", "status": "QUEUED" },
{ "index": 1, "messageId": "…", "status": "QUEUED" },
{ "index": 2, "status": "REJECTED", "error": "to: must be a phone number in E.164 format, for example +250788123456" }
]
}results is in the order you sent. Keep the batchId: GET /api/v1/sms?batchId=… lists the messages of this send.
Bulk requests do not take an Idempotency-Key. If a bulk request times out, list the batch before sending again.
What can go wrong
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | A field is missing or malformed. details names it. |
| 400 | MESSAGE_TOO_LONG | The message needs more segments than the server allows. |
| 409 | IDEMPOTENCY_KEY_CONFLICT | This key was used with a different message. |
| 429 | QUOTA_EXCEEDED | Your team's daily limit is reached, if your server sets one. |
| 429 | RATE_LIMITED | Too many requests. Wait the number of seconds in Retry-After. |
