Secure Message Center (SMC) API

API change history

MIGRATE USERS

This method is used to create or update DataMotion user accounts. A session key must be submitted via the X-Session-Key header. A successful transaction will receive a 200 status code.

Try it

Request

Request URL

Request headers

  • (optional)
    string
  • (optional)
    string
    Media type of the body sent to the API.
  • string
    Subscription key which provides access to this API. Found in your Profile.

Request body

The migrate users request data

{
  "Password": "string",
  "CompanyId": 0,
  "UserTypeId": 0,
  "Users": [
    {
      "Email": "string",
      "UserId": "string",
      "UserTag": "string",
      "FirstName": "string",
      "LastName": "string",
      "CreateDate": "string"
    }
  ]
}
{
  "description": "The migrate users request data",
  "required": [
    "Users"
  ],
  "type": "object",
  "properties": {
    "Password": {
      "description": "User password (same for each user record). Required only for Create.",
      "type": "string"
    },
    "CompanyId": {
      "format": "int32",
      "description": "Company ID",
      "type": "integer"
    },
    "UserTypeId": {
      "format": "int32",
      "description": "User type ID",
      "type": "integer"
    },
    "Users": {
      "description": "An array of users",
      "type": "array",
      "items": {
        "description": "The user migration request metadata",
        "required": [
          "UserTag"
        ],
        "type": "object",
        "properties": {
          "Email": {
            "description": "Email address. Required only for Create.",
            "type": "string"
          },
          "UserId": {
            "description": "User ID. Required only for Create.",
            "type": "string"
          },
          "UserTag": {
            "description": "User tag.",
            "type": "string"
          },
          "FirstName": {
            "description": "First name.",
            "type": "string"
          },
          "LastName": {
            "description": "Last name.",
            "type": "string"
          },
          "CreateDate": {
            "description": "User creation date (in \"YYYY-MM-DD hh:mm:ss[.nnn]\" format).",
            "type": "string"
          }
        }
      }
    }
  }
}

Responses

200 OK

Ok. || User migration successful. User migration validation successful. (0) || User migration failed. (10) || User migration Password exceeds maximum length. (20) || User migration CompanyId exceeds maximum length. (20) || User migration UserTypeId exceeds maximum length. (20) || User migration CompanyId less than zero. (20) || User migration UserTypeId less than zero. (20) || User migration company ID retrieval failed. (30) || User migration CompanyId in the request body does not match the company of the user associated with the session key. (40) || User migration UserTypeId does not exist. (50) || User migration cannot migrate user into integrator user type. (60) || User migration Users collection is NULL or empty. (70) || User migration UserTag exceeds maximum length. (80) || User migration UserId exceeds maximum length. (80) || User migration Email exceeds maximum length. (80) || User migration FirstName exceeds maximum length. (80) || User migration LastName exceeds maximum length. (80) || User migration CreateDate exceeds maximum length. (80) || User migration Create required CompanyId field is not greater than zero. (90) || User migration Create required UserTypeId field is not greater than zero. (90) || User migration Create required Password field is NULL or empty. (90) || User migration Create required UserId field is NULL or empty. (90) || User migration Create required Email field is NULL or empty. (90) || User migration Create required Email field is invalid. (90) || User migration Create optional CreateDate field is invalid. (90) || User migration Update no valid optional field supplied. (100) || User migration Update optional Email field is invalid. (100) || User migration Update optional CreateDate field is invalid. (100) || User migration Update cannot update user with blank password. (100) || User migration Create UserId already exists. (110) || User migration Create Email already exists. (120) || User migration Create UserId and Email already exist. (130) || User migration Create UserTag insert UserTag already exists. (140) || User migration Create failed to set CreateDate. (150) || User migration Create User Type Id is not associated with specified Company Id (155) || User migration Create unexpected exception occurred. Check the server logs. (160) || User migration Update user information retrieval failed. (170) || User migration Update CompanyId associated with the UserTag does not match the company of the user associated with the session key. (175) || User migration Update UserId already exists. (180) || User migration Update Email already exists. (190) || User migration Update failed to set CreateDate. (200) || User migration Update unexpected exception occurred. Check the server logs. (210) || User migration validation failed. User migration validation could not get migrated user data. (220) || User migration validation failed. User migration validation could not get migrated user data. Unexpected exception occurred. Check the server logs. (230).

Representations

