Send messages, check account balance, and manage contacts on WebText.com.

Node.js WebText.com API Client

Send messages, check account balance, and manage contacts on WebText.com.

The following will install this package and add it as a dependency to your project:

npm install --save

Require this package after installing with npm:

var WebText = require('webtext-api');

Create a WebText object with your API User and Password:

var user = 'bw13cexH',
    password = '5yw8Vhc3';
var wt = new WebText(user, password);

Now you can call the various API methods.

See the Sending Messages section below for details.

    text: 'First message from WebText!',
    to: '353861234567'
}, function (err) {
    if (!err) console.log('Message sent successfully!');
wt.balance(function (errbalance) {
    if (!err) console.log('Account has ' + balance + ' credits');
wt.contacts.save('353861234567', {
    name: 'David Doran'

Add the contact to a group:

wt.contacts.save('353861234567', {
    group: '888392630'

Just remove the contact from a group:

wt.contacts.remove('353861234567', {
    group: '888729566'
wt.groups.save('Customers', function (errgroup) {
    console.log('Group alias: ' + group);

The following message will be delivered 20 minutes from now, to group 888392630, with sender '*Alerts*', with the id '12345', and receipts will be delivered to 'webtext-receipts@example.com'.

var message = new WebText.Message({
    to: '888392630',
    from: '*Alerts*',
    text: 'This is an example SMS message',
    id: 12345,
    email: 'webtext-receipts@example.com',
    delivery_delta: 20

Here is the full list of supported properties with examples:

Required: to is a phone number, array of phone numbers, or an array of group aliases.

{to: ['353863123456', '353863654321', '353861940728']}

Required: text is the text of the message.

{text: 'Thanks for subscribing to SMS alerts!'}

unicode is the unicode text of the message (either text or unicode must be given).

{unicode: 'Μιλάς Ελληνικά'}

tag (or from) is the name that will appear as the message sender.

{tag: 'Alerts System'}

id is a unique numeric id for the message.

{id: '201300001'}

url is the URL to which message receipts should be sent.

{url: 'https://example.com/webtext-receipts'}

email is the email address to which message receipts should be sent.

{email: 'webtext-receipts@example.com'}

delivery_time is the date when the message should be sent, given by a Date object.

//Send the message on the 15th of January 2016 
{delivery_time: new Date('2016-01-15 18:00:00')}

delivery_delta is the number of minutes to wait before sending the message.

//Send the message 10 minutes from now 
{delivery_delta: 10}

validity is the number of minutes the SMS is valid for (after which delivery will not be attempted).

//Message is valid for 5 hours 
{validity: 300}

This project is released under the MIT License.