4 Different Ways To Send Text Messages (SMS) with Node.js

Send SMS in Node.js four ways: Twilio, MessageBird, Plivo, and Courier. Copy-paste code, plus how a notification API adds templates and failover.

Updated Jul 6, 2026

SMS notifications are widely used in modern web and mobile applications. Applications can engage with users programmatically to facilitate fundamental user interactions in your app, such as two-factor authentication, approval requests, password resets, billing alerts, user phone number verification, etc.

You can use an SMS API as a simple way to programmatically send an SMS from your application. When using SMS for a notification-related use case, developers will often pair an SMS API with a Notification API to handle things like user preferences, template management, multi-touch and multi-channel workflows, and advanced delivery logic like batching frequent messages, scheduling, pre-configured delays, and throttling.

There are multiple options available, and this article will discuss four different ways of sending SMSs with Node.js to help you decide which option is best for your needs.

1. Using Twilio API

Twilio's Programmable SMS API allows you to integrate powerful messaging capabilities into your apps with Node.js. You can send and receive SMS messages, track their delivery, schedule SMS messages to transmit at a later time, and access and edit message history using this REST API.

Note that the prerequisites and example below just shows the basics of interacting with the Twilio API. For a typical production notifications use case, you would use Twilio with Courier's notification platform to support workflow automation, user preference management, audience profiles, template design and management, advanced send logic, and more. Here is a tutorial for using Twilio with Courier's Node.js SDK.

As prerequisites to use Twilio with Node.js, you will need :

  • A Twilio account, either free or paid.
  • Node.js installed on your machine
  • SMS-enabled phone number (you can search for and buy one in the Twilio console).

Twilio uses webhooks to notify your app when events like receiving an SMS message occur. Twilio sends an HTTP request (typically a POST or a GET) to the URL you specified for the webhook when an event happens. The event's information, such as the incoming phone number or the body of an incoming message, will be included in Twilio's request. Some webhooks are just informative, while others expect your web app to respond. You must notify Twilio API to which URL these webhooks are sent in all of these cases.

Advantages of using Twilio SMS API

  1. Support of multiple programming languages.
  2. On-demand billing.
  3. Good documentation and community support.

Disadvantages of using Twilio SMS API

  1. Not mobile-friendly
  2. Expensive compared to other APIs.
  3. Hard to get started without a software development background.

Tutorial: How to send SMS using Twilio SMS API

The following is the base for all URLs in the Twilio documentation.

https://api.twilio.com/2010-04-01

Sending a text message with the Twilio API is straightforward, requiring ten lines of code roughly.

Twilio simplifies the process by providing a helper library. To begin, use npm to install the twilio-node library from the terminal.

npm install twilio

Next, create a file (sms.js) and open it in the text editor. Load the twilio-node helper library at the top of the file and use it to create a Twilio REST client. Dotenv is then used to populate your environment variables with your account credentials. You can find the credentials you need for this step in the Twilio Console.

const twilio = require('twilio');
require('dotenv').config();
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;

Then all you have to do is start a new Twilio client instance and send an SMS from your Twilio phone number to your phone number. Ensure the phone numbers are replaced with your Twilio and cell phone numbers.

client.messages.create({
from: process.env.TWILIO_PHONE_NUMBER,
to: process.env.CELL_PHONE_NUMBER,
body: "Send SMS using Twilio Api in Node.js!"
}).then((message) => console.log(message.sid));

Then, by running the following command in the terminal, you can receive the SMS in seconds.

run sms.js

Likewise, you can now successfully send some messages with the Twilio Programmable SMS API and the Node.js helper library.

2.Using MessageBird API

MessageBird provides a variety of SMS delivery options. You can, for example, send SMS via email or an API connection. In addition, users can always check the status of their messages because each one is assigned with a unique random ID, allowing users to check the status.

The SMS API has an HTTP, a RESTful endpoint structure, and an access key for API authorization. The request and response payloads are formatted as JSON with UTF-8 encoding and URL encoded values.

As with the example above above, the prerequisites and tutorial below are scoped to the basics of working with the MessageBird API. For most production notifications use cases, you would use MessageBird with Courier's notification platform to support workflow automation, user preference management, template design and management, audience profiles, and more.

