Send an SMS
POST /v1/messages/send sends one SMS to a number in any of the 53 countries. To send to many numbers, use send-bulk.
POST https://api.sms.jtnoble.com/v1/messages/send
Authorization: Bearer jtsms_live_YOUR_KEY
Content-Type: application/jsonRequest body
| Field | Type | Required | Meaning |
|---|---|---|---|
to | string | Yes | Mobile number in international format, for example +2348030000000. |
text | string | Yes | The message. Long text is split into segments, at most 10. See encoding. |
sender_id | string | No | Sender name, up to 11 characters. It must be approved on your account. Without it, the default sender is used. See Sender IDs. |
schedule_mode | string | No | now (default) or scheduled. |
scheduled_at | string | When scheduled | ISO 8601 time with a time zone. At least 5 minutes and at most 7 days ahead. |
The fields flash, validity_period, priority and binary exist but are not on sale yet: using them answers HTTP 400 with code feature_not_enabled.
curl -X POST "https://api.sms.jtnoble.com/v1/messages/send" \
-H "Authorization: Bearer $JTSMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"+2348030000000","text":"Your order 1042 is ready.","sender_id":"MYSHOP"}'const resp = await fetch('https://api.sms.jtnoble.com/v1/messages/send', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.JTSMS_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({"to":"+2348030000000","text":"Your order 1042 is ready.","sender_id":"MYSHOP"}),
});
console.log(resp.status, await resp.text());import os
import requests
resp = requests.post(
"https://api.sms.jtnoble.com/v1/messages/send",
headers={"Authorization": f"Bearer {os.environ['JTSMS_API_KEY']}"},
json={"to":"+2348030000000","text":"Your order 1042 is ready.","sender_id":"MYSHOP"},
timeout=30,
)
print(resp.status_code, resp.text)<?php
$ch = curl_init('https://api.sms.jtnoble.com/v1/messages/send');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('JTSMS_API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"to":"+2348030000000","text":"Your order 1042 is ready.","sender_id":"MYSHOP"}',
]);
$body = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $body, PHP_EOL;Response
HTTP 200:
{
"id": "6f1c2b9e-1d2a-4c55-9a0e-2b7f0c1d3e4f",
"status": "submitted",
"segments": 1,
"encoding": "GSM7",
"recipients": 1,
"price_per_sms": 35.0,
"cost": 35.0,
"cost_currency": "USD",
"route_cost": 35.0,
"route_currency": "USD",
"route": "NG",
"balance_after": 4965.0,
"scheduled_at": null,
"options": { "flash": false, "validity_period": null, "priority": 0, "binary": false }
}| Field | Meaning |
|---|---|
id | Message id. Use it to look up the message and to match webhooks. |
status | submitted (sent to the network), scheduled, unknown or failed. |
segments | Number of parts. You pay per segment. |
encoding | GSM7 or UCS2. |
price_per_sms | Your price per segment. |
cost, cost_currency | What your balance was charged. |
route | The destination country route, for example NG. |
balance_after | Your balance after this message. |
Each segment is charged at the price for the destination country, for example USD 0.0116 to Nigeria on the Basic price. The pricing page lists every country; your dashboard shows the price for your account.
Send each message once
Network problems can make you retry a request. Add an Idempotency-Key header with a unique value per message, for example your order id:
Idempotency-Key: order-1042-readyIf you send the same key again, you get the first result back, with "idempotent_replay": true. You are not charged twice.
Message status
| Status | Meaning | Charged |
|---|---|---|
queued | Accepted, waiting to go out. | Yes |
scheduled | Waiting for its scheduled time. | Yes |
submitted | Handed to the network. | Yes |
sent | The network took it and gave no final report. | Yes |
delivered | The phone received it. | Yes |
undelivered | The network could not deliver it. | Refunded |
failed | Not delivered. | Refunded |
unknown | The gateway did not confirm the send. We find out what happened, then settle it. | Held until settled |
cancelled | A scheduled message you cancelled. | Refunded |
A message with no report after 24 hours becomes unknown.
Rules that apply
- Numbers in the 53 countries only. Other countries get HTTP
422codedestination_not_allowed. A wrong number gets HTTP400withinvalid_phoneorinvalid_phone_length. - Your balance must cover the full message. If not, HTTP
402codeinsufficient_balance. The attempt shows in your message log asfailedand costs nothing. - A number that replied STOP to you is refused with HTTP
403coderecipient_opted_out. - A number on the do-not-disturb list is refused with HTTP
403coderecipient_dnd. - More than 10 segments is refused with HTTP
413codemessage_too_long. - The default rate limit is 20 requests per second per key. Above it, HTTP
429coderate_limited.
Price before you send
POST /v1/messages/rate takes to (one number, or up to 1000) and text, and returns the encoding, segment count and total cost. Nothing is sent and nothing is charged. POST /v1/messages/validate checks numbers the same way, without a price.
curl -X POST "https://api.sms.jtnoble.com/v1/messages/rate" \
-H "Authorization: Bearer $JTSMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"+2348030001111","text":"Your order 1042 is ready."}'const resp = await fetch('https://api.sms.jtnoble.com/v1/messages/rate', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.JTSMS_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({"to":"+2348030001111","text":"Your order 1042 is ready."}),
});
console.log(resp.status, await resp.text());import os
import requests
resp = requests.post(
"https://api.sms.jtnoble.com/v1/messages/rate",
headers={"Authorization": f"Bearer {os.environ['JTSMS_API_KEY']}"},
json={"to":"+2348030001111","text":"Your order 1042 is ready."},
timeout=30,
)
print(resp.status_code, resp.text)<?php
$ch = curl_init('https://api.sms.jtnoble.com/v1/messages/rate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('JTSMS_API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"to":"+2348030001111","text":"Your order 1042 is ready."}',
]);
$body = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), ' ', $body, PHP_EOL;See all message routes.