{
  "Users": [
    {
      "CompanyId": 0,
      "UserTypeId": 0,
      "Action": "string",
      "Email": "string",
      "UserId": "string",
      "UserTag": "string",
      "FirstName": "string",
      "LastName": "string",
      "CreateDate": "string",
      "Uid": 0,
      "Status": 0,
      "Details": "string"
    }
  ]
}
{
  "description": "The migrate users response data",
  "required": [
    "Users"
  ],
  "type": "object",
  "properties": {
    "Users": {
      "description": "An array of users",
      "type": "array",
      "items": {
        "description": "The user migration response metadata",
        "type": "object",
        "properties": {
          "CompanyId": {
            "format": "int32",
            "description": "Company ID",
            "type": "integer"
          },
          "UserTypeId": {
            "format": "int32",
            "description": "User type ID",
            "type": "integer"
          },
          "Action": {
            "description": "Action",
            "type": "string"
          },
          "Email": {
            "description": "Email address",
            "type": "string"
          },
          "UserId": {
            "description": "User ID",
            "type": "string"
          },
          "UserTag": {
            "description": "User tag",
            "type": "string"
          },
          "FirstName": {
            "description": "First name",
            "type": "string"
          },
          "LastName": {
            "description": "Last name",
            "type": "string"
          },
          "CreateDate": {
            "description": "User creation date (in \"YYYY-MM-DD hh:mm:ss[.nnn]\" format)",
            "type": "string"
          },
          "Uid": {
            "format": "int32",
            "description": "DataMotion user ID",
            "type": "integer"
          },
          "Status": {
            "format": "int32",
            "description": "Numeric value indicating status. 0=Successful, 10=GeneralFailure, 20=OuterRequestDataModelValidationFailed, 30=CompanyIdRetrievalFailed, 40=CompanyIdInRequestBodyAndSessionKeyMismatch, \r\n50=UserTypeIdDoesNotExist, 60=CannotMigrateUserIntoIntegratorUserType, 70=NoValidUsersCollection, 80=InnerRequestDataModelValidationFailed, 90=CreateFieldValidationFailed, \r\n100=UpdateFieldValidationFailed, 110=CreateUserIdAlreadyExists, 120=CreateEmailAlreadyExists, 130=CreateUserIdAndEmailAlreadyExist, 140=CreateUserTagInsertUserTagAlreadyExists, \r\n150=CreateFailedToSetCreateDate, 155=CreateUserTypeIdNotAssociatedWithSpecifiedCompanyId, 160=CreateUnexpectedExceptionOccurred, 170=UpdateUserInformationRetrievalFailed, 175=UpdateCompanyIdAssociatedWithUserTagAndSessionKeyMismatch, 180=UpdateUserIdAlreadyExists, 190=UpdateEmailAlreadyExists, \r\n200=UpdateFailedToSetCreateDate, 210=UpdateUnexpectedExceptionOccurred, 220=UserMigrationValidationCouldNotGetMigratedUserData, 230=UserMigrationValidationCouldNotGetMigratedUserDataException",
            "type": "integer"
          },
          "Details": {
            "description": "Error or Action Details",
            "type": "string"
          }
        }
      }
    }
  }
}

400 Bad Request

The MigrateUsersRequestData model is required in the request body. || The UserTag field is required. || CompanyId type is not an integer. || UserTypeId type is not an integer.

Representations

401 Unauthorized

The X-Session-Key header is missing. || Bad session key. || Session key expired. || User is not authorized to use the Web Service API. || User is not authorized to use the MigrateUsers method. || User is not a company admin.

Representations

Code samples

@ECHO OFF

curl -v -X POST "https://api.datamotion.com/SecureMail-Sandbox/Account/MigrateUsers"
-H "X-Session-Key: "
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("X-Session-Key", "");
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://api.datamotion.com/SecureMail-Sandbox/Account/MigrateUsers?" + queryString;

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");

            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }

        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://api.datamotion.com/SecureMail-Sandbox/Account/MigrateUsers");


            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("X-Session-Key", "");
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

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

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://api.datamotion.com/SecureMail-Sandbox/Account/MigrateUsers?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("X-Session-Key","");
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://api.datamotion.com/SecureMail-Sandbox/Account/MigrateUsers";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"" forHTTPHeaderField:@"X-Session-Key"];
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://api.datamotion.com/SecureMail-Sandbox/Account/MigrateUsers');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'X-Session-Key' => '',
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'X-Session-Key': '',
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('api.datamotion.com')
    conn.request("POST", "/SecureMail-Sandbox/Account/MigrateUsers?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'X-Session-Key': '',
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('api.datamotion.com')
    conn.request("POST", "/SecureMail-Sandbox/Account/MigrateUsers?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://api.datamotion.com/SecureMail-Sandbox/Account/MigrateUsers')


request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['X-Session-Key'] = ''
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body