Email Campaign API

This API exposes methods for creating and managing Email campaigns.

Emails can be sent to a list, that is used for contacts subscription.

A list allows contacts to subscribe to it, and also defines some basic email sending settings, such as: - Name of the list - Language - Sender’s name and email - Reply-to email - Customized Opt-in email

An Email campaign is a sending of an email to a certain list.

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 new list

Create a new sending list.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

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

Body Fields

Parameter Type Description Required Default
title String The list name Yes -
id_language String (e.g. “ita”) The list default language Yes -
email_sender a valid email The sender’s email address Yes -
reply_to a valid email The email to be used for the ‘reply_to’ email field Yes -
company_name String The company name Yes -
company_address String The company address Yes -
company_url String The company website URL Yes -
company_phone String The company phone number Yes -
company_fax String The company FAX number Yes -

Returns

Code Description
201 List created, The HTTP location header that points to the created list
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The User_key was not found
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}
'
On success, the above command returns the following response:
# The HTTP location header that points to the created list:
'Location': '/list/{list_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/list");
            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 = "{" + 
              "    \"title\": \"MyNewList\", " + 
              "    \"id_language\": \"ita\", " + 
              "    \"email_sender\": \"ema@il.com\", " + 
              "    \"reply_to\": \"ema@il.com\", " + 
              "    \"company_name\": \"MyCompany\", " + 
              "    \"company_address\": \"My Company Address\", " + 
              "    \"company_url\": \"www.mycompany.com\", " + 
              "    \"company_phone\": \"+34123456789\", " + 
              "    \"company_fax\": \"+341234567810\"" + 
              "}";

            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 list:
'Location': '/list/{list_id}'
Copy code
<?php

$payload = '{' . 
  '    "title": "MyNewList", ' . 
  '    "id_language": "ita", ' . 
  '    "email_sender": "ema@il.com", ' . 
  '    "reply_to": "ema@il.com", ' . 
  '    "company_name": "MyCompany", ' . 
  '    "company_address": "My Company Address", ' . 
  '    "company_url": "www.mycompany.com", ' . 
  '    "company_phone": "+34123456789", ' . 
  '    "company_fax": "+341234567810"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/list');
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 list:
'Location': '/list/{list_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 = """{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}"""

r = requests.post("https://app.gateway.smsend.it/API/v1.0/REST/list", 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 list:
'Location': '/list/{list_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/list',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "title": "MyNewList", 
        "id_language": "ita", 
        "email_sender": "ema@il.com", 
        "reply_to": "ema@il.com", 
        "company_name": "MyCompany", 
        "company_address": "My Company Address", 
        "company_url": "www.mycompany.com", 
        "company_phone": "+34123456789", 
        "company_fax": "+341234567810"
    },

    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 list:
'Location': '/list/{list_id}'
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/list")
payload =     {
        "title": "MyNewList", 
        "id_language": "ita", 
        "email_sender": "ema@il.com", 
        "reply_to": "ema@il.com", 
        "company_name": "MyCompany", 
        "company_address": "My Company Address", 
        "company_url": "www.mycompany.com", 
        "company_phone": "+34123456789", 
        "company_fax": "+341234567810"
    }

# 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 list:
'Location': '/list/{list_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 = "{" + 
                  "    \"title\": \"MyNewList\", " + 
                  "    \"id_language\": \"ita\", " + 
                  "    \"email_sender\": \"ema@il.com\", " + 
                  "    \"reply_to\": \"ema@il.com\", " + 
                  "    \"company_name\": \"MyCompany\", " + 
                  "    \"company_address\": \"My Company Address\", " + 
                  "    \"company_url\": \"www.mycompany.com\", " + 
                  "    \"company_phone\": \"+34123456789\", " + 
                  "    \"company_fax\": \"+341234567810\"" + 
                  "}";

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

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

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 = {
    "title" => "MyNewList", 
    "id_language" => "ita", 
    "email_sender" => "ema@il.com", 
    "reply_to" => "ema@il.com", 
    "company_name" => "MyCompany", 
    "company_address" => "My Company Address", 
    "company_url" => "www.mycompany.com", 
    "company_phone" => "+34123456789", 
    "company_fax" => "+341234567810"
};

$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 list:
'Location': '/list/{list_id}'

Modify a list

Updates a sending list.

HTTP Headers

user_key / Session_key

HTTP Method

PUT

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}

Parameters

