SMS Send API

This is the part of the API that allows to send SMS messages, to single recipients, saved contacts or groups of contacts.

Remember to provide the authentication HTTP headers as described in the Authenticate using a session key and the Authenticate using a user tokeny sections.
All the query string parameters in URL must be UTF-8 URL Encoded.

Send an SMS message

Sends an SMS message to a given list of recipients.

Landing Pages URLs

It is possible to include a link to a published Landing Page by specifying the id_landing parameter and by adding the following placeholder in the message body: %PAGESLINK____________%.

Landing pages must be first created and published in your user panel, since you will need id_landing to send it.

A list of published landing pages can be retrieved by using the Landing Pages APIs

Short URLs

When including URLs in the message, it may be convinient to use short URLs to limit the number of characters used in the SMS message.

Our API can automatically generate a short link starting from a long one, and add it in the message.

o use this feature, use the %SHORT_LINK% placeholder in the message body, that will be replaced with the generated short link, and the respective short_link_url parameter, that should be set to a valid URL. For shortlink dns personalization please contact us at helpdesk@smsend.it

Sender Alias

Alphanumeric aliases require to be registered first, and need to be approved both from Us and AGCOM.

Aliases can be used only with high-quality message types.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/sms

Body Fields

Parameter Type Description Required Default
message_type String (“N” for High quality with reception notification, “L” for Medium Quality, “LL” For Low Cost) The type of SMS. Yes -
message String (max 1000 chars*) The body of the message. *Message max length could be 160 chars when using low-quality SMSs Yes -
recipient List(String) A list of recipents phone numbers Yes -
sender String The Sender name. If the message type allows a custom TPOA and the field is left empty, the user’s preferred TPOA is used. Must be empty if the message type does not allow a custom TPOA No “”
scheduled_delivery_time String [ddMMyy, yyyyMMdd, ddMMyyHHmm, yyyyMMddHHmmss, yyyy-MM-dd HH:mm, yyyy-MM-dd HH:mm.0] The messages will be sent at the given scheduled time No null
scheduled_delivery_timezone Timezone(IANA time zone) Optional timezone applied to scheduled_delivery_time date No -
order_id String Specifies a custom order ID No Generated UUID
returnCredits Bool Returns the number of credits used instead of the number of messages. i.e. when message is more than 160 chars long more than one credit is used No “false”
returnRemaining Bool Returs the number of remaining SMSs No false
allowInvalidRecipients Bool Sending to an invalid recipient does not block the operation No false
encoding String (“gsm” or “ucs2”) The SMS encoding. Use UCS2 for non standard character sets No “gsm”
id_landing int The id of the published page. Also add the %PAGESLINK____________% placeholder in the message body No -
campaign_name String The campaign name No -
short_link_url String The url where the short link redirects. Also add the %SHORT_LINK% placeholder in the message body No -

Returns

Code Description
201 SMSs have been scheduled for delivery.
400 Invalid input. Details are in the response body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The User_key was not found
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/sms' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "returnCredits": true, 
    "order_id": "123456789", 
    "recipient": [
        "+393471234567", 
        "+393471234568"
    ], 
    "scheduled_delivery_time": "20161223101010", 
    "message": "Hello world!", 
    "message_type": "GP", 
    "sender": "MySender"
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/sms' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "returnCredits": true, 
    "order_id": "123456789", 
    "recipient": [
        "+393471234567", 
        "+393471234568"
    ], 
    "scheduled_delivery_time": "20161223101010", 
    "message": "Hello world!", 
    "message_type": "GP", 
    "sender": "MySender"
}
'
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.io.OutputStream;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://app.gateway.smsend.it/API/v1.0/REST/sms");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setRequestProperty("user_key", "{USER_KEY}");

            // Use this when using Session Key authentication
            conn.setRequestProperty("Session_key", "{SESSION_KEY}");                  
            // When using Access Token authentication, use this instead:
            // conn.setRequestProperty("Access_token", "{ACCESS_TOKEN}");

            conn.setRequestMethod("POST");

            conn.setRequestProperty("Accept", "application/json");
            conn.setRequestProperty("Content-type", "application/json");
            conn.setDoOutput(true);

            String payload = "{" + 
              "    \"returnCredits\": true, " + 
              "    \"order_id\": \"123456789\", " + 
              "    \"recipient\": [" + 
              "        \"+393471234567\", " + 
              "        \"+393471234568\"" + 
              "    ], " + 
              "    \"scheduled_delivery_time\": \"20161223101010\", " + 
              "    \"message\": \"Hello world!\", " + 
              "    \"message_type\": \"GP\", " + 
              "    \"sender\": \"MySender\"" + 
              "}";

            OutputStream os = conn.getOutputStream();
            os.write(payload.getBytes());
            os.flush();

            if (conn.getResponseCode() != 201) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            BufferedReader br =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));

            String response = "";
            String output;
            while ((output = br.readLine()) != null) {
                response += output;
            }
            // You can parse the response using Google GSON or similar.
            // MyObject should be a class that reflect the JSON 
            // structure of the response

            GsonBuilder builder = new GsonBuilder();
            Gson gson = builder.create();
            MyObject responseObj = gson.fromJson(response, MyObject.class);
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
<?php

