Import

Import your customer details into your SendMode account.

Available HTTP Methods: POST

sm_api_icon

Parameters

Parameters

ParameterTypeDescriptionRequired
importdataJSONData of the customer to import in JSON format.Yes
groupstringGroup to add the customer into.No
Importdata JSON

Importdata JSON

ParameterTypeDescriptionRequired
mobilenumberstringThe customers mobile number.Yes
firstnamestringThe customers first name.No
surnamestringThe customers surname.No
addressstringThe customers address.No
townstringThe customers address town.No
countystringThe customers address county.No
emailstringThe customers email address.No
custom1stringThe customers custom1 field.No
custom2stringThe customers custom2 field.No
businessnamestringThe customers business name.No
dateofbirthstringThe customers date of birth in format dd/mm/yyyyNo
Example importdata JSON
{
    "mobilenumber":"0870000000",
    "firstname":"Hello",
    "surname":"World"
}
Code Example

Code Example

C#
string customer = new JavaScriptSerializer().Serialize(new 
    { 
        mobilenumber = "0870000000",
        firstname = "Hello" 
    }
);
string group = "Hello World";

using (WebClient client = new WebClient())
{
    client.Headers.Add("Authorization", "YOUR_ACCESS_KEY");
    byte[] response = client.UploadValues("https://rest.sendmode.com/v2/import", new NameValueCollection()
    {
        { "importdata", customer},
        { "group", group},
    });

    string result = System.Text.Encoding.UTF8.GetString(response);
}
php
$arr =  array('mobilenumber' => '0870000000', 'firstname' => 'Hello');
$url = 'https://rest.sendmode.com/v2/import';
$data = array('importdata' => json_encode($arr));

// use key 'http' even if you send the request to https://...
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n" .
            "Authorization: YOUR_ACCESS_KEY\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
Java
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("https://rest.sendmode.com/v2/import");
httppost.setHeader(HttpHeaders.AUTHORIZATION, YOUR_ACCESS_KEY);

String json = "{\"firstname\" : \"Hello\", \"mobilenumber\" : \"0870000000\"}";
List<NameValuePair> params = new ArrayList<NameValuePair>(1);
params.add(new BasicNameValuePair("importdata", json));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
Response

Response

{
    "status":"OK",
    "statusCode":0,
    "acceptedDateTime":"2017-08-28T13:42:02.1757174+01:00",
    "group":"HELLO WORLD",
    "importdata":{
        "mobilenumber":"0870000000",
        "firstname":"Hello World",
        "surname":null,
        "address":null,
        "town":null,
        "county":null,
        "email":null,
        "custom1":null,
        "custom2":null,
        "businessname":null,
        "dateofbirth":null
    }
}