npm version Build Status dependencies Known Vulnerabilities

A Node.js client library for Bandwidth's Communications Platform

API Documentation

The API documentation is located at

Full SDK Reference

The Full SDK Reference is available either as an interactive site or as a single Markdown file:

Installing the SDK

node-bandwidth is available on NPM:

npm install --save node-bandwidth

Supported Versions

node-bandwidth should work on all versions of node newer than 0.10.*. However, due to the rapid development in the Node and npm environment, we can only provide support on LTS versions of Node

Client initialization

All interaction with the API is done through a client Object. The client constructor takes an Object containing configuration options. The following options are supported:

Field name Description Default value Required
userId Your Bandwidth user ID undefined Yes
apiToken Your API token undefined Yes
apiSecret Your API secret undefined Yes
baseUrl The Bandwidth API URL No

To initialize the client object, provide your API credentials which can be found on your account page in the portal.

var Bandwidth = require("node-bandwidth");

var client = new Bandwidth({
    userId    : "YOUR_USER_ID", // <-- note, this is not the same as the username you used to login to the portal
    apiToken  : "YOUR_API_TOKEN",
    apiSecret : "YOUR_API_SECRET"

Your client object is now ready to use the API.

Callbacks or Promises

All functions of the client object take an optional Node.js style (err, result) callback, and also return a Promise. That way if you want to use Promises in your application, you don't have to wrap the SDK with a Promise library. You can simply do things like this:

Async / Await

try {
    const messageResponse = await client.Message.send({
        to: "+19198675309",
        from: "+18288675309",
        text: "Hi Jenny"
    console.log(`Message sent with Id: ${}`);
catch (e) {
    console.log("Error sending message");

Promise style

    from : "+12345678901", // This must be a Catapult number on your account
    to   : "+12345678902",
    text : "Hello world."
.then(function(message) {
    console.log("Message sent with ID " +;
.catch(function(err) {

If you're not into that kind of thing you can also do things the "old fashioned" callback way:

Callback style

    from : "+12345678901", // This must be a Catapult number on your account
    to   : "+12345678902",
    text : "Hello world."
}, function(err, message) {
    if (err) {
    console.log("Message sent with ID " +;

results matching ""

    No results matching ""