$payload = '{' . 
  '    "returnCredits": true, ' . 
  '    "order_id": "123456789", ' . 
  '    "recipient": [' . 
  '        "+393471234567", ' . 
  '        "+393471234568"' . 
  '    ], ' . 
  '    "scheduled_delivery_time": "20161223101010", ' . 
  '    "message": "Hello world!", ' . 
  '    "message_type": "GP", ' . 
  '    "sender": "MySender"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/sms');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-type: application/json',
    'user_key: {USER_KEY}',
    // Use this when using session key authentication
    'Session_key: {SESSION_KEY}',
    // When using Access Token authentication, use this instead:
    // 'Access_token: {ACCESS_TOKEN}'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if ($info['http_code'] != 201) {
    echo('Error!');
}
else {

    $obj = json_decode($response);
    print_r($obj);
}
?>
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
# pip install requests
import requests
import json
# Use this when using Session Key authentication
headers = { 'user_key': '{USER_KEY}', 'Session_key' : '{SESSION_KEY}', 'Content-type' : 'application/json' }
# When using Access Token authentication, use this instead:
# headers = { 'user_key': '{USER_KEY}', 'Access_token' : '{ACCESS_TOKEN}', 'Content-type' : 'application/json' }
payload = """{
    "returnCredits": true, 
    "order_id": "123456789", 
    "recipient": [
        "+393471234567", 
        "+393471234568"
    ], 
    "scheduled_delivery_time": "20161223101010", 
    "message": "Hello world!", 
    "message_type": "GP", 
    "sender": "MySender"
}"""

r = requests.post("https://app.gateway.smsend.it/API/v1.0/REST/sms", headers=headers, data=payload)

if r.status_code != 201:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text

    obj = json.loads(response)
    print(unicode(obj))
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
// Uses https://github.com/request/request
// npm install [-g] request

var request = require('request');

