Send SMS
Send a single SMS message to a mobile number.
Endpoint
POST https://api.galatext.com/api/sms/sendHeaders
| Header | Value | Required |
|---|---|---|
Content-Type | application/json | Yes |
x-api-key | Your API key | Yes |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
phoneNumber | string | Yes | Recipient phone number in E.164 format (e.g., +254712345678) |
message | string | Yes | Message content (up to 1600 characters, split into segments) |
senderId | string | No | Sender ID (default: GALATEX, max 11 characters) |
reference | string | No | Optional client reference for reconciliation |
webhookUrl | string | No | Custom webhook URL for delivery report (overrides account default) |
E.164 Phone Number Format
Country code + number, no leading zero or special characters:
| Country | Example |
|---|---|
| Kenya | +254712345678 |
| Nigeria | +2348012345678 |
| Uganda | +256701234567 |
| Tanzania | +255712345678 |
| Rwanda | +250781234567 |
| Ghana | +233501234567 |
Example Request
bash
curl -X POST https://api.galatext.com/api/sms/send \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"phoneNumber": "+254712345678",
"message": "Your OTP is 482916. Valid for 10 minutes.",
"senderId": "YOURBRAND"
}'JavaScript (fetch)
js
const response = await fetch('https://api.galatext.com/api/sms/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.GALATEXT_API_KEY
},
body: JSON.stringify({
phoneNumber: '+254712345678',
message: 'Your OTP is 482916. Valid for 10 minutes.',
senderId: 'YOURBRAND'
})
});
const data = await response.json();
console.log(data);Python
python
import requests
response = requests.post(
'https://api.galatext.com/api/sms/send',
headers={
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
json={
'phoneNumber': '+254712345678',
'message': 'Your OTP is 482916. Valid for 10 minutes.',
'senderId': 'YOURBRAND'
}
)
data = response.json()
print(data)Response
Success (202 Accepted)
json
{
"success": true,
"data": {
"messageId": "msg_abc123def456",
"status": "PENDING",
"phoneNumber": "+254712345678",
"senderId": "YOURBRAND",
"messageLength": 49,
"segments": 1,
"creditsUsed": 1,
"creditsRemaining": 1499
}
}| Field | Description |
|---|---|
messageId | Unique identifier for the message |
status | Current status: PENDING, SENT, DELIVERED, FAILED |
segments | Number of SMS segments (1 segment = 160 characters) |
creditsUsed | Credits deducted for this message |
creditsRemaining | Remaining credits in your account |
Error Responses
json
{
"success": false,
"error": {
"code": "INVALID_PHONE_NUMBER",
"message": "The phone number provided is not valid. Use E.164 format.",
"statusCode": 422
}
}Error Codes
| Status | Error Code | Description |
|---|---|---|
| 400 | BAD_REQUEST | Malformed request body |
| 401 | UNAUTHORIZED | Missing or invalid API key |
| 402 | INSUFFICIENT_CREDITS | Account balance too low |
| 422 | INVALID_PHONE_NUMBER | Phone number not in E.164 format |
| 422 | MESSAGE_TOO_LONG | Message exceeds 1600 characters |
| 422 | INVALID_SENDER_ID | Sender ID not approved or invalid format |
| 429 | RATE_LIMIT_EXCEEDED | Too many requests, slow down |
Message Segments
| Characters | Segments | Credits |
|---|---|---|
| 1–160 | 1 | 1 |
| 161–320 | 2 | 2 |
| 321–480 | 3 | 3 |
| 481–1600 | Up to 10 | Up to 10 |
Using Unicode/emoji characters reduces per-segment capacity to 70 characters.
Best Practices
- Always validate phone numbers before sending
- Store the
messageIdfor delivery tracking - Set up webhooks for automatic delivery report callbacks
- Use a custom sender ID for brand recognition
- Keep messages under 160 characters to minimize costs