Twexit API - Node.js Twilio® API Alternative

Connecting to Notifyre via the Twexit API using Node.js

Twilio users can easily make the switch to Notifyre and save on their SMS messaging costs via the Twexit API. The Twexi API allows users to send SMS messages via Notifyre with minimal changes to existing Twilio SMS API code. Sitting on the fence? Read about what makes Notifyre the best SMS API and why switching from Twilio's SMS API can make a huge difference in your business.

Setting up your account

To use the Twexit API, create a Notifyre account and follow the steps below. 

Verify your phone number 

  1. Login to the Notifyre dashboard 
  2. If you are a first-time Notifyre user, click on your name in the top right hand corner of the dashboard and select "Profile" from the drop-down menu
  3. Enter your mobile number into the Phone Number field and click "Verify Number"
  4. You'll receive an SMS verification code. Enter the SMS code into the pop-up window and click "Verify Number"

Add API Testing Funds

  • Add funds to your account to test with. The minimum top up amount is $10. 
  • While in test mode your account will be able to: 
    1. Send a total of 20 SMS Parts (up to 160 characters per SMS part). 
    2. Send a total of 100 fax pages.
  • Our team will call you to verify your details and provide onboarding support. After this call your account limits will be lifted. To have your Notifyre account verified sooner, simply contact our friendly support team and quote your Notifyre account number.
  • USA: (866) 620-3220
  • AU: 1300 032 936
  • Email: support@notifyre.com

Generate an API token 

  1. Navigate to the settings tab on the right side of the Notifyre dashboard and click "Developer" from the drop-down menu
  2. Select the "API Tokens" tab and click "+New"

See: how to create an API token

Find your account ID

When setting up the Twexit API, you'll need your Notifyre account ID. To find this, simply:

  1. Navigate to the settings tab on the right side of the Notifyre dashboard and click "Account" from the drop-down menu
  2. On the "General" tab you'll be able to view your account ID

Using a virtual SMS number

You have the option to use a dedicated virtual mobile number to send and receive SMS via the Twexit API. If you do not setup a virtual mobile number, you will be unable to receive SMS replies.

See: adding a virtual SMS number to your account.

Using a custom SMS sender ID - Only available to Australian customers

You have the option to use a custom alphanumeric sender ID as the sender (from) when sending SMS via the Twexit API. In this case, you will not be able to receive SMS replies from your audience.

See: setting up a custom SMS sender ID on your account.

Sending an SMS message

To start sending SMS via the Twexit API, you must update the Request URL, the account ID and the API token in your existing Twilio API. 

1. Update the request URL 

To update the request URL, you will need to replace the existing HTTP POST URL:

https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json

with Notifyre's Twexit API URL in the Send SMS API endpoint:

https://twilio.api.notifyre.com/Accounts/${notifyreaccountSid}/Messages.json

2. Update the account ID 

To update the account ID, you will need to replace the variable TWILIO_ACCOUNT_SID with your Notifyre account ID. We recommended creating a new variable called NOTIFYRE_ACCOUNT_ID and replacing the Twilio variable with the Notifyre one in the Send SMS API endpoint. Alternatively, you can hardcode your Notifyre account ID.

3. Update the API token

To update the API token, you will need to replace the variable TWILIO_AUTH_TOKEN with your Notifyre API token. We recommend creating a new variable called NOTIFYRE_API_TOKEN and replacing the Twilio variable with the Notifyre one in the Send SMS API endpoint. Alternatively, you can hardcode your Notifyre API token.

Node.js code samples

Sample Node.js Javascript code in the Send SMS API endpoint with Twexit API updated variables: Request URL, Account ID and API token.

Original Twilio Send SMS API call:

const request = require('request');
const accountSid = 'TWILIO_ACCOUNT_SID';
const authToken = 'TWILIO_AUTH_TOKEN'
request.post(`https://api.twilio.com/Accounts/${TWILIO_ACCOUNT_SID}/Messages.json`, {
headers: {
'Authorization': 'Basic ' + Buffer.from(`${accountSid}:${authToken}`).toString('base64'),
},
form: {
body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
from: '+15017122661',
to: '+15558675310'
}
}, (err, _, body) => {
console.error('Send SMS error', err)
console.error('Send SMS response', body)
})

Updated Notifyre Twexit SMS API call: 

const request = require('request');
const accountSid = 'TWILIO_ACCOUNT_SID';
const authToken = 'TWILIO_AUTH_TOKEN'
const notifyreaccountSid = 'NOTIFYRE_ACCOUNT_ID' ;
const notifyreauthToken = 'NOTIFYRE_AUTH_TOKEN' ;

request.post(`https://twilio.api.notifyre.com/Accounts/${notifyreaccountSid}/Messages.json`, {
    headers: {
        'Authorization': 'Basic ' + Buffer.from(`${notifyreaccountSid}:${notifyreauthToken}`).toString('base64'),
    },
    form: {
        body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
        from: '+15017122661',
        to: '+15558675310'
    }
}, (err, _, body) => {
    console.error('Send SMS error', err)
    console.error('Send SMS response', body)
})

Responses are the same as Twilio's responses. The response should contain: 

{
    "error_code": null,
    "num_media": "0",
    "price_unit": "AUD",
    "subresource_uris": {},
    "uri": "",
    "api_version": "1.2.1",
    "account_sid": "{NOTIFYRE_ACCOUT_ID}",
    "sid": "ad85b548-9206-4d2c-b6e1-74ef2960a8b2",
    "body": "Test message from twilio adapter",
    "date_created": "Wed, 10 Aug 2022 01:15:19 +0000",
    "date_sent": null,
    "date_updated": null,
    "direction": "outbound-api",
    "error_message": "",
    "from": "Shared Number (+15017122661)",
    "messaging_service_sid": "22746a6e-f0c0-4075-88f6-5010e9050ebe",
    "num_segments": "1",
    "price": "0.05",
    "status": "sending",
    "to": "+15558675310"
}

Current limitations

  • The Twexit API does not currently support custom URL Callbacks
  • The Twexit API currently only supports the SMS Send API call
  • If using a Notifyre system number to send SMS, you will not be able to receive SMS replies (only available when using a dedicated virtual mobile number)