{"id":1316,"date":"2023-02-03T13:35:46","date_gmt":"2023-02-03T13:35:46","guid":{"rendered":"https:\/\/infobip.com\/developers\/?p=1316"},"modified":"2023-09-11T14:31:32","modified_gmt":"2023-09-11T14:31:32","slug":"send-an-sms-message-with-node-js-and-infobip","status":"publish","type":"post","link":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip","title":{"rendered":"Send an SMS message with Node.js and Infobip"},"content":{"rendered":"\n<p>In this blog post, we will use Node.js to build a simple library (Node.js) package that will enable us to send SMS messages over Infobip API using a single function call. The developed library can then be used in any number of projects to send any number of basic SMS text messages, with a minimum amount of configuration needed.<\/p>\n\n\n\n<p>We also have a <a href=\"https:\/\/github.com\/infobip-community\/infobip-api-node-sdk\">Node.js SDK<\/a> which should get you up and running in no time. Note that the example below creates a Node.js project from scratch with no packages or libraries.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Prerequisites\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.infobip.com\/signup\">Infobip account<\/a><\/li>\n\n\n\n<li>Working <a href=\"https:\/\/nodejs.org\/\">Node.js<\/a> environment, including <a href=\"https:\/\/www.npmjs.com\/\">npm<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Difficulty-level\">Difficulty level<\/h2>\n\n\n\n<p>This post assumes basic knowledge of JavaScript, Node.js, and HTTP.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Set-up-empty-project\">Set up an empty Node.js project<\/h2>\n\n\n\n<p>We will begin by setting up an empty Node.js project.\nInside an empty directory (let&#8217;s call it <code>sendsms<\/code>), run the <code>npm init<\/code> command to initialize a new Node.js project. You will need to answer a few questions that will be asked by <code>npm<\/code>, like the name and the version of the project. You can accept all the defaults suggested by <code>npm<\/code>, or fill out some information according to your preferences. In the end, <code>npm<\/code> will generate a <code>package.json<\/code> file containing something like:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n  &quot;name&quot;: &quot;sendsms&quot;,\n  &quot;version&quot;: &quot;1.0.0&quot;,\n  &quot;description&quot;: &quot;a simple Node.js project to send SMS messages&quot;,\n  &quot;main&quot;: &quot;index.js&quot;,\n  &quot;scripts&quot;: {\n    &quot;test&quot;: &quot;echo \\&quot;Error: no test specified\\&quot; && exit 1&quot;\n  },\n  &quot;author&quot;: &quot;&quot;,\n  &quot;license&quot;: &quot;ISC&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Add-dependencies\">Add dependencies<\/h2>\n\n\n\n<p>Our project will be very simple &#8211; we will only need one dependency. We&#8217;ll add a popular open-source HTTP client library called <a href=\"https:\/\/github.com\/axios\/axios\">Axios<\/a>.\nInside your project directory, run<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>npm install axios<\/code><\/pre><\/div>\n\n\n\n<p>You&#8217;ll notice that <code>axios<\/code> was added under <code>dependencies<\/code> inside your <code>package.json<\/code> file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Add-send-SMS-API-call\">Add the Send SMS API call<\/h2>\n\n\n\n<p>Our goal is to create a function with a signature.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>sendSms(config, destinationNumber, message)<\/code><\/pre><\/div>\n\n\n\n<p>Which we could use to send a single SMS message at a time.<\/p>\n\n\n\n<p>The parameters to use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>config<\/code> is an object with data, needed to execute the actual HTTP request against Infobip API.\\<\/li>\n\n\n\n<li>your custom Infobip API domain, <code>baseUrl<\/code> (e.g. <code>8935q9.api.infobip.com<\/code>) and your Infobip <code>APIkey<\/code> that you can access from within your Infobip account. You would typically store such information somewhere in your application&#8217;s configuration.\\<\/li>\n\n\n\n<li><code>destinationNumber<\/code> is the phone number (MSISDN) of the handset to which you want to send an SMS message. It must be in international format &#8211; that is, prefixed with the country and network prefix.<\/li>\n\n\n\n<li><code>message<\/code> is the actual text of the SMS message that you want to send.<\/li>\n<\/ul>\n\n\n\n<p>The function will need to do the appropriate HTTP POST call to <a href=\"https:\/\/www.infobip.com\/docs\/api\/channels\/sms\/sms-messaging\/outbound-sms\/send-sms-message\">Infobip Send SMS API<\/a> in order to send the SMS message. To implement it, we will split the work into three parts: constructing the URL, constructing request headers, and constructing the request body.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Construct-URL\">Construct a URL<\/h3>\n\n\n\n<p>The URL will always look like this: <code>https:\/\/&lt;your-custom-domain&gt;\/sms\/2\/text\/advanced<\/code>.  We can create a helper function that will use the custom domain from the configuration to build the correct URL:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const buildUrl = (domain) =&gt; {  \n        return `https:\/\/${domain}\/sms\/2\/text\/advanced`;  \n    }<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Construct-request-headers\">Construct request headers<\/h3>\n\n\n\n<p>The request to Infobip API needs to contain appropriate HTTP headers for authentication purposes, as described in the <a href=\"https:\/\/www.infobip.com\/docs\/essentials\/api-authentication\">documentation<\/a>. We will use the &#8220;API Key Header&#8221; authentication method, placing the API key into the <code>Authentication<\/code> header. We&#8217;ll also provide a header for the content type &#8211; we&#8217;ll be using <code>JSON<\/code>.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const buildHeaders = (apiKey) =&gt; {  \n       return {  \n          &#39;Content-Type&#39;: &#39;application\/json&#39;,  \n          &#39;Authorization&#39;: `App ${apiKey}`  \n      };  \n    }<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Construct-request-body\">Construct a request body<\/h3>\n\n\n\n<p>The <code>\/sms\/2\/text\/advanced<\/code> endpoint expects SMS message properties to be provided in the HTTP request body. We only need two properties for the basic case, the destination phone number and the message text. Following the format for the message body provided in the <a href=\"https:\/\/www.infobip.com\/docs\/api\/channels\/sms\/sms-messaging\/outbound-sms\/send-sms-message\">documentation<\/a>, we can make a helper function for that, too:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const buildRequestBody = (destinationNumber, message) =&gt; {  \n           const destinationObject = {  \n              to: destinationNumber  \n           };  \n           const messageObject = {  \n              destinations: [destinationObject],  \n              text: message  \n           };  \n           return {  \n              messages: [messageObject]  \n           }  \n    }<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Handling-API-responses\">Handling API responses<\/h3>\n\n\n\n<p>Once the HTTP request is executed, the response body will differ depending on whether the request was a success or a failure. Here, we&#8217;ll parse the response from the Axios HTTP client to a simple object containing a <code>success<\/code> boolean flag and message status information in case of success, or the error message in case of failure.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const parseSuccessResponse = (axiosResponse) =&gt; {  \n        const responseBody = axiosResponse.data;  \n        const singleMessageResponse = responseBody.messages[0];  \n        return {  \n            success: true,  \n            messageId: singleMessageResponse.messageId,  \n            status: singleMessageResponse.status.name,  \n            category: singleMessageResponse.status.groupName  \n          };  \n    }  \n \n    const parseFailedResponse = (axiosError) =&gt; {  \n        if (axiosError.response) {  \n            const responseBody = axiosError.response.data;  \n            return {  \n                success: false,  \n                errorMessage: responseBody.requestError.serviceException.text,  \n                errorDetails: responseBody  \n            }; \n        }  \n        return {  \n             success: false,  \n             errorMessage: axiosError.message  \n        };  \n    } <\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Add-helper-functions\">Add helper functions<\/h3>\n\n\n\n<p>We&#8217;ll add two more helper functions. One is to serve as a validation helper, to ensure that the <code>sendSms<\/code> function is called with the correct arguments. The other one is a helper function that wraps HTTP headers in an object as required by Axios&#8217;s <code>POST<\/code> function.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>  const validateNotEmpty = (value, fieldName) =&gt; {\n        if (!value) {\n            throw `${fieldName} parameter is mandatory`;\n        }\n    }\n\n    const buildAxiosConfig = (apiKey) =&gt; {\n        return {\n            headers: buildHeaders(apiKey)\n        };\n    }<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Send-SMS-message\">Send an SMS message<\/h2>\n\n\n\n<p>Finally, we have everything needed to put together for the <code>sendSms<\/code> function. The code itself is very straightforward:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const sendSms = (config, destinationNumber, message) =&gt; {\n        validateNotEmpty(config.domain, &#39;config.domain&#39;);\n        validateNotEmpty(config.apiKey, &#39;config.apiKey&#39;);\n        validateNotEmpty(destinationNumber, &#39;destinationNumber&#39;);\n        validateNotEmpty(message, &#39;message&#39;);\n    \n        const url = buildUrl(config.domain);\n        const requestBody = buildRequestBody(destinationNumber, message);\n        const axiosConfig = buildAxiosConfig(config.apiKey);\n\n        return axios.post(url, requestBody, axiosConfig)\n            .then(res =&gt; parseSuccessResponse(res))\n            .catch(err =&gt; parseFailedResponse(err));\n    }<\/code><\/pre><\/div>\n\n\n\n<p>To test out the code, we can put all the functions described so far in a single file called <code>send.js<\/code> in the root of our project. \nWe want to export the <code>sendSms()<\/code> function to use it elsewhere, so place the export at the end of the file:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>    module.exports = sendSms;<\/code><\/pre><\/div>\n\n\n\n<p>Now, create a file <code>index.js<\/code> inside the same directory (project root). We can import the <code>send<\/code> module and use it to send an SMS. We&#8217;ll just log the results to the console. Remember that if your Infobip account is in free trial mode, you can only send SMS to the phone number you used to create your Infobip account.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const sendSms = require(&#39;.\/send.js&#39;);    \n    const config = {  \n           domain: &#39;&lt;your-domain-here&gt;&#39;, \n            apiKey: &#39;&lt;your-api-key-here&gt;&#39;\n    };\n    sendSms(config,&#39;&lt;your-phone-number-here&gt;&#39;, `hello world` ).then(result =&gt; console.log(result));<\/code><\/pre><\/div>\n\n\n\n<p>Replace the placeholders with your actual API key, domain, and phone number, and that&#8217;s it, you can now run <code>node index.js<\/code> to send an SMS message!<\/p>\n\n\n\n<p><strong>Note:<\/strong> You can also download the completed project source files <a href=\"link_to_zip_file_with_source_code\">here<\/a>).<\/p>\n\n\n\n<p>Here is an example output in case of success, indicating that the message was accepted and is pending delivery:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;messages&quot;: [\n        {\n            &quot;messageId&quot;: &quot;3818998573364335793292&quot;,\n            &quot;status&quot;: {\n                &quot;description&quot;: &quot;Message sent to next instance&quot;,\n                &quot;groupId&quot;: 1,\n                &quot;groupName&quot;: &quot;PENDING&quot;,\n                &quot;id&quot;: 26,\n                &quot;name&quot;: &quot;PENDING_ACCEPTED&quot;\n            },\n            &quot;to&quot;: &quot;447515774433&quot;\n        }\n    ]\n}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Common-errors\">Common errors<\/h2>\n\n\n\n<p>Here, is an example response returned in the case that the provided API key is invalid:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;requestError&quot;: {\n        &quot;serviceException&quot;: {\n            &quot;messageId&quot;: &quot;UNAUTHORIZED&quot;,\n            &quot;text&quot;: &quot;Invalid login details&quot;\n        }\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p>For more details on status and error codes, visit <a href=\"https:\/\/www.infobip.com\/docs\/essentials\/response-status-and-error-codes\">documentation<\/a>.<\/p>\n\n\n\n<p>For the complete solution with code samples, visit <a href=\"https:\/\/github.com\/infobip-community\/send-sms-with-node.js-and-infobip\" target=\"_blank\" rel=\"noreferrer noopener\">Borna&#8217;s repo<\/a> on our GitHub Community!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we will use Node.js to [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_import_markdown_pro_load_document_selector":14,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[28,255],"tags":[43,46,62],"coauthors":[166],"class_list":["post-1316","post","type-post","status-publish","format-standard","hentry","category-blog-post","category-infobip-products","tag-api","tag-developer-docs","tag-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Send an SMS message with Node.js and Infobip - Infobip Developers Hub<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Send an SMS message with Node.js and Infobip - Infobip Developers Hub\" \/>\n<meta property=\"og:description\" content=\"In this blog post, we will use Node.js to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip\" \/>\n<meta property=\"og:site_name\" content=\"Infobip Developers Hub\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/infobip\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-03T13:35:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-11T14:31:32+00:00\" \/>\n<meta name=\"author\" content=\"Borna Biljan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InfobipDev\" \/>\n<meta name=\"twitter:site\" content=\"@InfobipDev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Borna Biljan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip\"},\"author\":{\"name\":\"Borna Biljan\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/c442e641a05fb262b315b6b5301e3972\"},\"headline\":\"Send an SMS message with Node.js and Infobip\",\"datePublished\":\"2023-02-03T13:35:46+00:00\",\"dateModified\":\"2023-09-11T14:31:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip\"},\"wordCount\":879,\"publisher\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\"},\"keywords\":[\"API\",\"developer docs\",\"tutorial\"],\"articleSection\":[\"Blog Post\",\"Infobip Products\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip\",\"url\":\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip\",\"name\":\"Send an SMS message with Node.js and Infobip - Infobip Developers Hub\",\"isPartOf\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#website\"},\"datePublished\":\"2023-02-03T13:35:46+00:00\",\"dateModified\":\"2023-09-11T14:31:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.infobip.com\/developers\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Send an SMS message with Node.js and Infobip\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#website\",\"url\":\"https:\/\/www.infobip.com\/developers\/\",\"name\":\"Infobip Developers Hub\",\"description\":\"Build meaningful customer relationships across any channel\",\"publisher\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.infobip.com\/developers\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#organization\",\"name\":\"Infobip Developers Hub\",\"url\":\"https:\/\/www.infobip.com\/developers\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png\",\"contentUrl\":\"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png\",\"width\":696,\"height\":696,\"caption\":\"Infobip Developers Hub\"},\"image\":{\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/infobip\/\",\"https:\/\/x.com\/InfobipDev\",\"https:\/\/www.youtube.com\/channel\/UCUPSTy53VecI5GIir3J3ZbQ\",\"https:\/\/github.com\/infobip-community\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/c442e641a05fb262b315b6b5301e3972\",\"name\":\"Borna Biljan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/image\/35278e2108926954cdc59bb317fb5b5a\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a02a8b5a58a07b8b210888ed21e6f2d6bffa647d2e894bf407a0e12aecb5b587?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a02a8b5a58a07b8b210888ed21e6f2d6bffa647d2e894bf407a0e12aecb5b587?s=96&d=mm&r=g\",\"caption\":\"Borna Biljan\"},\"description\":\"Borna works as a Staff Engineer at Infobip mostly on back-end services utilizing Java and Spring.\",\"url\":\"https:\/\/www.infobip.com\/developers\/blog\/author\/borna\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Send an SMS message with Node.js and Infobip - Infobip Developers Hub","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip","og_locale":"en_US","og_type":"article","og_title":"Send an SMS message with Node.js and Infobip - Infobip Developers Hub","og_description":"In this blog post, we will use Node.js to [&hellip;]","og_url":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip","og_site_name":"Infobip Developers Hub","article_publisher":"https:\/\/www.facebook.com\/infobip\/","article_published_time":"2023-02-03T13:35:46+00:00","article_modified_time":"2023-09-11T14:31:32+00:00","author":"Borna Biljan","twitter_card":"summary_large_image","twitter_creator":"@InfobipDev","twitter_site":"@InfobipDev","twitter_misc":{"Written by":"Borna Biljan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip#article","isPartOf":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip"},"author":{"name":"Borna Biljan","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/c442e641a05fb262b315b6b5301e3972"},"headline":"Send an SMS message with Node.js and Infobip","datePublished":"2023-02-03T13:35:46+00:00","dateModified":"2023-09-11T14:31:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip"},"wordCount":879,"publisher":{"@id":"https:\/\/www.infobip.com\/developers\/#organization"},"keywords":["API","developer docs","tutorial"],"articleSection":["Blog Post","Infobip Products"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip","url":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip","name":"Send an SMS message with Node.js and Infobip - Infobip Developers Hub","isPartOf":{"@id":"https:\/\/www.infobip.com\/developers\/#website"},"datePublished":"2023-02-03T13:35:46+00:00","dateModified":"2023-09-11T14:31:32+00:00","breadcrumb":{"@id":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.infobip.com\/developers\/blog\/send-an-sms-message-with-node-js-and-infobip#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.infobip.com\/developers\/"},{"@type":"ListItem","position":2,"name":"Send an SMS message with Node.js and Infobip"}]},{"@type":"WebSite","@id":"https:\/\/www.infobip.com\/developers\/#website","url":"https:\/\/www.infobip.com\/developers\/","name":"Infobip Developers Hub","description":"Build meaningful customer relationships across any channel","publisher":{"@id":"https:\/\/www.infobip.com\/developers\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.infobip.com\/developers\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.infobip.com\/developers\/#organization","name":"Infobip Developers Hub","url":"https:\/\/www.infobip.com\/developers\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/","url":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png","contentUrl":"https:\/\/www.infobip.com\/developers\/wp-content\/uploads\/2023\/03\/Infobip_logo_favicon.png","width":696,"height":696,"caption":"Infobip Developers Hub"},"image":{"@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/infobip\/","https:\/\/x.com\/InfobipDev","https:\/\/www.youtube.com\/channel\/UCUPSTy53VecI5GIir3J3ZbQ","https:\/\/github.com\/infobip-community"]},{"@type":"Person","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/c442e641a05fb262b315b6b5301e3972","name":"Borna Biljan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.infobip.com\/developers\/#\/schema\/person\/image\/35278e2108926954cdc59bb317fb5b5a","url":"https:\/\/secure.gravatar.com\/avatar\/a02a8b5a58a07b8b210888ed21e6f2d6bffa647d2e894bf407a0e12aecb5b587?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a02a8b5a58a07b8b210888ed21e6f2d6bffa647d2e894bf407a0e12aecb5b587?s=96&d=mm&r=g","caption":"Borna Biljan"},"description":"Borna works as a Staff Engineer at Infobip mostly on back-end services utilizing Java and Spring.","url":"https:\/\/www.infobip.com\/developers\/blog\/author\/borna"}]}},"_links":{"self":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/1316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/comments?post=1316"}],"version-history":[{"count":10,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/1316\/revisions"}],"predecessor-version":[{"id":2082,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/posts\/1316\/revisions\/2082"}],"wp:attachment":[{"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/media?parent=1316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/categories?post=1316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/tags?post=1316"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.infobip.com\/developers\/wp-json\/wp\/v2\/coauthors?post=1316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}