request({
    url: 'https://app.gateway.smsend.it/API/v1.0/REST/sms',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "returnCredits": true, 
        "order_id": "123456789", 
        "recipient": [
            "+393471234567", 
            "+393471234568"
        ], 
        "scheduled_delivery_time": "20161223101010", 
        "message": "Hello world!", 
        "message_type": "GP", 
        "sender": "MySender"
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 201) {

        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/sms")
payload =     {
        "returnCredits": true, 
        "order_id": "123456789", 
        "recipient": [
            "+393471234567", 
            "+393471234568"
        ], 
        "scheduled_delivery_time": "20161223101010", 
        "message": "Hello world!", 
        "message_type": "GP", 
        "sender": "MySender"
    }

# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request['Content-type'] = 'application/json'
request['user_key'] = '{USER_KEY}'
request['Session_key'] = '{SESSION_KEY}'
request.body = payload.to_json

# Send the request
responseData = http.request(request)
if responseData.code == "201"
  response = responseData.body

  obj = JSON.parse(response)
  puts obj
else
  puts "Error.."
end
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;

// We are using JSON.NET (http://www.newtonsoft.com/json)
using Newtonsoft.Json;

/*
 * The following code has been compiled and tested using the MONO
 * project.
 * 
 * To compile using MONO:
 * mcs -r:Newtonsoft.Json.dll example.cs
 */
namespace RestApplication
{
    class Program
    {        
        static void Main(string[] args)
        {
            using (var wb = new WebClient())
            {
                wb.Headers.Set(HttpRequestHeader.ContentType, "application/json");
                wb.Headers.Add("user_key", "{USER_KEY}");
                wb.Headers.Add("Session_key", "{SESSION_KEY}");

                String payload = "{" + 
                  "    \"returnCredits\": true, " + 
                  "    \"order_id\": \"123456789\", " + 
                  "    \"recipient\": [" + 
                  "        \"+393471234567\", " + 
                  "        \"+393471234568\"" + 
                  "    ], " + 
                  "    \"scheduled_delivery_time\": \"20161223101010\", " + 
                  "    \"message\": \"Hello world!\", " + 
                  "    \"message_type\": \"GP\", " + 
                  "    \"sender\": \"MySender\"" + 
                  "}";

                String response = wb.UploadString("https://app.gateway.smsend.it/API/v1.0/REST/sms", "POST", payload)

                dynamic obj = JsonConvert.DeserializeObject(response);
                Console.WriteLine(obj);
            }

        }
    }
}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
#!/usr/bin/env perl

use warnings;
use strict;
use LWP::UserAgent;

# Install using Cpan: "cpan JSON"
use JSON;

my $ua = LWP::UserAgent->new;

my $server_endpoint = "https://app.gateway.smsend.it/API/v1.0/REST/sms";

my $req = HTTP::Request->new(POST => $server_endpoint);

$req->header('Content_type' => 'application/json');

# IMPORTANT: Not adding the ':' before 'user_key' and
# 'Session_key' will result in perl to automatically rewrite the
# headers as 'User-Key' and 'Session-Key', which is not supported
# by our API.
$req->header(':user_key' => $auth->[0],
             ':Session_key' => $auth->[1]);
my $payload = {
    "returnCredits" => true, 
    "order_id" => "123456789", 
    "recipient" => [
        "+393471234567", 
        "+393471234568"
    ], 
    "scheduled_delivery_time" => "20161223101010", 
    "message" => "Hello world!", 
    "message_type" => "GP", 
    "sender" => "MySender"
};

$req->content(to_json($payload));
my $resp = $ua->request($req);
if ($resp->is_success && $resp->code == 201) {
  $response = $resp->decoded_content;
  my $obj = from_json($response);

}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}

Send a parametric SMS message

Sends a parametric SMS message to a given list of recipients. With this API it is possible to put placeholders in the message body, and then, for each recipient, specify the values that will replace the placeholders in the message body, for that particular recipient message.

Placeholders are in the form ${ParameterName}

When using parameters, the message length possibly changes between recipents. If a message length, when processed, exceeds the 1000 characters, an error code will be returned

Landing Pages URLs

It is possible to include a link to a published Landing Page by specifying the id_landing parameter and by adding the following placeholder in the message body: %PAGESLINK____________%.

Landing pages must be first created and published in your user panel, since you will need id_landing to send it.

A list of published landing pages can be retrieved by using the Landing Pages APIs

Short URLs

When including URLs in the message, it may be convinient to use short URLs to limit the number of characters used in the SMS message.

To use this feature, use the %SHORT_LINK% placeholder in the message body, that will be replaced with the generated short link, and the respective short_link_url parameter, that should be set to a valid URL. For shortlink dns personalization please contact us at helpdesk@smsend.it

Sender Alias

Alphanumeric aliases require to be registered first, and need to be approved both from Us and AGCOM.

Aliases can be used only with high-quality message types.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/paramsms

Body Fields

Parameter Type Description Required Default
message_type String (“N” for High quality with reception notification, “L” for Medium Quality, “LL” For Low Cost) The type of SMS. Yes -
message String (max 1000 chars with “gsm” encoding, 450 with “ucs2” encoding) The body of the message. *Message max length could be 160 chars when using low-quality SMSs Yes -
recipients Map(String, Map(String, String)) A map of recipents and relative parameters Yes -
sender String The Sender name. If the message type allows a custom TPOA and the field is left empty, the user’s preferred TPOA is used. Must be empty if the message type does not allow a custom TPOA No “”
scheduled_delivery_time String [ddMMyy, yyyyMMdd, ddMMyyHHmm, yyyyMMddHHmmss, yyyy-MM-dd HH:mm, yyyy-MM-dd HH:mm.0] The messages will be sent at the given scheduled time No null
scheduled_delivery_timezone Timezone(IANA time zone) Optional timezone applied to scheduled_delivery_time date No -
order_id String (max 32 chars, accepts only any letters, numbers, underscore, dot and dash) Specifies a custom order ID No Generated UUID
returnCredits Bool Returns the number of credits used instead of the number of messages. i.e. when message is more than 160 chars long more than one credit is used No false
returnRemaining Bool Returs the number of remaining SMSs No false
allowInvalidRecipients Bool Sending to an invalid recipient does not block the operation No false
encoding String (“gsm” or “ucs2”) The SMS encoding. Use UCS2 for non standard character sets No “gsm”
id_landing int The id of the published page. Also add the %PAGESLINK____________% placeholder in the message body No -
campaign_name String The campaign name No -
short_link_url String The url where the short link redirects. Also add the %SHORT_LINK% placeholder in the message body No -

Returns

Code Description
200 SMS have been successfully sent. The order ID and some other informations are returned
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The User_key was not found
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/paramsms' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "message_type": "GP", 
    "message": "Hello {name}, welcome to {nation}", 
    "sender": "MySender", 
    "scheduled_delivery_time": "20161223101010", 
    "order_id": "123456789", 
    "returnCredits": true, 
    "allowInvalidRecipients": false, 
    "returnRemaining": true, 
    "recipients": {
        "0": {
            "recipient": "+393471234567", 
            "name": "Mark"
        }, 
        "1": {
            "recipient": "+393477654321", 
            "nation": "Alabama"
        }
    }
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/paramsms' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "message_type": "GP", 
    "message": "Hello {name}, welcome to {nation}", 
    "sender": "MySender", 
    "scheduled_delivery_time": "20161223101010", 
    "order_id": "123456789", 
    "returnCredits": true, 
    "allowInvalidRecipients": false, 
    "returnRemaining": true, 
    "recipients": {
        "0": {
            "recipient": "+393471234567", 
            "name": "Mark"
        }, 
        "1": {
            "recipient": "+393477654321", 
            "nation": "Alabama"
        }
    }
}
'
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.io.OutputStream;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://app.gateway.smsend.it/API/v1.0/REST/paramsms");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setRequestProperty("user_key", "{USER_KEY}");

            // Use this when using Session Key authentication
            conn.setRequestProperty("Session_key", "{SESSION_KEY}");                  
            // When using Access Token authentication, use this instead:
            // conn.setRequestProperty("Access_token", "{ACCESS_TOKEN}");

            conn.setRequestMethod("POST");

            conn.setRequestProperty("Accept", "application/json");
            conn.setRequestProperty("Content-type", "application/json");
            conn.setDoOutput(true);

            String payload = "{" + 
              "    \"message_type\": \"GP\", " + 
              "    \"message\": \"Hello {name}, welcome to {nation}\", " + 
              "    \"sender\": \"MySender\", " + 
              "    \"scheduled_delivery_time\": \"20161223101010\", " + 
              "    \"order_id\": \"123456789\", " + 
              "    \"returnCredits\": true, " + 
              "    \"allowInvalidRecipients\": false, " + 
              "    \"returnRemaining\": true, " + 
              "    \"recipients\": {" + 
              "        \"0\": {" + 
              "            \"recipient\": \"+393471234567\", " + 
              "            \"name\": \"Mark\"" + 
              "        }, " + 
              "        \"1\": {" + 
              "            \"recipient\": \"+393477654321\", " + 
              "            \"nation\": \"Alabama\"" + 
              "        }" + 
              "    }" + 
              "}";

            OutputStream os = conn.getOutputStream();
            os.write(payload.getBytes());
            os.flush();

            if (conn.getResponseCode() != 201) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            BufferedReader br =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));

            String response = "";
            String output;
            while ((output = br.readLine()) != null) {
                response += output;
            }
            // You can parse the response using Google GSON or similar.
            // MyObject should be a class that reflect the JSON 
            // structure of the response

            GsonBuilder builder = new GsonBuilder();
            Gson gson = builder.create();
            MyObject responseObj = gson.fromJson(response, MyObject.class);
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
<?php