As prerequisites, you should have:

  • NodeJS development environment.
  • Project directory with the MessageBird SDK (This helper library helps interactions between your Node.js application's code and the MessageBird API)
  • MessageBird Account.

Advantages of using MessageBird API

  • User-friendly dashboard with features like flow builder.
  • Cost-effective pricing.
  • Can be easily integrated with native apps.

Disadvantages of using MessageBird API

  • Deliverability problems with some phone numbers.
  • Lack of plugins.

Tutorial: How to send SMS using MessageBird API

The base URL for all URLs in MessageBird's SMS API documentation is as follows.

https://rest.messagebird.com/messages

Create a file (sms.js) and open it in a text editor as the next step. Then, using require, you can include the MessageBird SDK ().

var messagebird = require('messagebird')('YOUR-API-KEY');

The SDK only accepts one argument, which is your API key. The string YOUR-API-KEY can then be replaced.

Then you can create a new instance of the MessageBird client via messages.create()and feed it to the originator (the sender), receivers (the phone numbers who will receive the message), and body (the message's content). You can use the number you purchased as the originator. The message's body will be limited to 160 characters; otherwise, it will be divided into many pieces. Make sure to replace the values in the sample code with actual data when testing.

messagebird.messages.create({
originator : '31970XXXXXXX',
recipients : [ '31970YYYYYYY' ],
body : 'Hello World, I am a text message and I was hatched by Javascript code!'
}

If everything goes properly, you'll get a response; if something goes wrong, you'll get an error response. As shown below, a callback function is used to manage this.

function (err, response) {
if (err) {
console.log("ERROR:");
console.log(err);
} else {
console.log("SUCCESS:");
console.log(response);
}
});

3. Using Plivo API

Plivo API makes it easier to integrate communications into your code by allowing you to send messages to any phone number using HTTP verbs and standard HTTP status codes. Other use cases include sending alerts and receiving delivery status updates.

Advantages of using Plivo SMS API

  1. Anyone can easily get started.
  2. User-friendly UI/UX.
  3. Seamless customization.

Disadvantages of using Plivo SMS API

  1. Documentation is a bit challenging to understand.
  2. Lack of error messages.

Tutorial: How to send SMS using Plivo SMS API

https://api.plivo.com/{version}/

As with Twilio and MessageBird above, the prerequisites and examples for Plivo focus on the basics of the Plivo API. For building production user notifications, pair Plivo with Courier's platform to automate workflows, manage user preferences, design templates, handle audience profiles, and more.

Prerequisites for Plivo are:

  • Plivo account.
  • Plivo phone number
  • NodeJS development environment.
  • Plivo's Node SDK.

To begin, create a new js file (sms.js) and use npm to install Express and the Plivo Node.js SDK.

$ npm install express plivo

Then you can create a new instance of the Plivo client via messages.create() and feed it the src(the sender id ), dst (the phone numbers who will receive the message), and text (the content of the message).

You can use the Plivo console to replace the auth placeholders with your authentication credentials. Actual phone numbers should be substituted for the placeholders (src and dst). Make sure that it's in E.164 format.

var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client("<auth_id>", "<auth_token>");
client.messages.create(
{
src: "<sender_id>",
dst: "<destination_number>",
text: "Hello, from Node.js!",
}
).then(function (response) {
console.log(response);
});
})();

Keeping your credentials in the auth id and auth token environment variables will be much safer. It will allow you to start the client with no arguments, and Plivo will automatically fetch the information from the environment variables.

Finally, save and execute the program to see if you received an SMS on your phone.

$ node SMS.js

You can also keep track of the status of your outbound messages with Plivo. First, you have to send a request to the server endpoint specifying its URL and HTTP method to set up a server endpoint. Then Plivo will call this endpoint with the latest message details as and when the message status changes.

4. Using a Multi-Channel Notification API

As mentioned in the sections above, it will typically make sense to pair an SMS API with a notification platform like Courier. While SMS APIs remove the difficulty of actually delivering a text message worldwide, a notification platform provides all the other critical logic for building a production notification use case with SMS, or any channel. Some of this logic includes

  • Automatic failover between SMS APIs to improve deliverability
  • Workflow designer and Automations API for multi-touch notification sequences
  • Advanced logic to implement throttling, pre-set delays, cron-based scheduling, and send limits.
  • A single Send API endpoint for not just SMS, but also Push, email, an in-app notification center, Slack, Discord, WeChat, and more
  • Central logging and reporting for all notification channels
  • Internationalization and compliance

Advantages of using a Notification API with an SMS API

  • You'll spend a fraction of the time and resources required to build and maintain a typical production notification use case.
  • You can easily add more notification channels like Push, email, and in-app notifications without modifying your code.
  • You'll build a notification system that will scale for the future and support other product teams.
  • You aren't tied to a single SMS API and can change over or add one for failover at any time
  • You won't have to manage a large codebase since all channels use the same API.

