Introduction
SWIFT SMS exposes a REST API for sending messages across SMS, WhatsApp, Voice, MMS, Viber and OTP, and for managing contacts and campaigns. Every request and response uses JSON.
All requests must be made over HTTPS and include the headers Accept: application/json and Content-Type: application/json.
Authentication
Authenticate with your API token as a Bearer token. Generate or rotate your token in the dashboard under Developers.
Authorization: Bearer YOUR_API_TOKEN
Accept: application/json
Content-Type: application/json
Keep your token secret. Never expose it in client-side code or public repositories.
SDKs
Official, open-source libraries wrap every endpoint below, including authentication, error handling and all message types. They’re the fastest way to integrate.
Quick start
require __DIR__ . '/vendor/autoload.php';
use Swiftsms\Swiftsmsgh;
use Swiftsms\SwiftsmsException;
$client = new Swiftsmsgh('YOUR_API_TOKEN', 'YourSenderID');
try {
// Comma-separate multiple recipients
$response = $client->send_sms('233538000000,233540000000', 'Hello from SWIFT SMS!');
// Optional: schedule and override the sender ID
$client->send_sms('233538000000', 'See you tomorrow', [
'schedule_time' => '2026-12-25 08:00',
'sender_id' => 'MyAlert',
]);
} catch (SwiftsmsException $e) {
echo 'Error: ' . $e->getMessage();
}
// Reads SWIFTSMS_API_TOKEN and SWIFTSMS_SENDER_ID from the environment
const client = require('swiftsmsgh-api-sdk')();
// A single number, or an array of numbers
await client.sms.send(['233538000000', '233540000000'], 'Hello from SWIFT SMS!');
// Optional: schedule and override the sender ID
await client.sms.send('233538000000', 'See you tomorrow', {
schedule_time: '2026-12-25 08:00',
sender_id: 'MyAlert',
});
import swiftsmsgh, { SwiftsmsException } from 'swiftsmsgh-api-sdk';
const client = swiftsmsgh(process.env.SWIFTSMS_API_TOKEN, process.env.SWIFTSMS_SENDER_ID, {
autoRetry: true, // retry failed requests with exponential backoff
maxRetries: 3,
});
try {
const { data } = await client.account.balance();
console.log(data?.remaining_balance);
} catch (error) {
if (error instanceof SwiftsmsException) {
console.error(`API error ${error.code}: ${error.message} (HTTP ${error.status})`);
}
}
Only use the SDKs on your server. Bundling them into front-end code exposes your API token to anyone who visits your site.
Method reference
| Task | PHP | Node.js |
|---|---|---|
| Send SMS | send_sms($to, $msg, $options) | sms.send(to, msg, options) |
| Send to contact lists | — | sms.sendCampaign(listIds, msg, options) |
| Voice call | send_voice($to, $msg, $gender, $lang) | voice.send(to, msg, gender, lang) |
| MMS | send_mms($to, $msg, $mediaUrl) | mms.send(to, msg, mediaUrl) |
| OTP | send_otp($to, $msg) | otp.send(to, msg) |
send_whatsapp($to, $msg) | whatsapp.send(to, msg, options) | |
| Viber | send_viber($to, $msg) | viber.send(to, msg, options) |
| List messages | — | sms.list(filters) |
| View a message / campaign | — | sms.view(uid), campaign.view(uid) |
| Balance | check_balance() | account.balance() |
| Profile | profile() | account.profile() |
| Contact groups | all_contact_groups(), view_contact_group($id), delete_contact_group($id) | contacts.groups.list(), contacts.groups.create(name), contacts.groups(id).fetch() |
| Contacts in a group | all_contacts_in_group($id), view_contact($id, $uid), delete_contact($id, $uid) | contacts.groups(id).contacts.list(), .create({...}), contacts(uid).update({...}) |
See each repository’s README for the full list of methods and options.
POST Send a message
https://swiftsmsgh.com/api/v3/sms/send
Send a message to one or more recipients. Separate multiple numbers with a comma. Using PHP or Node.js? The SDKs do this in one line.
| Parameter | Type | Description |
|---|---|---|
recipientrequired | string | Number(s) to send to, including country code. Example: 233241234567,233201234567 |
sender_idrequired | string | A phone number with country code, or an alphanumeric sender of up to 11 characters. |
typerequired | string | Message type. Use plain for text. See message types. |
messagerequired | string | The body of the message. |
schedule_time | datetime | Send later, formatted Y-m-d H:i. Example: 2026-12-20 07:00 |
dlt_template_id | string | DLT content template ID, where required by local regulation. |
curl -X POST https://swiftsmsgh.com/api/v3/sms/send \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"recipient": "233241234567",
"sender_id": "YourName",
"type": "plain",
"message": "This is a test message"
}'
$ch = curl_init('https://swiftsmsgh.com/api/v3/sms/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN',
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'recipient' => '233241234567',
'sender_id' => 'YourName',
'type' => 'plain',
'message' => 'This is a test message',
]),
]);
$response = json_decode(curl_exec($ch), true);
const res = await fetch('https://swiftsmsgh.com/api/v3/sms/send', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
recipient: '233241234567',
sender_id: 'YourName',
type: 'plain',
message: 'This is a test message',
}),
});
const data = await res.json();
import requests
res = requests.post(
"https://swiftsmsgh.com/api/v3/sms/send",
headers={"Authorization": "Bearer YOUR_API_TOKEN", "Accept": "application/json"},
json={
"recipient": "233241234567",
"sender_id": "YourName",
"type": "plain",
"message": "This is a test message",
},
)
data = res.json()
Message types
The same endpoint sends every channel. Set type and add any extra fields the channel needs.
type | Channel | Extra parameters |
|---|---|---|
plain | SMS | — |
unicode | SMS (non-Latin characters & emoji) | — |
otp | One-time passcode | — |
whatsapp | — | |
viber | Viber | — |
mms | MMS | media_url — URL of an image to attach |
voice | Voice (text-to-speech) | language (e.g. en-gb), gender (male|female) |
POST Send to a contact list
https://swiftsmsgh.com/api/v3/sms/campaign
Send a campaign to an entire contact list. Pass the list’s UID as recipient; all other parameters match Send a message.
curl -X POST https://swiftsmsgh.com/api/v3/sms/campaign \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"recipient": "6415907d0d37a",
"sender_id": "YourName",
"type": "plain",
"message": "Our weekend sale is live!",
"schedule_time": "2026-12-20 07:00"
}'
View messages
/smsList all messages sent from your account.
/sms/{uid}Retrieve a single message and its delivery status.
/campaign/{uid}/viewRetrieve a campaign and its progress.
Contacts & groups
Contact groups (lists) hold your contacts. Contacts are identified by group UID and contact UID.
Contact groups
/contactsList all contact groups.
/contactsCreate a group. Body: {"name": "Customers"}
/contacts/{group_id}/showRetrieve a group.
/contacts/{group_id}Rename a group.
/contacts/{group_id}Delete a group.
Contacts
/contacts/{group_id}/storeAdd a contact. Body: PHONE plus optional fields such as FIRST_NAME, LAST_NAME.
/contacts/{group_id}/search/{uid}Retrieve a contact.
/contacts/{group_id}/update/{uid}Update a contact.
/contacts/{group_id}/delete/{uid}Delete a contact.
/contacts/{group_id}/allList all contacts in a group.
Profile & balance
/meRetrieve your account profile.
/balanceRetrieve your remaining SMS units and expiry.
HTTP API
For systems that can’t send headers or JSON, every endpoint is also available under https://swiftsmsgh.com/api/http. Pass your token as the api_token parameter instead of a header.
https://swiftsmsgh.com/api/http/sms/send?recipient=233241234567&sender_id=YourName&type=plain&message=Hello&api_token=YOUR_API_TOKEN
Responses & errors
Every response includes a status field. On success you receive the requested data; on failure, a human-readable message.
{
"status": "success",
"data": { ... }
}
{
"status": "error",
"message": "A human-readable description of the error."
}
Status codes
| Code | Meaning |
|---|---|
ok | Message sent successfully |
100 | Bad gateway requested |
101 | Wrong action |
102 | Authentication failed |
103 | Invalid phone number |
104 | Phone coverage not active |
105 | Insufficient balance |
106 | Invalid sender ID |
107 | Invalid SMS type |
108 | SMS gateway not active |
109 | Invalid schedule time |
110 | Media URL required |
111 | Message contains a spam word and is awaiting approval |
Plugins
Prefer not to write code? Use one of our ready-made plugins.
FAQ
Common questions from developers. For billing, sender IDs and more, visit the full FAQ.
How do I integrate with my application?
Use the REST API with a Bearer token, the simple HTTP API with query parameters, or our official PHP and Node.js SDKs. The documentation has ready-to-run examples.
Where do I find my API token?
Log in and open Developers in the dashboard. You can copy your token there or generate a new one at any time.
Is there a rate limit?
Yes. API requests are rate-limited per account to keep the platform fast for everyone. If you hit the limit, wait a moment and retry. The Node.js SDK can retry automatically.
Can I send to a whole contact list from the API?
Yes. Call the campaign endpoint with your contact list’s UID as the recipient and the message is sent to everyone on that list.
How long can a message be?
A standard SMS holds 160 characters, or 70 if it contains Unicode such as emoji or non-Latin script. Longer messages are split into parts and joined on the handset, and each part counts as one credit.
Can I schedule messages?
Yes. Pick a date and time when you create a campaign, or pass schedule_time in the API, and the message goes out automatically.
Do you offer delivery reports?
Yes. Every message has a live delivery status, and you can filter and export detailed reports at any time.
Why is my message waiting for approval?
Messages that contain words often used in spam are held for a quick review before sending. This protects your sender reputation and delivery rates.
How do I check my balance?
Your remaining credits are shown on the dashboard. Developers can also call the /balance endpoint or use the SDK balance method.