$payload = '{' . 
  '    "message_type": "GP", ' . 
  '    "message": "Hello {name}, welcome to {nation}", ' . 
  '    "sender": "MySender", ' . 
  '    "scheduled_delivery_time": "20161223101010", ' . 
  '    "order_id": "123456789", ' . 
  '    "returnCredits": true, ' . 
  '    "allowInvalidRecipients": false, ' . 
  '    "returnRemaining": true, ' . 
  '    "recipients": {' . 
  '        "0": {' . 
  '            "recipient": "+393471234567", ' . 
  '            "name": "Mark"' . 
  '        }, ' . 
  '        "1": {' . 
  '            "recipient": "+393477654321", ' . 
  '            "nation": "Alabama"' . 
  '        }' . 
  '    }' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/paramsms');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-type: application/json',
    'user_key: {USER_KEY}',
    // Use this when using session key authentication
    'Session_key: {SESSION_KEY}',
    // When using Access Token authentication, use this instead:
    // 'Access_token: {ACCESS_TOKEN}'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if ($info['http_code'] != 201) {
    echo('Error!');
}
else {

    $obj = json_decode($response);
    print_r($obj);
}
?>
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
# pip install requests
import requests
import json
# Use this when using Session Key authentication
headers = { 'user_key': '{USER_KEY}', 'Session_key' : '{SESSION_KEY}', 'Content-type' : 'application/json' }
# When using Access Token authentication, use this instead:
# headers = { 'user_key': '{USER_KEY}', 'Access_token' : '{ACCESS_TOKEN}', 'Content-type' : 'application/json' }
payload = """{
    "message_type": "GP", 
    "message": "Hello {name}, welcome to {nation}", 
    "sender": "MySender", 
    "scheduled_delivery_time": "20161223101010", 
    "order_id": "123456789", 
    "returnCredits": true, 
    "allowInvalidRecipients": false, 
    "returnRemaining": true, 
    "recipients": {
        "0": {
            "recipient": "+393471234567", 
            "name": "Mark"
        }, 
        "1": {
            "recipient": "+393477654321", 
            "nation": "Alabama"
        }
    }
}"""

r = requests.post("https://app.gateway.smsend.it/API/v1.0/REST/paramsms", headers=headers, data=payload)

if r.status_code != 201:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text

    obj = json.loads(response)
    print(unicode(obj))
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
// Uses https://github.com/request/request
// npm install [-g] request

var request = require('request');

