Sample code to send texts

/*
for demo and quick start place this code in your app.js or server.js
please run 'npm install puretext --save' in terminal
*/

  const puretext = require('puretext');
  

  let text = {
      // To Number is the number you will be sending the text to.
      toNumber: '+X-XXX-XXX-XXXX',
      // From number is the number you will buy from your admin dashboard
      fromNumber: '+X-XXX-XXX-XXXX',
      // Text Content
      smsBody: 'Sending SMS using Node.js',
      //Sign up for an account to get an API Token
      apiToken: 'XXXXX'
  };

  puretext.send(text, function (err, response) {
    if(err) console.log(err);
    else console.log(response)
  })
How to get an API token?Signup for an account here and your dashboard will show your API tokenWhat is fromNumber?Once you sign up you can reserve a local number of any area code to send texts fromCan I use my existing mobile number as fromNumber?No, unfortunately you cannot.More questions?Contact Us