User API

The following are utility functions regarding the Authenticated User

E.g. the user status, password reset, dashboard access etc

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.

Dashboard

API used to retrieve the dashboard URL of the authenticated user

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

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

Returns

Code Description
200 Returns the URL for the user’s dashboard
404 [Unauthorized] User_key, Token or Session_key are invalid or not provided
400 Other errors, details are in the body
Copy code
# Session Key example
curl -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/dashboard' -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/dashboard' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' 
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB
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/dashboard");
            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;
            }
            System.out.println(response);
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/dashboard');
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 {
    echo($response);
}
?>
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB
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/dashboard", headers=headers)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text
    print(response)
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB
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/dashboard',
    method: 'GET',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 200) {
            console.log(response);
        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB
Copy code
require 'net/http'
require 'uri'
require 'json'

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

# 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
  puts response
else
  puts "Error.."
end
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB
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/dashboard");
                Console.WriteLine(response);
            }

        }
    }
}
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB
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/dashboard";

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;
  print "Success!";

}
On success, the above command returns the following response:
https://app.gateway.smsend.it/API/v1.0/REST//s/user/external-auth?k=07366A25DF70038A22B9D284AB13E856BD95C6227&action=FC07AD201AE372F378&action-params=7010AB

Verify session

Checks whether the user session is still active and valid (without renewal).

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

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

Returns

Code Description
200 String “true” if the session is valid, “false” otherwise.
401 [Unauthorized] User_key, Token or Session_key are invalid or not provide
400 Other errors, details are in the body
Copy code
# Session Key example
curl -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/checksession' -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/checksession' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}'
On success, the above command returns the following response:
"true" or "false"
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/checksession");
            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;
            }
            System.out.println("Is session valid: " + ("true".equals(response)));
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
"true" or "false"
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/checksession');
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 {
    echo('Is session valid: ' . ($response === "true"));
}
?>
On success, the above command returns the following response:
"true" or "false"
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/checksession", headers=headers)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text
    print("Is session valid: " + str(response == "true"))
On success, the above command returns the following response:
"true" or "false"
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/checksession',
    method: 'GET',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 200) {
            console.log('Is session valid: ' + (response == "true"));
        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
"true" or "false"
Copy code
require 'net/http'
require 'uri'
require 'json'

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

# 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
  puts "Is session valid " + response
else
  puts "Error.."
end
On success, the above command returns the following response:
"true" or "false"
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/checksession");
                Console.WriteLine("Is session valid: " + response);
            }

        }
    }
}
On success, the above command returns the following response:
"true" or "false"
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/checksession";

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;
  print "Success!";

}
On success, the above command returns the following response:
"true" or "false"

Reset password

Changes the authenticated user’s password

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/pwdreset?password={PWD}

Parameters

Parameter Type Description Required Default
password String The new user password Yes -

Returns

Code Description
200 String “true” on success, “false” otherwise
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
400 [Not found] User key does not exist
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/pwdreset?password={newpwd}' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' 

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/pwdreset?password={newpwd}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}'
On success, the above command returns the following response:
"true" or "false"
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/pwdreset?password={newpwd}");
            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");

            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;
            }
            System.out.println("Password changed: " + ("true".equals(response)));
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
"true" or "false"
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/pwdreset?password={newpwd}');
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);

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

if ($info['http_code'] != 200) {
    echo('Error!');
}
else {
    echo('Password changed: ' . ($response === "true"));
}
?>
On success, the above command returns the following response:
"true" or "false"
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.post("https://app.gateway.smsend.it/API/v1.0/REST/pwdreset?password={newpwd}", headers=headers)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    response = r.text
    print("Password changed: " + str(response == "true"))
On success, the above command returns the following response:
"true" or "false"
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/pwdreset?password={newpwd}',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 200) {
            console.log('Password changed: ' + (response == "true"));
        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
"true" or "false"
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/pwdreset?password={newpwd}")

# 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}'

# Send the request
responseData = http.request(request)
if responseData.code == "200"
  response = responseData.body
  puts "Password changed " + response
else
  puts "Error.."
end
On success, the above command returns the following response:
"true" or "false"
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.UploadString("https://app.gateway.smsend.it/API/v1.0/REST/pwdreset?password={newpwd}", "POST", null)
                Console.WriteLine("Password changed: " + response);
            }

        }
    }
}
On success, the above command returns the following response:
"true" or "false"
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/pwdreset?password={newpwd}";

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 $resp = $ua->request($req);
if ($resp->is_success && $resp->code == 200) {
  $response = $resp->decoded_content;
  print "Success!";

}
On success, the above command returns the following response:
"true" or "false"

User status

Used to retrieve the services status of the user identified by the id.

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/status?getMoney={value}

Parameters

Parameter Type Description Required Default
getMoney String “true” or “false” Add user current money to response No “false”
typeAliases String “true” or “false” Returns the actual names for the message types instead of the internal ID. This is not done by default only because of retrocompatibility issues. No, but suggested “false”

Returns

Code Description
200 A Json object representing the user status
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] Credentials are incorrect
Copy code
# Session Key example
curl -XGET 'https://app.gateway.smsend.it/API/v1.0/REST/status' -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/status' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}'
On success, the above command returns the following response:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}
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/status");
            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:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/status');
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:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}
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/status", 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:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}
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/status',
    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:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}
Copy code
require 'net/http'
require 'uri'
require 'json'

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

# 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:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}
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/status");

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

        }
    }
}
On success, the above command returns the following response:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}
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/status";

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:
{
    "money": null, 
    "sms": [
        {
            "type": "SI", 
            "quantity": 16079
        }, 
        {
            "type": "GS", 
            "quantity": 11815
        }, 
        {
            "type": "GP", 
            "quantity": 10407
        }, 
        {
            "type": "EE", 
            "quantity": 10387
        }
    ], 
    "email": {
        "bandwidth": 2000.0, 
        "purchased": "2015-01-16", 
        "billing": "EMAILPERHOUR", 
        "expiry": "2016-01-17"
    }, 
    "landing": null
}