request({
    url: 'https://app.gateway.smsend.it/API/v1.0/REST/paramsms',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "message_type": "GP", 
        "message": "Hello {name}, welcome to {nation}", 
        "sender": "MySender", 
        "scheduled_delivery_time": "20161223101010", 
        "order_id": "123456789", 
        "returnCredits": true, 
        "allowInvalidRecipients": false, 
        "returnRemaining": true, 
        "recipients": {
            "0": {
                "recipient": "+393471234567", 
                "name": "Mark"
            }, 
            "1": {
                "recipient": "+393477654321", 
                "nation": "Alabama"
            }
        }
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 201) {

        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/paramsms")
payload =     {
        "message_type": "GP", 
        "message": "Hello {name}, welcome to {nation}", 
        "sender": "MySender", 
        "scheduled_delivery_time": "20161223101010", 
        "order_id": "123456789", 
        "returnCredits": true, 
        "allowInvalidRecipients": false, 
        "returnRemaining": true, 
        "recipients": {
            "0": {
                "recipient": "+393471234567", 
                "name": "Mark"
            }, 
            "1": {
                "recipient": "+393477654321", 
                "nation": "Alabama"
            }
        }
    }

# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request['Content-type'] = 'application/json'
request['user_key'] = '{USER_KEY}'
request['Session_key'] = '{SESSION_KEY}'
request.body = payload.to_json

# Send the request
responseData = http.request(request)
if responseData.code == "201"
  response = responseData.body

  obj = JSON.parse(response)
  puts obj
else
  puts "Error.."
end
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;

// We are using JSON.NET (http://www.newtonsoft.com/json)
using Newtonsoft.Json;

/*
 * The following code has been compiled and tested using the MONO
 * project.
 * 
 * To compile using MONO:
 * mcs -r:Newtonsoft.Json.dll example.cs
 */
namespace RestApplication
{
    class Program
    {        
        static void Main(string[] args)
        {
            using (var wb = new WebClient())
            {
                wb.Headers.Set(HttpRequestHeader.ContentType, "application/json");
                wb.Headers.Add("user_key", "{USER_KEY}");
                wb.Headers.Add("Session_key", "{SESSION_KEY}");

                String payload = "{" + 
                  "    \"message_type\": \"GP\", " + 
                  "    \"message\": \"Hello {name}, welcome to {nation}\", " + 
                  "    \"sender\": \"MySender\", " + 
                  "    \"scheduled_delivery_time\": \"20161223101010\", " + 
                  "    \"order_id\": \"123456789\", " + 
                  "    \"returnCredits\": true, " + 
                  "    \"allowInvalidRecipients\": false, " + 
                  "    \"returnRemaining\": true, " + 
                  "    \"recipients\": {" + 
                  "        \"0\": {" + 
                  "            \"recipient\": \"+393471234567\", " + 
                  "            \"name\": \"Mark\"" + 
                  "        }, " + 
                  "        \"1\": {" + 
                  "            \"recipient\": \"+393477654321\", " + 
                  "            \"nation\": \"Alabama\"" + 
                  "        }" + 
                  "    }" + 
                  "}";

                String response = wb.UploadString("https://app.gateway.smsend.it/API/v1.0/REST/paramsms", "POST", payload)

                dynamic obj = JsonConvert.DeserializeObject(response);
                Console.WriteLine(obj);
            }

        }
    }
}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
#!/usr/bin/env perl

use warnings;
use strict;
use LWP::UserAgent;

# Install using Cpan: "cpan JSON"
use JSON;

my $ua = LWP::UserAgent->new;

my $server_endpoint = "https://app.gateway.smsend.it/API/v1.0/REST/paramsms";

my $req = HTTP::Request->new(POST => $server_endpoint);

$req->header('Content_type' => 'application/json');

# IMPORTANT: Not adding the ':' before 'user_key' and
# 'Session_key' will result in perl to automatically rewrite the
# headers as 'User-Key' and 'Session-Key', which is not supported
# by our API.
$req->header(':user_key' => $auth->[0],
             ':Session_key' => $auth->[1]);
my $payload = {
    "message_type" => "GP", 
    "message" => "Hello {name}, welcome to {nation}", 
    "sender" => "MySender", 
    "scheduled_delivery_time" => "20161223101010", 
    "order_id" => "123456789", 
    "returnCredits" => true, 
    "allowInvalidRecipients" => false, 
    "returnRemaining" => true, 
    "recipients" => {
        "0" => {
            "recipient" => "+393471234567", 
            "name" => "Mark"
        }, 
        "1" => {
            "recipient" => "+393477654321", 
            "nation" => "Alabama"
        }
    }
};

$req->content(to_json($payload));
my $resp = $ua->request($req);
if ($resp->is_success && $resp->code == 201) {
  $response = $resp->decoded_content;
  my $obj = from_json($response);

}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}

Send an SMS message to a group

Send an SMS message to a set of contacts groups.

Landing Pages URLs

It is possible to include a link to a published Landing Page by specifying the id_landing parameter and by adding the following placeholder in the message body: %PAGESLINK____________%.

Landing pages must be first created and published in your user panel, since you will need id_landing to send it.

A list of published landing pages can be retrieved by using the Landing Pages APIs

Short URLs

When including URLs in the message, it may be convinient to use short URLs to limit the number of characters used in the SMS message.

Our API can automatically generate a short link starting from a long one, and add it in the message.

To use this feature, use the %SHORT_LINK% placeholder in the message body, that will be replaced with the generated short link, and the respective short_link_url parameter, that should be set to a valid URL. For shortlink dns personalization please contact us at helpdesk@smsend.it

Sender Alias

Alphanumeric aliases require to be registered first, and need to be approved both from Us and AGCOM.

Aliases can be used only with high-quality message types.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/smstogroups

Body Fields

Parameter Type Description Required Default
message_type String (“N” for High quality with reception notification, “L” for Medium Quality, “LL” For Low Cost) The type of SMS. Yes -
message String (max 1000 chars with “gsm” encoding, 450 with “ucs2” encoding) The body of the message. *Message max length could be 160 chars when using low-quality SMSs Yes -
recipient List(String) A list of contact group names Yes -
sender String The Sender name. If the message type allows a custom TPOA and the field is left empty, the user’s preferred TPOA is used. Must be empty if the message type does not allow a custom TPOA No “”
scheduled_delivery_time String [ddMMyy, yyyyMMdd, ddMMyyHHmm, yyyyMMddHHmmss, yyyy-MM-dd HH:mm, yyyy-MM-dd HH:mm.0] The messages will be sent at the given scheduled time No null
scheduled_delivery_timezone Timezone(IANA time zone) Optional timezone applied to scheduled_delivery_time date No -
order_id String (max 32 chars, accepts only any letters, numbers, underscore, dot and dash) Specifies a custom order ID No Generated UUID
returnCredits Bool Returns the number of credits used instead of the number of messages. i.e. when message is more than 160 chars long more than one credit is used No “false”
returnRemaining Bool Returs the number of remaining SMSs No false
allowInvalidRecipients Bool Sending to an invalid recipient does not block the operation No false
encoding String (“gsm” or “ucs2”) The SMS encoding. Use UCS2 for non standard character sets No “gsm”
id_landing int The id of the published page. Also add the %PAGESLINK____________% placeholder in the message body No -
campaign_name String The campaign name No -
short_link_url String The url where the short link redirects. Also add the %SHORT_LINK% placeholder in the message body No -

Returns

Code Description
200 Successful request
400 Groups could not be found, or other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The User_key was not found
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/smstogroups' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "returnCredits": true, 
    "order_id": "123456789", 
    "recipient": [
        "Group1", 
        "Group2"
    ], 
    "scheduled_delivery_time": "20161223101010", 
    "message": "Hello world!", 
    "message_type": "GP", 
    "sender": "MySender"
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/smstogroups' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "returnCredits": true, 
    "order_id": "123456789", 
    "recipient": [
        "Group1", 
        "Group2"
    ], 
    "scheduled_delivery_time": "20161223101010", 
    "message": "Hello world!", 
    "message_type": "GP", 
    "sender": "MySender"
}
'
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.io.OutputStream;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://app.gateway.smsend.it/API/v1.0/REST/smstogroups");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setRequestProperty("user_key", "{USER_KEY}");

            // Use this when using Session Key authentication
            conn.setRequestProperty("Session_key", "{SESSION_KEY}");                  
            // When using Access Token authentication, use this instead:
            // conn.setRequestProperty("Access_token", "{ACCESS_TOKEN}");

            conn.setRequestMethod("POST");

            conn.setRequestProperty("Accept", "application/json");
            conn.setRequestProperty("Content-type", "application/json");
            conn.setDoOutput(true);

            String payload = "{" + 
              "    \"returnCredits\": true, " + 
              "    \"order_id\": \"123456789\", " + 
              "    \"recipient\": [" + 
              "        \"Group1\", " + 
              "        \"Group2\"" + 
              "    ], " + 
              "    \"scheduled_delivery_time\": \"20161223101010\", " + 
              "    \"message\": \"Hello world!\", " + 
              "    \"message_type\": \"GP\", " + 
              "    \"sender\": \"MySender\"" + 
              "}";

            OutputStream os = conn.getOutputStream();
            os.write(payload.getBytes());
            os.flush();

            if (conn.getResponseCode() != 201) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            BufferedReader br =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));

            String response = "";
            String output;
            while ((output = br.readLine()) != null) {
                response += output;
            }
            // You can parse the response using Google GSON or similar.
            // MyObject should be a class that reflect the JSON 
            // structure of the response

            GsonBuilder builder = new GsonBuilder();
            Gson gson = builder.create();
            MyObject responseObj = gson.fromJson(response, MyObject.class);
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
<?php

