Send SMS
Send an SMS message through the Ender API.
Request
Headers
| Header | Value |
Authorization | Bearer YOUR_API_KEY |
Content-Type | application/json |
Body
| Field | Type | Required | Description |
to | string | Yes | Phone number in E.164 format (e.g., +1234567890) |
message | string | Yes | Message content (max 1600 characters) |
device_id | string | No | Specific device to use. If omitted, auto-selected. |
webhook_url | string | No | URL for delivery status webhook |
Example
curl -X POST https://your-server.com/api/v1/sms \
-H "Authorization: Bearer sk_live_abc123" \
-H "Content-Type: application/json" \
-d '{
"to": "+1234567890",
"message": "Your verification code is 123456",
"webhook_url": "https://your-app.com/webhooks/sms"
}'
Response
Success (201 Created)
{
"id": "msg_abc123def456",
"status": "queued",
"to": "+1234567890",
"message": "Your verification code is 123456",
"device_id": "dev_xyz789",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Message statuses
| Status | Description |
queued | Message is queued for sending |
sending | Message is being sent by the device |
sent | Message was sent successfully |
delivered | Message was delivered (if delivery reports enabled) |
failed | Message failed to send |
Errors
// 400 Bad Request - Invalid phone number
{
"error": "invalid_phone_number",
"message": "Phone number must be in E.164 format"
}
// 401 Unauthorized - Invalid API key
{
"error": "unauthorized",
"message": "Invalid or missing API key"
}
// 402 Payment Required - Quota exceeded
{
"error": "quota_exceeded",
"message": "Monthly message quota exceeded"
}
// 503 Service Unavailable - No devices available
{
"error": "no_devices",
"message": "No devices available to send messages"
}
Code examples
Python
import requests
response = requests.post(
"https://your-server.com/api/v1/sms",
headers={
"Authorization": "Bearer sk_live_abc123",
"Content-Type": "application/json"
},
json={
"to": "+1234567890",
"message": "Hello from Python!"
}
)
print(response.json())
JavaScript
const response = await fetch("https://your-server.com/api/v1/sms", {
method: "POST",
headers: {
"Authorization": "Bearer sk_live_abc123",
"Content-Type": "application/json"
},
body: JSON.stringify({
to: "+1234567890",
message: "Hello from JavaScript!"
})
});
const data = await response.json();
console.log(data);
Related