{"id":230,"date":"2017-02-23T16:08:37","date_gmt":"2017-02-23T22:08:37","guid":{"rendered":"https:\/\/voip-communications.net\/vcw\/?page_id=230"},"modified":"2017-11-15T12:59:40","modified_gmt":"2017-11-15T18:59:40","slug":"sms-api","status":"publish","type":"page","link":"https:\/\/voip-communications.net\/vcw\/sms\/sms-api\/","title":{"rendered":"SMS API"},"content":{"rendered":"<p>Send SMS messages to one or more destinations.<\/p>\n<h3>URL:<\/h3>\n<p>https:\/\/voip-communications.net\/api-v2\/index.php\/sms\/send<\/p>\n<h3>Method:<\/h3>\n<p>POST<\/p>\n<h3>Authentication:<\/h3>\n<p>Basic<\/p>\n<h3>Parameters:<\/h3>\n<ul>\n<li><strong>from<\/strong> (optional): If empty the message will be considered a BULK message (lower rate), otherwise, the phone number must belong to you and be SMS enabled, in this case, the message will be considered 2 Way SMS, the replies will be notified to the Callback URL defined for the phone number.<\/li>\n<li><strong>to<\/strong> <span style=\"color: #ff0000;\"><strong>(required)<\/strong><\/span>: Phone numbers to send the message to. You can specify more than one phone number separate them by commas &#8220;,&#8221;<\/li>\n<li><strong>msg <span style=\"color: #ff0000;\">(required)<\/span><\/strong>: Message to be sent. If the message length is more than 160 characters, the message will be split it into messages of 153 characters each<\/li>\n<li><strong>delivery_date<\/strong> (optional): Date to deliver the message in the next format YYYY-MM-DD HH:MM or any valid date format; If empty, the message will be delivered immediately. For messages scheduled to be delivered later, the charge will be applied just at the moment of the message be sent; you can delete messages for late delivery from the SMS Log or through the <a href=\"https:\/\/voip-communications.net\/vcw\/listdelete-scheduled-sms\/\">[API]<\/a><\/li>\n<\/ul>\n<h3>HTTP Response Codes:<\/h3>\n<ul>\n<li>200: Success<\/li>\n<li>401: Invalid api<span style=\"font-weight: inherit;\"> credentials<\/span><\/li>\n<\/ul>\n<h3>Response data:<\/h3>\n<p>You will get a JSON array with the log of each SMS processed.<\/p>\n<pre>{\r\n \"send_log\": [\r\n      {\r\n          \"code\": 200,\r\n          \"code_desc\": \"\",\r\n          \"from\": \"17134567890\",\r\n          \"to\": \"12812345678\",\r\n          \"country\": \"US\",\r\n          \"msg\": \"It is a SMS message\",\r\n          \"delivery_date\": \"2019-10-01 00:00:00\",\r\n          \"sale\": 0.01,\r\n          \"type\": \"BULKSMS\",\r\n          \"status\": \"SCHEDULED\",\r\n          \"smsid\": \"2017559ea27008c6b7122900621\"\r\n      }\r\n   ]\r\n}<\/pre>\n<p>Please note <strong><span style=\"color: #008000;\">&#8220;smsid&#8221;<\/span><\/strong>\u00a0into the response.\u00a0; It is a unique code for the process, and it is required to cancel the request (just if it is a scheduled SMS).\u00a0<a href=\"https:\/\/voip-communications.net\/vcw\/listdelete-scheduled-sms\/\">[click here]<\/a>\u00a0to see API methods to list\/delete\u00a0scheduled SMS.<\/p>\n<hr \/>\n<h3>Curl Example<\/h3>\n<pre>curl -u YOUR_API_KEY:YOUR_API_PASSWORD \r\n     --data\"to=TO_NUMBER&amp;msg=TEXT_MESSAGE\"\r\n     https:\/\/voip-communications.net\/api-v2\/index.php\/sms\/send<\/pre>\n<hr \/>\n<h3>PHP Example<\/h3>\n<pre>$service_url = \"https:\/\/voip-communications.net\/api-v2\/index.php\/sms\/send\";\r\n$curl = curl_init($service_url);\r\ncurl_setopt($curl, CURLOPT_USERPWD, \"YOUR_API_KEY:YOUR_API_PASSWORD\");\r\ncurl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\r\n$post_fields = array(\"from\" =&gt; \"FROM_NUMBER\",\r\n                     \"to\" =&gt; \"TO_NUMBER\",\r\n                     \"msg\" =&gt; \"TEXT_MESSAGE\",\r\n                     \"delivery_date\" =&gt; \"2010-01-01 13:15\");\r\ncurl_setopt($curl, CURLOPT_POST, true);\r\ncurl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_fields));\r\n$curl_response = curl_exec($curl);\r\nif ($curl_response !== false) {\r\n    $http_code = curl_getinfo($curl,CURLINFO_HTTP_CODE);\r\n    if ($http_code == \"200\") {\r\n        $result = json_decode($curl_response,true);\r\n        print_r($result);\r\n    }\r\n}\r\ncurl_close($curl);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Send SMS messages to one or more destinations. URL: https:\/\/voip-communications.net\/api-v2\/index.php\/sms\/send Method: POST Authentication: Basic Parameters: from (optional): If empty the message will be considered a BULK message (lower rate), otherwise, the phone number must belong to you and be SMS enabled, in this case, the message will be considered 2 Way SMS, the replies will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":22,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/230"}],"collection":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/comments?post=230"}],"version-history":[{"count":20,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/230\/revisions"}],"predecessor-version":[{"id":712,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/230\/revisions\/712"}],"up":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/22"}],"wp:attachment":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/media?parent=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}