$payload = '{' . 
  '    "returnCredits": true, ' . 
  '    "order_id": "123456789", ' . 
  '    "recipient": [' . 
  '        "Group1", ' . 
  '        "Group2"' . 
  '    ], ' . 
  '    "scheduled_delivery_time": "20161223101010", ' . 
  '    "message": "Hello world!", ' . 
  '    "message_type": "GP", ' . 
  '    "sender": "MySender"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/smstogroups');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-type: application/json',
    'user_key: {USER_KEY}',
    // Use this when using session key authentication
    'Session_key: {SESSION_KEY}',
    // When using Access Token authentication, use this instead:
    // 'Access_token: {ACCESS_TOKEN}'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if ($info['http_code'] != 201) {
    echo('Error!');
}
else {

    $obj = json_decode($response);
    print_r($obj);
}
?>
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
# pip install requests
import requests
import json
# Use this when using Session Key authentication
headers = { 'user_key': '{USER_KEY}', 'Session_key' : '{SESSION_KEY}', 'Content-type' : 'application/json' }
# When using Access Token authentication, use this instead:
# headers = { 'user_key': '{USER_KEY}', 'Access_token' : '{ACCESS_TOKEN}', 'Content-type' : 'application/json' }
payload = """{
    "returnCredits": true, 
    "order_id": "123456789", 
    "recipient": [
        "Group1", 
        "Group2"
    ], 
    "scheduled_delivery_time": "20161223101010", 
    "message": "Hello world!", 
    "message_type": "GP", 
    "sender": "MySender"
}"""

r = requests.post("https://app.gateway.smsend.it/API/v1.0/REST/smstogroups", headers=headers, data=payload)

if r.status_code != 201:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text

    obj = json.loads(response)
    print(unicode(obj))
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
// Uses https://github.com/request/request
// npm install [-g] request

var request = require('request');

request({
    url: 'https://app.gateway.smsend.it/API/v1.0/REST/smstogroups',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "returnCredits": true, 
        "order_id": "123456789", 
        "recipient": [
            "Group1", 
            "Group2"
        ], 
        "scheduled_delivery_time": "20161223101010", 
        "message": "Hello world!", 
        "message_type": "GP", 
        "sender": "MySender"
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 201) {

        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/smstogroups")
payload =     {
        "returnCredits": true, 
        "order_id": "123456789", 
        "recipient": [
            "Group1", 
            "Group2"
        ], 
        "scheduled_delivery_time": "20161223101010", 
        "message": "Hello world!", 
        "message_type": "GP", 
        "sender": "MySender"
    }

# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.request_uri)
request['Content-type'] = 'application/json'
request['user_key'] = '{USER_KEY}'
request['Session_key'] = '{SESSION_KEY}'
request.body = payload.to_json

# Send the request
responseData = http.request(request)
if responseData.code == "201"
  response = responseData.body

  obj = JSON.parse(response)
  puts obj
else
  puts "Error.."
end
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;

// We are using JSON.NET (http://www.newtonsoft.com/json)
using Newtonsoft.Json;

/*
 * The following code has been compiled and tested using the MONO
 * project.
 * 
 * To compile using MONO:
 * mcs -r:Newtonsoft.Json.dll example.cs
 */
namespace RestApplication
{
    class Program
    {        
        static void Main(string[] args)
        {
            using (var wb = new WebClient())
            {
                wb.Headers.Set(HttpRequestHeader.ContentType, "application/json");
                wb.Headers.Add("user_key", "{USER_KEY}");
                wb.Headers.Add("Session_key", "{SESSION_KEY}");

                String payload = "{" + 
                  "    \"returnCredits\": true, " + 
                  "    \"order_id\": \"123456789\", " + 
                  "    \"recipient\": [" + 
                  "        \"Group1\", " + 
                  "        \"Group2\"" + 
                  "    ], " + 
                  "    \"scheduled_delivery_time\": \"20161223101010\", " + 
                  "    \"message\": \"Hello world!\", " + 
                  "    \"message_type\": \"GP\", " + 
                  "    \"sender\": \"MySender\"" + 
                  "}";

                String response = wb.UploadString("https://app.gateway.smsend.it/API/v1.0/REST/smstogroups", "POST", payload)

                dynamic obj = JsonConvert.DeserializeObject(response);
                Console.WriteLine(obj);
            }

        }
    }
}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}
Copy code
#!/usr/bin/env perl

use warnings;
use strict;
use LWP::UserAgent;

# Install using Cpan: "cpan JSON"
use JSON;

my $ua = LWP::UserAgent->new;

my $server_endpoint = "https://app.gateway.smsend.it/API/v1.0/REST/smstogroups";

my $req = HTTP::Request->new(POST => $server_endpoint);

$req->header('Content_type' => 'application/json');

# IMPORTANT: Not adding the ':' before 'user_key' and
# 'Session_key' will result in perl to automatically rewrite the
# headers as 'User-Key' and 'Session-Key', which is not supported
# by our API.
$req->header(':user_key' => $auth->[0],
             ':Session_key' => $auth->[1]);
my $payload = {
    "returnCredits" => true, 
    "order_id" => "123456789", 
    "recipient" => [
        "Group1", 
        "Group2"
    ], 
    "scheduled_delivery_time" => "20161223101010", 
    "message" => "Hello world!", 
    "message_type" => "GP", 
    "sender" => "MySender"
};

$req->content(to_json($payload));
my $resp = $ua->request($req);
if ($resp->is_success && $resp->code == 201) {
  $response = $resp->decoded_content;
  my $obj = from_json($response);

}
On success, the above command returns the following response:
{
    "result" : "OK",    "//OK or errors"
    "order_id" : "123456789",
    "total_sent" : 2    "//SMS sent or credits used"
}

Get SMS message state

Get informations on the SMS delivery status of the given order_id.

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}

