Received SMS API

This API allows to query the received SMS messages on the owned SIMs.

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.

Get new received messages

Returns the list of received messages on the given sim_id since the last call of this method, or the beginning of time if it’s the first call. The list is limited to max. 100 entries.

This method requires activation by smSend. If you want to request the received SMS messages through this API, please contact us at helpdesk@smsend.it

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

For all SIMs, use:

https://app.gateway.smsend.it/API/v1.0/REST/newsrsmsmessage?limit={limit}

For one or more specific SIMs, use:

https://app.gateway.smsend.it/API/v1.0/REST/newsrsmsmessage/{id_sim}?limit={limit}

Parameters

Parameter Type Description Required Default
id_sim String(PhoneNumber) The phone number where you enabled the service of reception, in international format (+393471234567 or 00393471234567). If no SIM is specified, returns the new messages for all enabled SIMs. It is possible to specify more numbers, separated by comma No All SIMs
limit Int (max 100) The max. number of entries returned No 100

Returns

Code Description
200 The list of received SMS messages since the last call of this method.
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 -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/newsrsmsmessage' -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/newsrsmsmessage' -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",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}
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/newsrsmsmessage");
            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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/newsrsmsmessage');
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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}
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/newsrsmsmessage", 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",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}
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/newsrsmsmessage',
    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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/newsrsmsmessage")

# 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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}
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/newsrsmsmessage");

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

        }
    }
}
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}
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/newsrsmsmessage";

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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "31",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        },
        {
              "id_message": "29",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "sadasd",
              "sms_date": "20160503102231",
              "keyword": "qwe"
        }
    ]
}

Get the received SMS messages

Get the paginated list of received SMS messages.

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

For all SIMs, use:

https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory?from={fromdate}&to={todate}&pageNumber={page}&pageSize={size}

For one or more specific SIMs, use:

https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory/{id_sim}?from={fromdate}&to={todate}&pageNumber={page}&pageSize={size}

Parameters

Parameter Type Description Required Default
id_sim String(PhoneNumber) The phone number where you enabled the service of reception, in international format (+393471234567 or 00393471234567). If no SIM is specified, returns the new messages for all enabled SIMs. It is possible to specify more numbers, separated by comma No All SIMs
from Date(yyyyMMddHHmmss) Return results from the given date Yes -
to Date(yyyyMMddHHmmss) Return results up to the given date No now
timezone Timezone(IANA time zone) Optional timezone applied to from or to dates No -
pageNumber Int Return the given results page No 1
pageSize Int The number of results in a page No 10

Returns

Code Description
200 The paginated list of received SMS messages.
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 -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory?from={fromdate}' -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/srsmshistory?from={fromdate}' -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",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
        }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}
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/srsmshistory?from={fromdate}");
            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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
         }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory?from={fromdate}');
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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
        }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}
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/srsmshistory?from={fromdate}", 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",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
        }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}
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/srsmshistory?from={fromdate}',
    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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
        }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory?from={fromdate}")

# 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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
        }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}
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/srsmshistory?from={fromdate}");

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

        }
    }
}
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
        }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}
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/srsmshistory?from={fromdate}";

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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "2",
              "id_sim": "+393400000001",
              "sender": "+393356242290",
              "message": "abcde",
              "sms_date": "20160503102231",
              "keyword": ""
         }
    ],
    "pageNumber": 1,
    "pageSize": 10,
    "total": 1
}

Get the received SMS messages after a specified message.

Returns a list (limited to max. 100 entries) of SMS messages received after the given SMS message ID id_message, for the given SIM id_sim.

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory/{id_sim}/{id_message}?limit={limit}

Parameters

Parameter Type Description Required Default
id_sim String (Phone number) The phone number where you enabled the service of reception, in international format (+393471234567 or 00393471234567) Yes -
id_message Int The reference message ID Yes -
limit Int (max. 100) The max. number of entries in the returned list No 100

Returns

Code Description
201 The contact has been added and the HTTP Location Header returns its URL.
400 Campaign not active or not found, no email provided, group not owned or a generic error. 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 -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory/{id_sim}/{id_message}' -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/srsmshistory/{id_sim}/{id_message}' -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",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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/srsmshistory/{id_sim}/{id_message}");
            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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/srsmshistory/{id_sim}/{id_message}');
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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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/srsmshistory/{id_sim}/{id_message}", 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",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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/srsmshistory/{id_sim}/{id_message}',
    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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
