Contacts groups API

This section describes how groups of contacts are created, updated and deleted.

SMS messages and emails can be directly sent to 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.

Create a contacts group

Creates an empty group of contacts given a name and a description.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

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

Body Fields

Parameter Type Description Required Default
name String The name of the group Yes -
description String The description of the group Yes -

Returns

Code Description
201 An empty string, and the HTTP Location header containing the path to the newly created group
400 If the group name is invalid, or other errors, with a code error
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] If the requesting user does not exist.
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/group' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "name": "{NAME}", 
    "description": "{DESCRIPTION}"
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/group' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "name": "{NAME}", 
    "description": "{DESCRIPTION}"
}
'
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'
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/group");
            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 = "{" + 
              "    \"name\": \"{NAME}\", " + 
              "    \"description\": \"{DESCRIPTION}\"" + 
              "}";

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

            if (conn.getResponseCode() != 201) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            System.out.println("Success!");
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'
Copy code
<?php

$payload = '{' . 
  '    "name": "{NAME}", ' . 
  '    "description": "{DESCRIPTION}"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/group');
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 {
    echo('Success!');
}
?>
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'
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 = """{
    "name": "{NAME}", 
    "description": "{DESCRIPTION}"
}"""

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

if r.status_code != 201:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    print('Success!')
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'
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/group',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "name": "{NAME}", 
        "description": "{DESCRIPTION}"
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 201) {
            console.log('Success!');
        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/group")
payload =     {
        "name": "{NAME}", 
        "description": "{DESCRIPTION}"
    }

# 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
  puts "Success!"
else
  puts "Error.."
end
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'
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 = "{" + 
                  "    \"name\": \"{NAME}\", " + 
                  "    \"description\": \"{DESCRIPTION}\"" + 
                  "}";

                String response = wb.UploadString("https://app.gateway.smsend.it/API/v1.0/REST/group", "POST", payload)
                Console.WriteLine("Success!");
            }

        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'
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/group";

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 = {
    "name" => "{NAME}", 
    "description" => "{DESCRIPTION}"
};

$req->content(to_json($payload));
my $resp = $ua->request($req);
if ($resp->is_success && $resp->code == 201) {
  $response = $resp->decoded_content;
  print "Success!";

}
On success, the above command returns the following response:
# The HTTP location header that points to the created group:
'Location': '/group/{group_id}'

Modify an existing contacts group

Updates a given contacts group

HTTP Headers

user_key / Session_key

HTTP Method

PUT

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}

Body Fields

Parameter Type Description Required Default
name String The name of the group Yes -
description String The description of the group Yes -

Returns

Code Description
200 An empty string, and the HTTP Location header containing the path to the updated group
400 If the given group_id is invalid, if the address book is locked, if the group name is invalid, or other errors, with a code error
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] If the requesting user does not exist.
Copy code
# Session Key example
curl -XPUT 'https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "name": "{NAME}", 
    "description": "{DESCRIPTION}"
}
'

# Access token example
curl -XPUT 'https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "name": "{NAME}", 
    "description": "{DESCRIPTION}"
}
'
On success, the above command returns the following response:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'
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/group/{group_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("PUT");

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

            String payload = "{" + 
              "    \"name\": \"{NAME}\", " + 
              "    \"description\": \"{DESCRIPTION}\"" + 
              "}";

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

            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            System.out.println("Success!");
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'
Copy code
<?php

$payload = '{' . 
  '    "name": "{NAME}", ' . 
  '    "description": "{DESCRIPTION}"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/group/{group_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_PUT, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if ($info['http_code'] != 200) {
    echo('Error!');
}
else {
    echo('Success!');
}
?>
On success, the above command returns the following response:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'
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 = """{
    "name": "{NAME}", 
    "description": "{DESCRIPTION}"
}"""

r = requests.put("https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}", headers=headers, data=payload)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    print('Success!')
On success, the above command returns the following response:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'
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/group/{group_id}',
    method: 'PUT',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "name": "{NAME}", 
        "description": "{DESCRIPTION}"
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 200) {
            console.log('Success!');
        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}")
payload =     {
        "name": "{NAME}", 
        "description": "{DESCRIPTION}"
    }

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

request = Net::HTTP::Put.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 == "200"
  response = responseData.body
  puts "Success!"
else
  puts "Error.."
end
On success, the above command returns the following response:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'
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 = "{" + 
                  "    \"name\": \"{NAME}\", " + 
                  "    \"description\": \"{DESCRIPTION}\"" + 
                  "}";

                String response = wb.UploadString("https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}", "PUT", payload)
                Console.WriteLine("Success!");
            }

        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'
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/group/{group_id}";

my $req = HTTP::Request->new(PUT => $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 = {
    "name" => "{NAME}", 
    "description" => "{DESCRIPTION}"
};

$req->content(to_json($payload));
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:
# The HTTP location header that points to the modified group:
'Location': '/group/{group_id}'

Delete a contacts group

Deletes the contacts group identified by the given ID.

HTTP Headers

user_key / Session_key

HTTP Method

DELETE

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}?deletecontacts={del}

Parameters

Parameter Type Description Required Default
group_id Int The group ID to be deleted Yes -
deletecontacts String “true” or “false” If “true”, also deletes all contacts in the group No “false”

Returns

