SMS Node.js API example


const https = require('https')

const data = JSON.stringify({
  "sms": {
    "message": {
      "text": "Message API",
      "sender": "",
    },
    "recipients": {
      "gsm": [
        {
          "value": "41781234567"
        }
      ]
    }
  }
})

//Your first token must be generated on our plateform at https://app.smsup.ch/developers/api-tokens
const token = "your.token"

const options = {
  hostname: 'api.smsup.ch',
  port: 443,
  path: '/send',
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer ' + token
  }
}

const req = https.request(options, (res) => {
  console.log(`statusCode: ${res.statusCode}`)

  res.on('data', (d) => {
    process.stdout.write(d)
  })
})

req.on('error', (error) => {
  console.error(error)
})

req.write(data)
req.end()