Skip to main content

Command Palette

Search for a command to run...

Sending SMS with Nodejs using Sendchamp SMS API

Updated
2 min read
Sending SMS with Nodejs using Sendchamp SMS API
A

Software engineer with a passion for building user-friendly and visually appealing websites and applications. I have a strong foundation in blockchain technology and developer advocacy.

The Sendchamp SMS API allows you to send SMS anywhere around the world. With your verified Sender ID, you can use the SMS API to facilitate outbound messages.

In this article, you will learn how to send SMS messages with Node.js.

Prerequisite

Before you can get started, make sure you have:

  • JavaScript knowledge and familiarity with nodejs.
  • Nodejs installed on your machine
  • Sendchamp account

To get started with Sendchamp SMS API, sign up on Sendchamp to get your API credentials. Once you signed up, go to your Sendchamp Dashboard to get your API key in the account settings section and you will find APIs & Webhook.

Setting up your Nodejs Application

Create a .js file, let’s call it index.js, and in the file, initialize an instance with your credentials:

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.sendchamp.com/api/v1/sms/send',
  'headers': {
    'Accept': 'application/json',
    'Authorization': 'Bearer ACCESS_KEY',
    'Content-Type': 'application/json'
  },

Make sure to replace ACCESS_KEY with your correct public access key on your sendchamp dashboard.

Sending SMS Messages

To send a message, pass the Sender ID you are sending the message from, a recipient number, message to be sent and the route.

Let’s try to hard-code a phone number (which should start with a country code, e.g. “2349039099438”) and a message to test out the SMS API:

body: JSON.stringify({"to":["2349039099438"],"message":"Testing Sendchamp SMS API","sender_name":"Sendchamp", "route":"dnd"})
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Let’s see if we will get an SMS.

unnamed.jpg

Leave a comment if you need further clarification. You can join our developer community here

More from this blog

Sadiqful

22 posts

A software developer who loves writing