Code Description
200 An empty string
400 If the given group_id is invalid, if the address book is locked, if the group name is invalid, or other errors, with a code error
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 -XDELETE 'https://app.gateway.smsend.it/API/v1.0/REST/group/{groupid}' -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/group/{groupid}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' 
On success, the above command returns the following response:
""
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/group/{groupid}");
            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());
            }
            System.out.println("Success!");
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
""
Copy code
<?php

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

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    print('Success!')
On success, the above command returns the following response:
""
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/group/{groupid}',
    method: 'DELETE',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

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

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

# 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
  puts "Success!"
else
  puts "Error.."
end
On success, the above command returns the following response:
""
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/group/{groupid}", "DELETE", new NameValueCollection());
                Console.WriteLine("Success!");
            }

        }
    }
}
On success, the above command returns the following response:
""
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/group/{groupid}";

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

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

List contacts groups

Returns the list of existing contacts groups, paginated.

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/groups?pageNumber={page}&pageSize={size}

Parameters

Parameter Type Description Required Default
pageNumber int The page number No 1
pageSize int The page size No 5

Returns

Code Description
200 The paginated list of contacts groups, as a Json Object
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/groups' -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/groups' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' 
On success, the above command returns the following response:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}
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/groups");
            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:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/groups');
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:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}
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/groups", 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:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}
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/groups',
    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:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}
Copy code
require 'net/http'
require 'uri'
require 'json'

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

# 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:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}
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/groups");

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

        }
    }
}
On success, the above command returns the following response:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}
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/groups";

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:
{
 "groups":[                         "// The list of groups"
  {
    "id_group": (string),           "// The ID of a group in the list"
    "group_name": (string),         "// The group name"
    "group_description": (string)   "// The group description"
  },
  {...}                             "// Other groups in the list (omitted..)"
 ],
 "pageNumber": (int),               "// Paging: The page number"
 "pageSize": (int),                 "// Paging: The page size"
 "Total": (int)                     "// Paging: The total number of groups"
}

Add a contact to a group

Adds the specified contact in the specified contacts group.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}/contact/{contact_id}

Parameters

Parameter Type Description Required Default
group_id Int The Contacts Group ID Yes -
contact_id Int The Contact ID Yes -

Returns

Code Description
200 An empty string, and the HTTP Location header containing the URL of the contact
400 If contact_id is invalid, if the addressbook is locked or other. 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/group/{group_id}/contact/{contact_id}' -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/group/{group_id}/contact/{contact_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:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/{group_id}/contact/{contact_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("POST");

            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : "
                                           + conn.getResponseCode());
            }
            System.out.println("Success!");
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}/contact/{contact_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_POST, 1);

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

if ($info['http_code'] != 200) {
    echo('Error!');
}
else {
    echo('Success!');
}
?>
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/{group_id}/contact/{contact_id}", headers=headers)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    print('Success!')
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/{group_id}/contact/{contact_id}',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 200) {
            console.log('Success!');
        }
        else {
            console.log('An error occurred..');
        }
    }
});
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}/contact/{contact_id}")

# 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 "Success!"
else
  puts "Error.."
end
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/{group_id}/contact/{contact_id}", "POST", null)
                Console.WriteLine("Success!");
            }

        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/{group_id}/contact/{contact_id}";

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:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'

Remove a contact from a group

Removes the specified contact from the specified contacts group.

HTTP Headers

user_key / Session_key

HTTP Method

DELETE

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/group/{group_id}/contact/{contact_id}

Parameters

Parameter Type Description Required Default
group_id Int The Contacts Group ID Yes -
contact_id Int The Contact ID Yes -

Returns

Code Description
200 An empty string, and the HTTP Location header containing the URL of the contact
400 If contact_id is invalid, if the addressbook is locked or other. 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 -XDELETE 'https://app.gateway.smsend.it/API/v1.0/REST/group/GROUP_ID/contact/CONTACT_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/group/GROUP_ID/contact/CONTACT_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:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/GROUP_ID/contact/CONTACT_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", "UserParam{access_token}");

            conn.setRequestMethod("DELETE");

            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());
            }
            System.out.println("Success!");
            conn.disconnect();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/group/GROUP_ID/contact/CONTACT_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: UserParam{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! http code: ' . $info['http_code'] . ', body message: ' . $response);
}
else {
    echo('Success!');
}
?>
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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.delete("https://app.gateway.smsend.it/API/v1.0/REST/group/GROUP_ID/contact/CONTACT_ID", headers=headers)

if r.status_code != 200:
    print("Error! http code: " + str(r.status_code) + ", body message: " + str(r.content))
else:
    print('Success!')
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/GROUP_ID/contact/CONTACT_ID',
    method: 'DELETE',
    headers: { 'user_key' : 'USER_KEY', 'Session_key' : 'SESSION_KEY' },

    callback: function (error, responseMeta, response) {
        if (!error &↦ responseMeta.statusCode == 200) {
            console.log('Success!');
        }
        else {
            console.log('Error! http code: ' + responseMeta.statusCode + ', body message: ' + response)
        }
    }
});
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/group/GROUP_ID/contact/CONTACT_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
  puts "Success!"
else
  puts "Error! http code: " + responseData.code + ", body message: " + responseData.body
end
On success, the above command returns the following response:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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");

                    wb.UploadValues("https://app.gateway.smsend.it/API/v1.0/REST/group/GROUP_ID/contact/CONTACT_ID", "DELETE", new NameValueCollection());
                    Console.WriteLine("Success!");
                } 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:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
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/group/GROUP_ID/contact/CONTACT_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) {
  my $response = $resp->decoded_content;
  print "Success!";

} 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:
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'