Prerequisites
Before you begin:
- A SpringEdge account with an API key and your SMS service URL (
<SMS_SERVICE_URL>, shared after sign-up, for direct HTTP calls) - Node.js installed (18+ for built-in
fetch) - Install the package:
npm install springedge - A DLT-registered sender ID and approved template (for India)
Official npm Package
springedge wraps the send API in a single call
Delivery Reports
Receive delivery status on your own Express.js endpoint via callbackurl
Or Zero Dependencies
Use built-in fetch in Node 18+ with a form-encoded POST
const springedge = require('springedge');
const params = {
apikey: 'YOUR_API_KEY',
sender: 'SEDEMO',
to: ['919900XXXXXX'],
message: 'Your OTP is 482910',
format: 'json',
};
// 5000 = request timeout in ms
springedge.messages.send(
params, 5000, (err, response) => {
if (err) {
return console.error(err);
}
console.log(response);
}
);
// Success response (format=json):
// {"groupID": 61, "MessageIDs": "61-1",
// "status": "AWAITED-DLR"}
NPM PACKAGE
Using the springedge Package
springedge is SpringEdge's official Node.js library. It sends your apikey, sender, to and message (matching a DLT-approved template) to the send API and returns the result to your callback.
Quick Start:
npm init -y && npm install springedge- Replace
YOUR_API_KEYwith your SpringEdge key - Run:
node send_sms.js
Without the package (Node 18+ fetch):
fetch(
'<SMS_SERVICE_URL>/api/web/send/',
{
method: 'POST',
// form-encoded body, not JSON
body: new URLSearchParams({
apikey: 'YOUR_API_KEY',
sender: 'SEDEMO',
to: '9900XXXXXX',
message: 'Your OTP is 482910',
format: 'json',
}),
}
)
// JSON on success; plain-text error
// such as "Invalid Sender ID" otherwise
.then((res) => res.text())
.then(console.log)
.catch(console.error);
See the SMS API documentation for all parameters. Call the API only from server-side code — never from a browser or mobile app, where the key would be exposed.
EXPRESS.JS
Receive Delivery Reports
Set up an Express.js endpoint to receive delivery reports. Add callbackurl (your endpoint URL) and label (your own reference ID) to the send parameters, and SpringEdge calls your URL with label, recipient and status (DELIVRD, UNDLIVRD or FAILED).
Read the values from the request parameters and respond with HTTP 200 quickly. See delivery report webhooks.
const express = require('express');
const app = express();
// Parameters may arrive as query string
// or form-encoded body
app.use(express.urlencoded({ extended: false }));
app.all('/webhook/dlr', (req, res) => {
const p = { ...req.query, ...req.body };
const { label, recipient, status } = p;
console.log(`${label} to ${recipient}: ${status}`);
// Update your database
// await db.updateSmsStatus(label, status);
res.sendStatus(200);
});
app.listen(3000, () =>
console.log('DLR server on :3000')
);
// Send with: callbackurl:
// 'https://example.com/webhook/dlr',
// label: 'order-1001'
What You Can Build
OTP Verification
Add phone number verification to your Express, Nest.js, or Next.js signup and login flows.
Webhook Server
Build a real-time delivery tracking server that processes delivery reports and updates your database.
Scheduled Campaigns
Use node-cron or Bull queues to schedule and send bulk SMS campaigns at optimal delivery times.
Microservice Alerts
Send SMS alerts from your Node.js microservices when critical events occur — server down, threshold breached, deployment complete.