Parameter Type Description Required Default
list_id Int The ID of the list to modify Yes -

Body Fields

Parameter Type Description Required Default
title String The list name No -
id_language String (e.g. “ita”) The list default language No -
email_sender a valid email The sender’s email address No -
reply_to a valid email The email to be used for the ‘reply_to’ email field No -
company_name String The company name No -
company_address String The company address No -
company_url String The company website URL No -
company_phone String The company phone number No -
company_fax String The company FAX number No -
status Int The list status (0 = Active, 1 = Archived, 2 = To Be Activated) No -

Returns

Code Description
204 List updated, The HTTP location header that points to the created list
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 -XPUT 'https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}
'

# Access token example
curl -XPUT 'https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}
'
On success, the above command returns the following response:
# The HTTP location header that points to the updated list:
'Location': '/list/{list_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/list/{list_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 = "{" + 
              "    \"title\": \"MyNewList\", " + 
              "    \"id_language\": \"ita\", " + 
              "    \"email_sender\": \"ema@il.com\", " + 
              "    \"reply_to\": \"ema@il.com\", " + 
              "    \"company_name\": \"MyCompany\", " + 
              "    \"company_address\": \"My Company Address\", " + 
              "    \"company_url\": \"www.mycompany.com\", " + 
              "    \"company_phone\": \"+34123456789\", " + 
              "    \"company_fax\": \"+341234567810\"" + 
              "}";

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

            if (conn.getResponseCode() != 204) {
                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 updated list:
'Location': '/list/{list_id}'
Copy code
<?php

$payload = '{' . 
  '    "title": "MyNewList", ' . 
  '    "id_language": "ita", ' . 
  '    "email_sender": "ema@il.com", ' . 
  '    "reply_to": "ema@il.com", ' . 
  '    "company_name": "MyCompany", ' . 
  '    "company_address": "My Company Address", ' . 
  '    "company_url": "www.mycompany.com", ' . 
  '    "company_phone": "+34123456789", ' . 
  '    "company_fax": "+341234567810"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/list/{list_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'] != 204) {
    echo('Error!');
}
else {
    echo('Success!');
}
?>
On success, the above command returns the following response:
# The HTTP location header that points to the updated list:
'Location': '/list/{list_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 = """{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}"""

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

if r.status_code != 204:
    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 updated list:
'Location': '/list/{list_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/list/{list_id}',
    method: 'PUT',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "title": "MyNewList", 
        "id_language": "ita", 
        "email_sender": "ema@il.com", 
        "reply_to": "ema@il.com", 
        "company_name": "MyCompany", 
        "company_address": "My Company Address", 
        "company_url": "www.mycompany.com", 
        "company_phone": "+34123456789", 
        "company_fax": "+341234567810"
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 204) {
            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 updated list:
'Location': '/list/{list_id}'
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}")
payload =     {
        "title": "MyNewList", 
        "id_language": "ita", 
        "email_sender": "ema@il.com", 
        "reply_to": "ema@il.com", 
        "company_name": "MyCompany", 
        "company_address": "My Company Address", 
        "company_url": "www.mycompany.com", 
        "company_phone": "+34123456789", 
        "company_fax": "+341234567810"
    }

# 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 == "204"
  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 updated list:
'Location': '/list/{list_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 = "{" + 
                  "    \"title\": \"MyNewList\", " + 
                  "    \"id_language\": \"ita\", " + 
                  "    \"email_sender\": \"ema@il.com\", " + 
                  "    \"reply_to\": \"ema@il.com\", " + 
                  "    \"company_name\": \"MyCompany\", " + 
                  "    \"company_address\": \"My Company Address\", " + 
                  "    \"company_url\": \"www.mycompany.com\", " + 
                  "    \"company_phone\": \"+34123456789\", " + 
                  "    \"company_fax\": \"+341234567810\"" + 
                  "}";

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

        }
    }
}
On success, the above command returns the following response:
# The HTTP location header that points to the updated list:
'Location': '/list/{list_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/list/{list_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 = {
    "title" => "MyNewList", 
    "id_language" => "ita", 
    "email_sender" => "ema@il.com", 
    "reply_to" => "ema@il.com", 
    "company_name" => "MyCompany", 
    "company_address" => "My Company Address", 
    "company_url" => "www.mycompany.com", 
    "company_phone" => "+34123456789", 
    "company_fax" => "+341234567810"
};

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

}
On success, the above command returns the following response:
# The HTTP location header that points to the updated list:
'Location': '/list/{list_id}'