Parameters

Parameter Type Description Required Default
order_id String The order ID Yes -

Returns

Code Description
200 A Json object representing the status of the given SMS order.
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The order_id was not found

Possible returned statuses are:

Status Value
WAITING “WAITING”
SENT_TO_SMSC “SENT”
WAITING_DELIVERY “WAIT4DLVR”
SENT “SENT”
DELIVERY_RECEIVED “DLVRD”
TOO_MANY_SMS_FROM_USER “TOOM4USER”
TOO_MANY_SMS_FOR_NUMBER “TOOM4NUM”
ERROR “ERROR”
TIMEOUT “TIMEOUT”
UNPARSABLE_RCPT “UNKNRCPT”
UNKNOWN_PREFIX “UNKNPFX”
SENT_IN_DEMO_MODE “DEMO”
WAITING_DELAYED “SCHEDULED”
INVALID_DESTINATION “INVALIDDST”
NUMBER_BLACKLISTED “BLACKLISTED”
NUMBER_USER_BLACKLISTED “BLACKLISTED”
SMSC_REJECTED “KO”
INVALID_CONTENTS “INVALIDCONTENTS”
Copy code
# Session Key example
curl -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' 

# Access token example
curl -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}'
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}
Copy code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.io.OutputStream;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setRequestProperty("user_key", "{USER_KEY}");

            // Use this when using Session Key authentication
            conn.setRequestProperty("Session_key", "{SESSION_KEY}");                  
            // When using Access Token authentication, use this instead:
            // conn.setRequestProperty("Access_token", "{ACCESS_TOKEN}");

            conn.setRequestMethod("GET");

            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            BufferedReader br =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));

            String response = "";
            String output;
            while ((output = br.readLine()) != null) {
                response += output;
            }
            // You can parse the response using Google GSON or similar.
            // MyObject should be a class that reflect the JSON 
            // structure of the response

            GsonBuilder builder = new GsonBuilder();
            Gson gson = builder.create();
            MyObject responseObj = gson.fromJson(response, MyObject.class);
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-type: application/json',
    'user_key: {USER_KEY}',
    // Use this when using session key authentication
    'Session_key: {SESSION_KEY}',
    // When using Access Token authentication, use this instead:
    // 'Access_token: {ACCESS_TOKEN}'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if ($info['http_code'] != 200) {
    echo('Error!');
}
else {

    $obj = json_decode($response);
    print_r($obj);
}
?>
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}
Copy code
# pip install requests
import requests
import json
# Use this when using Session Key authentication
headers = { 'user_key': '{USER_KEY}', 'Session_key' : '{SESSION_KEY}', 'Content-type' : 'application/json' }
# When using Access Token authentication, use this instead:
# headers = { 'user_key': '{USER_KEY}', 'Access_token' : '{ACCESS_TOKEN}', 'Content-type' : 'application/json' }

r = requests.get("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}", headers=headers)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text

    obj = json.loads(response)
    print(unicode(obj))
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}
Copy code
// Uses https://github.com/request/request
// npm install [-g] request

var request = require('request');

request({
    url: 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}',
    method: 'GET',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 200) {

        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}")

# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)
request['Content-type'] = 'application/json'
request['user_key'] = '{USER_KEY}'
request['Session_key'] = '{SESSION_KEY}'

# Send the request
responseData = http.request(request)
if responseData.code == "200"
  response = responseData.body

  obj = JSON.parse(response)
  puts obj
else
  puts "Error.."
end
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}
Copy code
using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;

// We are using JSON.NET (http://www.newtonsoft.com/json)
using Newtonsoft.Json;

/*
 * The following code has been compiled and tested using the MONO
 * project.
 * 
 * To compile using MONO:
 * mcs -r:Newtonsoft.Json.dll example.cs
 */
namespace RestApplication
{
    class Program
    {        
        static void Main(string[] args)
        {
            using (var wb = new WebClient())
            {
                wb.Headers.Set(HttpRequestHeader.ContentType, "application/json");
                wb.Headers.Add("user_key", "{USER_KEY}");
                wb.Headers.Add("Session_key", "{SESSION_KEY}");

                String response = wb.DownloadString("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}");

                dynamic obj = JsonConvert.DeserializeObject(response);
                Console.WriteLine(obj);
            }

        }
    }
}
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}
Copy code
#!/usr/bin/env perl

use warnings;
use strict;
use LWP::UserAgent;

# Install using Cpan: "cpan JSON"
use JSON;

my $ua = LWP::UserAgent->new;

my $server_endpoint = "https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}";