Copy code
require 'net/http'
require 'uri'
require 'json'

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

# 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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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/srsmshistory/{id_sim}/{id_message}");

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

        }
    }
}
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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/srsmshistory/{id_sim}/{id_message}";

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:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "8",
              "id_sim": "+393400000000",
              "sender": "+393356242290",
              "message": "abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}

Get the MO received messages.

This feature is available only for French customers!. Returns a list (limited to max. 100 entries) of MO messages received for the give type which could be STOP or CONTACT or OTHER; type is a mandatory parameter, the other are optional.

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/mosmshistory?type=TYPE&from=FROMDATE&to=TODATE&pageNumber=PAGE&pageSize=SIZE

Parameters

Parameter Type Description Required Default
type String (“STOP” or “CONTACT” or “OTHER”) Type of the MO and could be one of STOP, CONTACT or OTHER Yes -
from Date(yyyyMMddHHmmss) Return results from the given date No -
to Date(yyyyMMddHHmmss) Return results up to the given date No -
timezone Timezone(IANA time zone) Optional timezone applied to from or to dates No -
pageNumber Int Return the given results page No 1
pageSize Int The number of results in a page No 10

Returns

Code Description
200 The list of received MO messages of type, with the specified time constraints (if any) and paging
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided, ot if the user is not French
404 [Not found] The User_key was not found
Copy code
# Session Key example
curl -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/mosmshistory' -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/mosmshistory' -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",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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/mosmshistory");
            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", "UserParam{access_token}");

            conn.setRequestMethod("GET");

            if (conn.getResponseCode() != 200) {
                // Print the possible error contained in body response
                String error = "";
                String output;
                BufferedReader errorbuffer = new BufferedReader(new InputStreamReader(conn.getErrorStream(), "UTF-8"));
                while ((output = errorbuffer.readLine()) != null) {
                    error += output;
                }
                System.out.println("Error! HTTP error code : " + conn.getResponseCode() +
                                   ", Body message : " + error);
                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",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/mosmshistory');
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: UserParam{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! http code: ' . $info['http_code'] . ', body message: ' . $response);
}
else {

    $obj = json_decode($response);
    print_r($obj);
}
?>
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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': 'UserParam{user_key}', 'Access_token' : 'UserParam{access_token}', 'Content-type' : 'application/json' }

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

if r.status_code != 200:
    print("Error! http code: " + str(r.status_code) + ", body message: " + str(r.content))
else:
    response = r.text

    obj = json.loads(response)
    print(unicode(obj))
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
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/mosmshistory',
    method: 'GET',
    headers: { 'user_key' : 'USER_KEY', 'Session_key' : 'SESSION_KEY' },

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

        }
        else {
            console.log('Error! http code: ' + responseMeta.statusCode + ', body message: ' + response)
        }
    }
});
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/mosmshistory")

# 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! http code: " + responseData.code + ", body message: " + responseData.body
end
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
Copy code
using System;
using System.IO;
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())
            {
                // Setting the encoding is required when sending UTF8 characters!
                wb.Encoding = System.Text.Encoding.UTF8;

                try {
                    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/mosmshistory");

                    dynamic obj = JsonConvert.DeserializeObject(response);
                    Console.WriteLine(obj);
                } catch (WebException ex) {
                    var statusCode = ((HttpWebResponse)ex.Response).StatusCode;
                    var errorResponse = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
                    Console.WriteLine("Error!, http code: " + statusCode + ", body message: ");
                    Console.WriteLine(errorResponse);
                }
            }
        }
    }
}
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}
Copy code
#!/usr/bin/env perl

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

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

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

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

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) {
  my $response = $resp->decoded_content;
  my $obj = from_json($response);

} else {
    my $error = $resp->decoded_content;
    my $code = $resp->code;
    print "Error!, http code: $code, body message: $error ";
}
On success, the above command returns the following response:
{
    "result": "OK",
    "srsmshistory": [
        {
              "id_message": "6",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP asd",
              "sms_date": "20160503102231",
              "keyword": ""
        },
        {
              "id_message": "7",
              "id_sim": "SMS STOP",
              "sender": "+393356242290",
              "message": "STOP abcdef",
              "sms_date": "20160503102231",
              "keyword": ""
        }
      ]
}