Get list of campaigns by statuses

Get list of campaigns by statuses. If statuses is not specified by default return only ACTIVE campaign.

HTTP Headers

user_key / Session_key

HTTP Method

GET

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/list?statuses=UserParam(statuses)

Parameters

Parameter Type Description Required Default
statuses String List of campaign statuses separated by comma (ACTIVE, ARCHIVED, TO_ACTIVATE) No ACTIVE

Returns

Code Description
204 List of campaign
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
Copy code
# Session Key example
curl -XPUT 'https://app.gateway.smsend.it/API/v1.0/REST/list/LIST_ID' -H 'Content-Type: application/json' \
-H 'user_key: USER_KEY' -H 'Session_key: SESSION_KEY' -d'
{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}
'

# Access token example
curl -XPUT 'https://app.gateway.smsend.it/API/v1.0/REST/list/LIST_ID' -H 'Content-Type: application/json' \
 -H 'user_key: USER_KEY' -H 'Access_token: ACCESS_TOKEN' -d'
{
    "title": "MyNewList", 
    "id_language": "ita", 
    "email_sender": "ema@il.com", 
    "reply_to": "ema@il.com", 
    "company_name": "MyCompany", 
    "company_address": "My Company Address", 
    "company_url": "www.mycompany.com", 
    "company_phone": "+34123456789", 
    "company_fax": "+341234567810"
}
'
On success, the above command returns the following response:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]
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/list/LIST_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("PUT");

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

            String payload = "{" + 
              "    \"title\": \"MyNewList\", " + 
              "    \"id_language\": \"ita\", " + 
              "    \"email_sender\": \"ema@il.com\", " + 
              "    \"reply_to\": \"ema@il.com\", " + 
              "    \"company_name\": \"MyCompany\", " + 
              "    \"company_address\": \"My Company Address\", " + 
              "    \"company_url\": \"www.mycompany.com\", " + 
              "    \"company_phone\": \"+34123456789\", " + 
              "    \"company_fax\": \"+341234567810\"" + 
              "}";

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

            if (conn.getResponseCode() != 204) {
                // 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:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]
Copy code
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/list');
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:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]
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/list", 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:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]
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/list',
    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:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]
Copy code
require 'net/http'
require 'uri'
require 'json'

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

# 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:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]
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/list");

                    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:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]
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/list";

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:
[{
    "id_campaign": 10,
    "title": "MyList1",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:30:56"
},
{
    "id_campaign": 11,
    "title": "MyList2",
    "id_language": "ita",
    "email_sender": "ema@il.com",
    "reply_to": "ema@il.com",
    "company_name": "MyCompany",
    "company_address": "My Company Address",
    "company_url": "www.mycompany.com",
    "company_phone": "+34123456789",
    "company_fax": "+341234567810",
    "status": "ACTIVE",
    "create_date": "2018-02-27 15:31:06"
}]

Add a contacts group to a list of distribution

Add all contacts of the given group to the given list of distribution.

Emails can be only sent to contacts that belong to a distribution list.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/group/{group_id}?sendoptin={send}

Parameters

Parameter Type Description Required Default
list_id Int The list ID Yes -
group_id String The group ID Yes -
sendoptin Bool Send the Opt-in email to the group’s contacts No false

Returns

Code Description
200 The group has been added to the list
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The User_key was not found
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/group/{group_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/list/{list_id}/group/{group_id}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' 
							
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/list/{list_id}/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("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();
        }
    }
}
Copy code
<?php

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

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

if ($info['http_code'] != 200) {
    echo('Error!');
}
else {
    echo('Success!');
}
?>
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/list/{list_id}/group/{group_id}", headers=headers)

if r.status_code != 200:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    print('Success!')
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/list/{list_id}/group/{group_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..');
        }
    }
});
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/group/{group_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
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/list/{list_id}/group/{group_id}", "POST", null)
                Console.WriteLine("Success!");
            }

        }
    }
}
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/list/{list_id}/group/{group_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!";

}

Create a new email draft

Creates a new email draft. Every email draft must be associated to a distribution list.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/issue

Parameters

Parameter Type Description Required Default
list_id Int The list where to send the emails Yes -

Body Fields

