Send SMS¶
Send a single SMS message to a phone number.
Request body¶
| Field | Type | Required | Description |
|---|---|---|---|
to |
string | Yes | Recipient phone number in E.164 format (e.g. +12125551234) |
message |
string | Yes* | SMS text body. *Required if template_id is not provided. |
template_id |
integer | No | ID of a saved SMS template to use instead of message |
variables |
object | No | Key/value pairs to replace {{variable}} placeholders in the template or message |
Segments
SMS messages longer than 160 characters (or 70 for Unicode/emoji) are split into multiple segments. Each segment consumes one SMS credit. The API returns segments_used so you know exactly how many credits were deducted.
Example — plain message¶
$response = file_get_contents('https://admin.notifybulk.com/api/v1/sms/send', false,
stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Authorization: Bearer YOUR_API_TOKEN\r\nContent-Type: application/json\r\n",
'content' => json_encode([
'to' => '+12125551234',
'message' => 'Your order #1042 has shipped!',
]),
]
])
);
$data = json_decode($response, true);
const res = await fetch('https://admin.notifybulk.com/api/v1/sms/send', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: '+12125551234',
message: 'Your order #1042 has shipped!',
}),
});
const data = await res.json();
Example — using a template with variables¶
{
"to": "+12125551234",
"template_id": 7,
"variables": {
"name": "Maria",
"order": "1042",
"eta": "Thursday"
}
}
If the template body is Hello {{name}}, your order #{{order}} arrives on {{eta}}., the message sent will be:
Hello Maria, your order #1042 arrives on Thursday.
Response¶
{
"success": true,
"sid": "SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"status": "queued",
"segments_used": 1,
"credits_remaining": 498
}
| Field | Type | Description |
|---|---|---|
success |
boolean | true on success |
sid |
string | Unique message identifier from the carrier |
status |
string | Initial delivery status: queued, sent |
segments_used |
integer | SMS credits deducted |
credits_remaining |
integer | SMS credits left after this send |
Error responses¶
| HTTP | Error message | Cause |
|---|---|---|
400 |
"to" is required |
Missing recipient |
400 |
"to" must be a valid phone number in E.164 format |
Invalid number format |
400 |
Provide either "template_id" or "message" |
Neither was provided |
402 |
Insufficient SMS credits |
No credits remaining |
403 |
SMS is not included in your current plan |
Plan doesn't include SMS |
404 |
SMS template not found |
Invalid template_id |
422 |
No phone number configured for this store |
Store has no sender number |
451 |
Content blocked by moderation filter |
Message flagged by content filter |