How Can I Send Sms Using Node.Js?


If you are using Windows, download and install Node.js
Linux/macOS, install it using the following command:


sudo apt install nodejs npm # Debian/Ubuntu brew install node # macOS

After installation, verify by running the following command in the Terminal or Command Prompt (cmd):


node -v

Install Axios (HTTP client for requests)


npm install axios

Copy and paste this code into a NodeJs file, save it as send_sms.js, and replace its contents with the provided NodeJs code. Then, update the Authentication_id and Authentication_key with your credentials. Click Authentication Key ID, and a page will display your 32-character Authentication ID and 32-character Authentication Key, which you can copy and paste into the script.


const axios = require('axios'); const sendSms = async () => { const url = "https://msgpserver.com/api/"; const data = { mtype: "N", to: "+91XXXXXXXXXX", message: "This is a test message from Note.JS...", auth_id: "Authentication_Id", auth_key: "Authentication_Key" }; try { const response = await axios.post(url, data, { headers: { 'Content-Type': 'application/json' } }); console.log("Response:", response.data); } catch (error) { console.error("Error:", error.response ? error.response.data : error.message); } }; sendSms();


node send_sms.js

Return Success Response.


[ SUCCESS ] {'status': 'success', 'login': 'success', 'recharge': 'success', 'host': 'success', 'msg': 'success'}

Return Error Response.


[ ERROR ] {'status': 'success', 'login': 'success', 'recharge': 'success', 'host': 'error', 'msg': 'error'} {'status': 'success', 'login': 'success', 'recharge': 'expire', 'host': 'error', 'msg': 'error'} {'status': 'online', 'login': 'error', 'recharge': 'error', 'host': 'error', 'msg': 'error'}


Are you satisfied this Answer?