Parameter Type Description Required Default
title String The issue title Yes -
subject String The subject for the issue Yes -
share_social Bool Adds the social share buttons Yes -
web_analytics String The WebAnalytics tracing code No -
text_content String The Email text body Yes -
html_content String The Email HTML body Yes -
attachments List(Attachment) The list of attachments (can be empty) Yes -
Attachment.file_name String The file name of the attachment Yes -
Attachment.file_content_base64 String The base64-encoded attachment Yes -

Returns

Code Description
201 Issue created, the HTTP Location header points to the created issue
400 Other errors, details are in the body
401 [Unauthorized] User_key, Token or Session_key are invalid or not provided
404 [Not found] The User_key was not found
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/issue' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "title": "New title", 
    "subject": "Hello world!", 
    "share_social": false, 
    "web_analytics": "www.google.it?a=b", 
    "text_content": "Test email", 
    "html_content": "<body><table><tr><td>Hello world!</td></tr><table></body>", 
    "attachments": [
        {
            "file_name": "attach1.pdf", 
            "file_content_base64": "ABAAC2"
        }, 
        {
            "file_name": "attach2.pdf", 
            "file_content_base64": "PBAAC2"
        }
    ]
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/issue' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "title": "New title", 
    "subject": "Hello world!", 
    "share_social": false, 
    "web_analytics": "www.google.it?a=b", 
    "text_content": "Test email", 
    "html_content": "<body><table><tr><td>Hello world!</td></tr><table></body>", 
    "attachments": [
        {
            "file_name": "attach1.pdf", 
            "file_content_base64": "ABAAC2"
        }, 
        {
            "file_name": "attach2.pdf", 
            "file_content_base64": "PBAAC2"
        }
    ]
}
'
# The HTTP location header that points to the created issue:
'Location': '/issue/{issue_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/list/{list_id}/issue");
            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 = "{" + 
              "    \"title\": \"New title\", " + 
              "    \"subject\": \"Hello world!\", " + 
              "    \"share_social\": false, " + 
              "    \"web_analytics\": \"www.google.it?a=b\", " + 
              "    \"text_content\": \"Test email\", " + 
              "    \"html_content\": \"<body><table><tr><td>Hello world!</td></tr><table></body>\", " + 
              "    \"attachments\": [" + 
              "        {" + 
              "            \"file_name\": \"attach1.pdf\", " + 
              "            \"file_content_base64\": \"ABAAC2\"" + 
              "        }, " + 
              "        {" + 
              "            \"file_name\": \"attach2.pdf\", " + 
              "            \"file_content_base64\": \"PBAAC2\"" + 
              "        }" + 
              "    ]" + 
              "}";

            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();
        }
    }
}
# The HTTP location header that points to the created issue:
'Location': '/issue/{issue_id}'
Copy code
<?php

