Send SMS from a Javascript or Node.js application
Build a customized SMS messaging solution within your JavaScript or Node.js environment. Automate your communication via SMS, meet specific needs, add messaging to your JavaScript and Node.js tools. Take advantage of a quick-start guide to integrate SMS in just a few minutes.

Send SMS in JavaScript with smsmode©
Simple, secure API integration
Compatible with all programming languages. Our REST API makes sending, receiving and monitoring mobile messaging easy, thanks to comprehensive, free documentation.
Security & business continuity
Our ISO 27001 & 27701 certified infrastructure is hosted in France in 2 separate level 4 data centers (redundancy). Our SMS APIs are monitored 24/7, 365 days a year.
Technical support at your service
Our dedicated support and development teams are available to help you integrate our APIs SMS (REST or http) or to answer any questions you may have about the day-to-day use of our solutions.
STARTER GUIDE
Send your first SMS in Node.js
THE API SMS allows you to make calls to our SMS automatic mailing service from web pages and applications developed in JavaScript or Node.js. You can configure the sending and receiving of SMS and manage your account functionalities (contacts, available credits, scheduling, reception status, sender, etc.).
The Node.js Next source code lets you test sending SMS via the HTTP API (deprecated). ↓
const urlencode = require('urlencode');
var exports=module.exports={};
const urlencode = require('urlencode');
const http = require('https');
const querystring = require('querystring');
const fs = require('fs');
const pathname = require("path");
const ERROR_API = "Error during API call";
const ERROR_FILE = "The specified file does not exist";
const HOSTNAME = 'api.smsmode.com'
const PATH_SEND_SMS = "/http/1.6/sendSMS.do";
const PATH_SEND_SMS_Batch = "/http/1.6/sendSMSBatch.do";
/**
* Function parameters:
*
* - accessToken (required)
* - message (required)
* - destinataires (required): Receivers separated by a comma
* - emetteur (optional): Allows to deal with the sms sender
* - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
* - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/
exports.ExempleClientHttpAPI = class {
// send SMS with GET method
async sendSmsGet(accessToken, message, destinataires, emetteur, optionStop) {
var finalPath = PATH_SEND_SMS + '?accessToken=' + accessToken + '&numero=' + destinataires +
"&message=" + urlencode(message,'ISO-8859-15') + '&emetteur=' + emetteur + '&stop=' + optionStop;
const options = {
hostname: HOSTNAME,
port: 443,
path: finalPath,
method: 'GET'
};
try {
let http_promise = this.getHttpResponse(options, "");
let response_body = await http_promise;
return response_body;
}
catch(error) {
return ERROR_API;
}
}
// send SMS with POST method
async sendSmsPost(accessToken, message, destinataires, emetteur, optionStop) {
var postData = querystring.stringify({
'accessToken': accessToken,
'numero': destinataires,
'emetteur' : emetteur,
'stop' : optionStop
});
postData = postData + "&message=" + urlencode(message,'ISO-8859-15');
const options = {
hostname: HOSTNAME,
port: 443,
path: PATH_SEND_SMS,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=ISO-8859-15',
'Content-Length': Buffer.byteLength(postData)
}
};
try {
let http_promise = this.getHttpResponse(options, postData);
let response_body = await http_promise;
return response_body;
}
catch(error) {
return ERROR_API;
}
}
// send SMS with POST method (Batch)
async sendSmsBatch(accessToken, batchFilePath, optionStop) {
var finalPath = PATH_SEND_SMS_Batch + "?accessToken=" + accessToken + "&stop=" + optionStop;
try {
let content_file_promise = this.getContentFile(batchFilePath);
let content = await content_file_promise;
var boundary = "AaB03x";
var postData = Buffer.concat([
Buffer.from("--" + boundary + "\r\n"),
Buffer.from("Content-Disposition: form-data; name=\"file\"; filename=\""),
Buffer.from(pathname.basename(batchFilePath) + "\"\r\n"),
Buffer.from("Content-Type:text/csv\r\n\r\n"),
Buffer.from(content),
Buffer.from("\r\n--" + boundary + "--\r\n"),
]);
var options = {
method: 'POST',
hostname: HOSTNAME,
port: 443,
path: finalPath,
headers: {
"Content-Type": "multipart/form-data; boundary=" + boundary,
'Content-Length': Buffer.byteLength(postData)
}
};
try {
let http_promise = this.getHttpResponse(options, postData);
let response_body = await http_promise;
return response_body;
}
catch(error) {
return ERROR_API;
}
}
catch(error) {
return ERROR_FILE;
}
}
getHttpResponse(options, postData) {
return new Promise((resolve, reject) => {
const req = http.request(options, (res) => {
let chunks_of_data = [];
res.on('data', (fragments) => {
chunks_of_data.push(fragments);
});
res.on('end', () => {
let response_body = Buffer.concat(chunks_of_data);
resolve(response_body.toString());
});
});
req.on('error', (error) => {
reject(error);
});
req.write(postData);
req.end();
});
}
getContentFile(batchFilePath) {
return new Promise((resolve, reject) => {
fs.readFile(batchFilePath, async function(err, content) {
if (err) {
reject(err);
} else {
resolve(content);
}
});
});
}
}
You can now test SMS in JavaScript!
To harness the full potential of SMS marketingTo use the full potential of marketing, notification or OTP, consult the REST API documentation and its parameters to exploit the full range of functions offered.
The full documentation of our REST API details all the functions and requests available on our gateway. SMS
The Curl SDK lets you configure :
- View remaining credit
- Send individual or bulk SMS
- Manage and segment your contacts
- Schedule sending date and time
- Send notifications by SMS
- Receive statistics on campaigns sent (status received)
It is compatible with :
ISO-8859-15
PHP
Java
ASP
C++
Ruby
WINDEV
Why use our SMS gateway?
Approved by more than 10,000 customers in France and abroad, our solution is quick and easy to install and offers significant competitive advantages:
As an ARCEP telecom operator, we only route SMS via high-quality routes. As a result, we can guarantee that your messages will be received by French telephone operators at a rate of +90% within one minute of being sent. A real guarantee of quality and maximum deliverability.
Our Gateway SMS is continuously monitored. You can access the performance of your SMS mailings via our traffic monitoring system and benefit from detailed results and statistics in real time, be alerted to any slowdowns and be assured of the success of your SMS campaigns.
Our high-availability gateway handles millions of requests every day, with an annual dispatch volume of over 900 million SMS . The management of sending priorities (segmentation of traffic into 3 types: OTP, notification and marketing traffic) enables us to offer better performance adapted to the type of sending.
Create your free account
Try out our SMS platform and benefit from 20 free test credits, with no obligation.