my $req = HTTP::Request->new(GET => $server_endpoint);

$req->header('Content_type' => 'application/json');

# IMPORTANT: Not adding the ':' before 'user_key' and
# 'Session_key' will result in perl to automatically rewrite the
# headers as 'User-Key' and 'Session-Key', which is not supported
# by our API.
$req->header(':user_key' => $auth->[0],
             ':Session_key' => $auth->[1]);
my $resp = $ua->request($req);
if ($resp->is_success && $resp->code == 200) {
  $response = $resp->decoded_content;
  my $obj = from_json($response);

}
On success, the above command returns the following response:
{
    "recipient_number": 1,
    "result": "OK",
    "recipients": [
        {
            "status": "WAITING",
            "destination": "+393471234567",
            "delivery_date": ""
        }
    ]
}

Delete a scheduled message

Deletes the SMS delivery process of the given order_id.

HTTP Headers

user_key / Session_key

HTTP Method

DELETE

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}

Parameters

Parameter Type Description Required Default
order_id String The order id Yes -

Returns

Code Description
200 Scheduled Message sending
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The given order_id was not found, or the message sending could not be removed (e.g. Message status is not “SCHEDULED”)
Copy code
# Session Key example
curl -XDELETE 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' 

# Access token example
curl -XDELETE 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}'
On success, the above command returns the following response:
{"result":"OK"}
Copy code
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.io.OutputStream;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setRequestProperty("user_key", "{USER_KEY}");

            // Use this when using Session Key authentication
            conn.setRequestProperty("Session_key", "{SESSION_KEY}");                  
            // When using Access Token authentication, use this instead:
            // conn.setRequestProperty("Access_token", "{ACCESS_TOKEN}");

            conn.setRequestMethod("DELETE");

            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            BufferedReader br =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));

            String response = "";
            String output;
            while ((output = br.readLine()) != null) {
                response += output;
            }
            // You can parse the response using Google GSON or similar.
            // MyObject should be a class that reflect the JSON 
            // structure of the response

            GsonBuilder builder = new GsonBuilder();
            Gson gson = builder.create();
            MyObject responseObj = gson.fromJson(response, MyObject.class);
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
{"result":"OK"}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-type: application/json',
    'user_key: {USER_KEY}',
    // Use this when using session key authentication
    'Session_key: {SESSION_KEY}',
    // When using Access Token authentication, use this instead:
    // 'Access_token: {ACCESS_TOKEN}'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');

$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if ($info['http_code'] != 200) {
    echo('Error!');
}
else {

    $obj = json_decode($response);
    print_r($obj);
}
?>
On success, the above command returns the following response:
{"result":"OK"}
Copy code
# pip install requests
import requests
import json
# Use this when using Session Key authentication
headers = { 'user_key': '{USER_KEY}', 'Session_key' : '{SESSION_KEY}', 'Content-type' : 'application/json' }
# When using Access Token authentication, use this instead:
# headers = { 'user_key': '{USER_KEY}', 'Access_token' : '{ACCESS_TOKEN}', 'Content-type' : 'application/json' }

r = requests.delete("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}", headers=headers)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text

    obj = json.loads(response)
    print(unicode(obj))
On success, the above command returns the following response:
{"result":"OK"}
Copy code
// Uses https://github.com/request/request
// npm install [-g] request

var request = require('request');

request({
    url: 'https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}',
    method: 'DELETE',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 200) {

        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
{"result":"OK"}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}")

# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(uri.request_uri)
request['Content-type'] = 'application/json'
request['user_key'] = '{USER_KEY}'
request['Session_key'] = '{SESSION_KEY}'

# Send the request
responseData = http.request(request)
if responseData.code == "200"
  response = responseData.body

  obj = JSON.parse(response)
  puts obj
else
  puts "Error.."
end
On success, the above command returns the following response:
{"result":"OK"}
Copy code
using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;

// We are using JSON.NET (http://www.newtonsoft.com/json)
using Newtonsoft.Json;

/*
 * The following code has been compiled and tested using the MONO
 * project.
 * 
 * To compile using MONO:
 * mcs -r:Newtonsoft.Json.dll example.cs
 */
namespace RestApplication
{
    class Program
    {        
        static void Main(string[] args)
        {
            using (var wb = new WebClient())
            {
                wb.Headers.Set(HttpRequestHeader.ContentType, "application/json");
                wb.Headers.Add("user_key", "{USER_KEY}");
                wb.Headers.Add("Session_key", "{SESSION_KEY}");

                wb.UploadValues("https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}", "DELETE", new NameValueCollection());

                dynamic obj = JsonConvert.DeserializeObject(response);
                Console.WriteLine(obj);
            }

        }
    }
}
On success, the above command returns the following response:
{"result":"OK"}
Copy code
#!/usr/bin/env perl

use warnings;
use strict;
use LWP::UserAgent;

# Install using Cpan: "cpan JSON"
use JSON;

my $ua = LWP::UserAgent->new;

my $server_endpoint = "https://app.gateway.smsend.it/API/v1.0/REST/sms/{order_id}";

my $req = HTTP::Request->new(DELETE => $server_endpoint);

$req->header('Content_type' => 'application/json');

# IMPORTANT: Not adding the ':' before 'user_key' and
# 'Session_key' will result in perl to automatically rewrite the
# headers as 'User-Key' and 'Session-Key', which is not supported
# by our API.
$req->header(':user_key' => $auth->[0],
             ':Session_key' => $auth->[1]);
my $resp = $ua->request($req);
if ($resp->is_success && $resp->code == 200) {
  $response = $resp->decoded_content;
  my $obj = from_json($response);

}
On success, the above command returns the following response:
{"result":"OK"}