$payload = '{' . 
  '    "title": "New title", ' . 
  '    "subject": "Hello world!", ' . 
  '    "share_social": false, ' . 
  '    "web_analytics": "www.google.it?a=b", ' . 
  '    "text_content": "Test email", ' . 
  '    "html_content": "<body><table><tr><td>Hello world!</td></tr><table></body>", ' . 
  '    "attachments": [' . 
  '        {' . 
  '            "file_name": "attach1.pdf", ' . 
  '            "file_content_base64": "ABAAC2"' . 
  '        }, ' . 
  '        {' . 
  '            "file_name": "attach2.pdf", ' . 
  '            "file_content_base64": "PBAAC2"' . 
  '        }' . 
  '    ]' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/issue');
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!');
}
?>
# The HTTP location header that points to the created issue:
'Location': '/issue/{issue_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 = """{
    "title": "New title", 
    "subject": "Hello world!", 
    "share_social": false, 
    "web_analytics": "www.google.it?a=b", 
    "text_content": "Test email", 
    "html_content": "<body><table><tr><td>Hello world!</td></tr><table></body>", 
    "attachments": [
        {
            "file_name": "attach1.pdf", 
            "file_content_base64": "ABAAC2"
        }, 
        {
            "file_name": "attach2.pdf", 
            "file_content_base64": "PBAAC2"
        }
    ]
}"""

r = requests.post("https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/issue", headers=headers, data=payload)

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

    json: true,
    body:     {
        "title": "New title", 
        "subject": "Hello world!", 
        "share_social": false, 
        "web_analytics": "www.google.it?a=b", 
        "text_content": "Test email", 
        "html_content": "<body><table><tr><td>Hello world!</td></tr><table></body>", 
        "attachments": [
            {
                "file_name": "attach1.pdf", 
                "file_content_base64": "ABAAC2"
            }, 
            {
                "file_name": "attach2.pdf", 
                "file_content_base64": "PBAAC2"
            }
        ]
    },

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

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/list/{list_id}/issue")
payload =     {
        "title": "New title", 
        "subject": "Hello world!", 
        "share_social": false, 
        "web_analytics": "www.google.it?a=b", 
        "text_content": "Test email", 
        "html_content": "<body><table><tr><td>Hello world!</td></tr><table></body>", 
        "attachments": [
            {
                "file_name": "attach1.pdf", 
                "file_content_base64": "ABAAC2"
            }, 
            {
                "file_name": "attach2.pdf", 
                "file_content_base64": "PBAAC2"
            }
        ]
    }

# 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
# The HTTP location header that points to the created issue:
'Location': '/issue/{issue_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 = "{" + 
                  "    \"title\": \"New title\", " + 
                  "    \"subject\": \"Hello world!\", " + 
                  "    \"share_social\": false, " + 
                  "    \"web_analytics\": \"www.google.it?a=b\", " + 
                  "    \"text_content\": \"Test email\", " + 
                  "    \"html_content\": \"<body><table><tr><td>Hello world!</td></tr><table></body>\", " + 
                  "    \"attachments\": [" + 
                  "        {" + 
                  "            \"file_name\": \"attach1.pdf\", " + 
                  "            \"file_content_base64\": \"ABAAC2\"" + 
                  "        }, " + 
                  "        {" + 
                  "            \"file_name\": \"attach2.pdf\", " + 
                  "            \"file_content_base64\": \"PBAAC2\"" + 
                  "        }" + 
                  "    ]" + 
                  "}";

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

        }
    }
}
# The HTTP location header that points to the created issue:
'Location': '/issue/{issue_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/list/{list_id}/issue";

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 = {
    "title" => "New title", 
    "subject" => "Hello world!", 
    "share_social" => false, 
    "web_analytics" => "www.google.it?a=b", 
    "text_content" => "Test email", 
    "html_content" => "<body><table><tr><td>Hello world!</td></tr><table></body>", 
    "attachments" => [
        {
            "file_name" => "attach1.pdf", 
            "file_content_base64" => "ABAAC2"
        }, 
        {
            "file_name" => "attach2.pdf", 
            "file_content_base64" => "PBAAC2"
        }
    ]
};

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

}
# The HTTP location header that points to the created issue:
'Location': '/issue/{issue_id}'

Create new issue using a specified template

Creates a new issue starting from the specified template.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/template/{template}

Parameters

Parameter Type Description Required Default
campaignId Int The list where to send the emails Yes -
template Int The template, previously created, to do the send Yes -

Body Fields

Parameter Type Description Required Default
name String The name/title of the issue Yes -
subject String The subject used in the issue Yes -

Returns

200 Successful request
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
500 The issue can’t be created
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/template/{template}' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "name": "New title", 
    "subject": "Hello World!!"
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/template/{template}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "name": "New title", 
    "subject": "Hello World!!"
}
'
# 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/list/{campaignId}/issue/template/{template}");
            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\": \"New title\", " + 
              "    \"subject\": \"Hello World!!\"" + 
              "}";

            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();
        }
    }
}
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'
Copy code
<?php

$payload = '{' . 
  '    "name": "New title", ' . 
  '    "subject": "Hello World!!"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/template/{template}');
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!');
}
?>
# 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' }
payload = """{
    "name": "New title", 
    "subject": "Hello World!!"
}"""

r = requests.post("https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/template/{template}", headers=headers, data=payload)

if r.status_code != 201:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    print('Success!')
# 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/list/{campaignId}/issue/template/{template}',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "name": "New title", 
        "subject": "Hello World!!"
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 201) {
            console.log('Success!');
        }
        else {
            console.log('An error occurred..');
        }
    }
});
# 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/list/{campaignId}/issue/template/{template}")
payload =     {
        "name": "New title", 
        "subject": "Hello World!!"
    }

# 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
# 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 payload = "{" + 
                  "    \"name\": \"New title\", " + 
                  "    \"subject\": \"Hello World!!\"" + 
                  "}";

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

        }
    }
}
# 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/list/{campaignId}/issue/template/{template}";

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" => "New title", 
    "subject" => "Hello World!!"
};

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

}
# The HTTP location header that points to the contact:
'Location': '/contact/{contact_id}'

Send an issue to preloaded contacts

Schedule an issue to be sent to a specified list of contacts Ids at a given time.

HTTP Headers

user_key / Session_key

HTTP Method

POST

HTTP Request

https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/{idIssue}

Parameters

Parameter Type Description Required Default
campaignId Int The campaign where to send the emails Yes -
idIssue Int The mailing to send Yes -

Body Fields

Parameter Type Description Required Default
contactIds String[] The list of contact Ids of the recipients Yes -
scheduleTime String When send the mailing in format yyyy-MM-dd hh:mm:ss Yes -

Returns

Code Description
200 Successful request
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
500 The issue can’t be sent or the contacts Ids array is empty
Copy code
# Session Key example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/{idIssue}' -H 'Content-Type: application/json' \
-H 'user_key: {USER_KEY}' -H 'Session_key: {SESSION_KEY}' -d'
{
    "contactIds": [
        "AV3vrSlPuGYfQz6BgjeI", 
        "BVvrSlPuGYfQz6BgjeI"
    ], 
    "scheduleTime": "2017-08-17 12:30:00"
}
'

# Access token example
curl -XPOST 'https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/{idIssue}' -H 'Content-Type: application/json' \
 -H 'user_key: {USER_KEY}' -H 'Access_token: {ACCESS_TOKEN}' -d'
{
    "contactIds": [
        "AV3vrSlPuGYfQz6BgjeI", 
        "BVvrSlPuGYfQz6BgjeI"
    ], 
    "scheduleTime": "2017-08-17 12:30:00"
}
'
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/list/{campaignId}/issue/{idIssue}");
            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 = "{" + 
              "    \"contactIds\": [" + 
              "        \"AV3vrSlPuGYfQz6BgjeI\", " + 
              "        \"BVvrSlPuGYfQz6BgjeI\"" + 
              "    ], " + 
              "    \"scheduleTime\": \"2017-08-17 12:30:00\"" + 
              "}";

            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();
        }
    }
}
Copy code
<?php

$payload = '{' . 
  '    "contactIds": [' . 
  '        "AV3vrSlPuGYfQz6BgjeI", ' . 
  '        "BVvrSlPuGYfQz6BgjeI"' . 
  '    ], ' . 
  '    "scheduleTime": "2017-08-17 12:30:00"' . 
  '}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/{idIssue}');
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!');
}
?>
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 = """{
    "contactIds": [
        "AV3vrSlPuGYfQz6BgjeI", 
        "BVvrSlPuGYfQz6BgjeI"
    ], 
    "scheduleTime": "2017-08-17 12:30:00"
}"""

r = requests.post("https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/{idIssue}", headers=headers, data=payload)

if r.status_code != 201:
    print("An error occurred, return code is: " + str(r.status_code))
else:
    print('Success!')
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/list/{campaignId}/issue/{idIssue}',
    method: 'POST',
    headers: { 'user_key' : '{USER_KEY}', 'Session_key' : '{SESSION_KEY}' },

    json: true,
    body:     {
        "contactIds": [
            "AV3vrSlPuGYfQz6BgjeI", 
            "BVvrSlPuGYfQz6BgjeI"
        ], 
        "scheduleTime": "2017-08-17 12:30:00"
    },

    callback: function (error, responseMeta, response) {
        if (!error && responseMeta.statusCode == 201) {
            console.log('Success!');
        }
        else {
            console.log('An error occurred..');
        }
    }
});
Copy code
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://app.gateway.smsend.it/API/v1.0/REST/list/{campaignId}/issue/{idIssue}")
payload =     {
        "contactIds": [
            "AV3vrSlPuGYfQz6BgjeI", 
            "BVvrSlPuGYfQz6BgjeI"
        ], 
        "scheduleTime": "2017-08-17 12:30:00"
    }

# 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
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 = "{" + 
                  "    \"contactIds\": [" + 
                  "        \"AV3vrSlPuGYfQz6BgjeI\", " + 
                  "        \"BVvrSlPuGYfQz6BgjeI\"" + 
                  "    ], " + 
                  "    \"scheduleTime\": \"2017-08-17 12:30:00\"" + 
                  "}";

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

        }
    }
}
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/list/{campaignId}/issue/{idIssue}";

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 = {
    "contactIds" => [
        "AV3vrSlPuGYfQz6BgjeI", 
        "BVvrSlPuGYfQz6BgjeI"
    ], 
    "scheduleTime" => "2017-08-17 12:30:00"
};

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

}