Disadvantages of using a Notification API

  • Takes more time to get started and try out than a simple SMS API REST call.
  • May not be appropriate for 2-way SMS messaging use cases
  • May not be practical for marketing-focused multicast use cases

Tutorial: How to send SMS using a Notification API

For this demonstration, I will be using Courier since it supports some well-known SMS providers like Twilio, Plivo, MessageBird, etc. Here is a full list of supported channels and providers.

Creating a Courier account

You can easily create a free Courier account using the following link - https://app.courier.com/signup.

Creating a new channel

After logging into your account, create a new SMS channel. From the Courier dashboard, open the Channels tab, choose one of the listed SMS providers (Twilio, MessageBird, Plivo, and more), and enter the credentials that provider requires, such as an originating number and an access key. Save the provider to activate the channel.

Creating a notification

With the channel connected, open the Designer tab and create a notification. Select SMS as the channel and your connected provider, add your message content, and publish your changes so the notification is ready to send.

Install the Courier SDK

Install the Courier Node.js SDK and copy your API key from Settings in the Courier dashboard.

npm install @trycourier/courier

Then send an SMS by instantiating the client with your API key and calling client.send.message. Send to a user by their user_id and reference the notification template you published above.

import Courier from "@trycourier/courier";
const client = new Courier({ apiKey: process.env.COURIER_API_KEY });
const { requestId } = await client.send.message({
message: {
to: {
user_id: "user-123",
},
template: "NOTIFICATION_TEMPLATE_ID",
data: {
name: "Nomen Nescio",
},
},
});

You can also send SMS content inline instead of referencing a published template, and use routing to control which channels the message uses:

const { requestId } = await client.send.message({
message: {
to: {
phone_number: "+15558675309",
},
content: {
title: "Order update",
body: "Hi Erika, your order has shipped.",
},
routing: {
method: "single",
channels: ["sms"],
},
},
});

Note: You can customize the above code based on your requirements. Please refer to the Courier documentation for more details.

Frequently asked questions

What is the easiest way to send an SMS in Node.js?

The quickest path is to install a provider SDK such as Twilio, MessageBird, or Plivo, create a client with your API credentials, and call the SDK's message-create method with a sender number, a recipient number, and the message body. For a production notification use case, pair that SMS API with a notification platform like Courier so you also get templates, user preferences, and multi-channel delivery from a single Send API call.

Do I need an SMS-enabled phone number to send SMS from Node.js?

Yes. Every SMS provider (Twilio, MessageBird, Plivo, and others) requires an SMS-enabled sending number or sender ID that you provision in that provider's console. Recipient numbers should be in E.164 format, for example +15558675309, to be delivered reliably across countries.

What is the difference between an SMS API and a notification API?

An SMS API delivers a single text message to a phone number. A notification API such as Courier sits on top of one or more SMS APIs and adds the logic a real application needs: reusable templates, user preferences, batching and throttling, scheduling, automatic failover between providers, and delivery to other channels like email, push, and in-app, all through one endpoint.

How do I send an SMS with Courier in Node.js?

Install the SDK with npm install @trycourier/courier, create a client with new Courier({ apiKey }), then call client.send.message with a message object that names the recipient (by user_id or phone_number), the content or a published template, and optional routing and data. The call returns a requestId you can use to track delivery.

How do I switch SMS providers without changing my code?

If you send through a notification platform, the provider is configured as a channel in the dashboard rather than hard-coded in your app. You can add a new SMS provider, reorder providers, or set up automatic failover between them without editing or redeploying your Node.js code, because your send call always targets the same Send API.

Can I send SMS and email from the same code in Node.js?

Yes. With a multi-channel notification API you send to a user rather than to a specific channel, and the platform routes the message to SMS, email, push, or an in-app inbox based on the notification's configuration and the user's preferences. This lets you add channels later without rewriting your send logic.

Conclusion

This article serves as a compilation of four summarized tutorials on how to send SMS using Node.js. With a basic understanding of Node.js, you should be able to choose between the four options above and enhance the functionality of your web or mobile application by sending SMS notifications. Thank you for reading.

One API, every channel

Ship notifications without the boilerplate

Courier gives you one API for email, SMS, push, and chat, with templates, routing, retries, and delivery logs built in.

Last updated Jul 6, 2026. Code samples are illustrative; provider APIs and pricing change over time, so check each provider’s docs before relying on them.