Secure Message Center (SMC) API
API change historyMIGRATE MESSAGES
This method is used to create and update with verify, and delete and move DataMotion messages. A session key must be submitted via the X-Session-Key header. A successful transaction will receive a 200 status code.
Try itRequest
Request URL
Request headers
-
(optional)string
-
(optional)stringMedia type of the body sent to the API.
Request body
The migrate messages request data
{
"Password": "string",
"ChecksumAlgorithm": "string",
"Messages": [
{
"Action": "string",
"UserTag": "string",
"FolderName": "string",
"MessageTag": "string",
"ReadStatus": "string",
"CreateDate": "string",
"ContentData": "string"
}
]
}
{
"description": "The migrate messages request data",
"required": [
"Messages"
],
"type": "object",
"properties": {
"Password": {
"description": "Default Password for auto-create of Users without accounts. Required only for create/update of Messages.",
"type": "string"
},
"ChecksumAlgorithm": {
"description": "Hash algorithm to use when computing the ContentDataHash response. Initially must be set to MD5. Required when ContentData is provided.",
"type": "string"
},
"Messages": {
"description": "An array of users",
"type": "array",
"items": {
"description": "Message migration request metadata",
"required": [
"MessageTag"
],
"type": "object",
"properties": {
"Action": {
"description": "Message Action. Not present except for Delete (D) action. The Delete action removes the message from the database.",
"type": "string"
},
"UserTag": {
"description": "User tag.",
"type": "string"
},
"FolderName": {
"description": "Folder name (DRAFT, INBOX, SENT, TRASH). Required only for Create.",
"type": "string"
},
"MessageTag": {
"description": "Message tag.",
"type": "string"
},
"ReadStatus": {
"description": "UNREAD,READ. Required only for Create.",
"type": "string"
},
"CreateDate": {
"description": "Message creation date (in \"YYYY-MM-DD hh:mm:ss[.nnn]\" format).",
"type": "string"
},
"ContentData": {
"description": "Multi-Part Mime Message Content (body, recipients, attachments). Required only for Create action.",
"type": "string"
}
}
}
}
}
}
Responses
200 OK
Ok. || Message migration successful. Message migration validation successful. (0) || Message migration failed. (10) || Message migration Password exceeds maximum length. (20) || Message migration ChecksumAlgorithm exceeds maximum length. (20) || Message migration messages collection is NULL or empty. (30) || Message migration Action exceeds maximum length. (40) || Message migration CreateDate exceeds maximum length. (40) || Message migration FolderName exceeds maximum length. (40) || Message migration MessageTag exceeds maximum length. (40) || Message migration ReadStatus exceeds maximum length. (40) || Message migration UserTag exceeds maximum length. (40) || Message migration Create required ChecksumAlgorithm field is NULL or empty. (50) || Message migration Create required ChecksumAlgorithm field is invalid. (50) || Message migration Create required UserTag field is NULL or empty. (50) || Message migration Create required FolderName field is NULL or empty. (50) || Message migration Create required FolderName field is invalid. (50) || Message migration Create required ReadStatus field is NULL or empty. (50) || Message migration Create required ReadStatus field is invalid. (50) || Message migration Create required ContentData field is NULL or empty. (50) || Message migration Create optional CreateDate field is invalid. (50) || Message migration Update optional FolderName field is invalid. (60) || Message migration Update optional CreateDate field is invalid. (60) || Message migration Update optional ReadStatus field is invalid. (60) || Message migration Update ContentData is populated and ChecksumAlgorithm field is NULL or empty. (60) || Message migration Update ContentData is populated and ChecksumAlgorithm field is invalid. (60) || Message migration Update no valid optional field supplied. (60) || Message migration Create UserTag does not exist. (70) || Message migration Create CompanyId associated with the UserTag does not match the company of the user associated with the session key. (75) || Message migration Create the email address associated with the UserTag is not in the From or To or Cc or Bcc field. (80) || Message migration Create the Trash folder is invalid in the old email address use case. (82) || Message migration Create Inbox or Inbox|Trash folder passed and no recipient email addresses exist in the message in the old email address use case. (83) || Message migration Create Sent or Drafts or Sent|Trash folder passed and no From email address exists in the message in the old email address use case. (87) || Message migration Create Inbox|Trash and Sent|Trash are only valid in the old email address use case. (89) || Message migration Create the email address associated with the UserTag is in the From field only. The FolderName submitted is 'INBOX'. The submitted FolderName must be 'DRAFT' or 'SENT' or 'TRASH' when the email address associated with UserTag is in the From field only. (90) || Message migration Create the email address associated with the UserTag is in a recipient field only. The FolderName submitted is 'DRAFT' or 'SENT'. The submitted FolderName must be 'INBOX' or 'TRASH' when the email address associated with UserTag is in a recipient field only. (100) || Message migration Create no recipient addresses. (110) || Message migration Create recipient creation cannot create user with blank password. (112) || Message migration Create recipient creation email exceeds maximum length. (114) || Message migration Create recipient creation unexpected exception occurred. Check the server logs. (120) || Message migration Create no From address. (130) || Message migration Create sender creation cannot create user with blank password. (132) || Message migration Create sender creation email exceeds maximum length. (134) || Message migration Create sender creation unexpected exception occurred. Check the server logs. (140) || Message migration Create Subject exceeds maximum length. (145) || Message migration file sizes greater than 32 MB are not supported. (150) || Message migration Create write migration message unexpected exception occurred. Check the server logs. (160) || Message migration validation could not get migrated message data. (170) || Message migration validation could not get migrated message data. Unexpected exception occurred. Check the server logs. (180) || Message migration Move message UserTag is not associated with the message. Cannot move to specified folder. (200) || Message migration Move CompanyId associated with the UserTag does not match the company of the user associated with the session key. (205) || Message migration Move sender cannot move to folder Inbox. (210) || Message migration Move sender cannot move to folder Draft. (220) || Message migration Move recipient cannot move to folder Sent. (230) || Message migration Move recipient cannot move to folder Draft. (240) || Message migration Move message associated with recipient and folder specified is not Inbox or Trash. (250) || Message migration Move message associated with sender and folder specified is not Sent or Trash. (260) || Message migration Move message from Draft to Sent and message does not have recipients. (270) || Message migration Move message invalid folder. Check the server logs. (280) || Message migration Move message unexpected exception occurred. Check the server logs. (290) || Message migration Update sender cannot move to folder Inbox. (300) || Message migration Update sender cannot move to folder Draft. (310) || Message migration Update message associated with sender and folder specified is not Sent or Trash. (320) || Message migration Update recipient cannot move to folder Sent. (330) || Message migration Update recipient cannot move to folder Draft. (340) || Message migration Update message associated with recipient and folder specified is not Inbox or Trash. (350) || Message migration Update message move unexpected exception occurred. Check the server logs. (360) || Message migration Update message move invalid folder. Check the server logs. (370) || Message migration Update message cannot update a draft message with a ReadStatus value of Read. (380) || Message migration Update message ReadStatus unexpected exception occurred. Check the server logs. (390) || Message migration Update message CreateDate unexpected exception occurred. Check the server logs. (400) || Message migration Update message UserTag does not exist. (410) || Message migration Update CompanyId associated with the UserTag does not match the company of the user associated with the session key. (415) || Message migration Update message UserTag is not associated with the message. (420) || Message migration Update message UserTag unexpected exception occurred. Check the server logs. (430) || Message migration Update message delete unexpected exception occurred. Check the server logs. (440) || Message migration file sizes greater than 32 MB are not supported. (450) || Message migration Update the email address associated with the UserTag is in the From field only. The FolderName submitted is 'INBOX'. The submitted FolderName must be 'DRAFT' or 'SENT' or 'TRASH' when the email address associated with UserTag is in the From field only. (460) || Message migration Update no recipient addresses. (470) || Message migration Update recipient creation cannot create user with blank password. (472) || Message migration Update recipient creation email exceeds maximum length. (474) || Message migration Update recipient creation unexpected exception occurred. Check the server logs. (480) || Message migration Update the email address associated with the UserTag is not in the From or To or Cc or Bcc field. (490) || Message migration Update the email address associated with the UserTag is in a recipient field only. The FolderName submitted is 'DRAFT' or 'SENT'. The submitted FolderName must be 'INBOX' or 'TRASH' when the email address associated with UserTag is in a recipient field only. (500) || Message migration Update no From address. (510) || Message migration Update sender creation cannot create user with blank password. (512) || Message migration Update sender creation email exceeds maximum length. (514) || Message migration Update sender creation unexpected exception occurred. Check the server logs. (520) || Message migration Update Subject exceeds maximum length. (530) || Message migration Delete message MessageTag does not exist. (600) || Message migration Delete CompanyId associated with the UserTag does not match the company of the user associated with the session key. (605) || Message migration Delete message unexpected exception occurred. Check the server logs. (610)
Representations
{
"Messages": [
{
"Action": "string",
"UserTag": "string",
"FolderName": "string",
"MessageTag": "string",
"DmMessageId": 0,
"Status": 0,
"Details": "string",
"CreateDate": "string",
"ContentDataHash": "string"
}
]
}
{
"description": "The migrate messages response data",
"required": [
"Messages"
],
"type": "object",
"properties": {
"Messages": {
"description": "An array of messages",
"type": "array",
"items": {
"description": "Message migration response metadata",
"type": "object",
"properties": {
"Action": {
"description": "Action",
"type": "string"
},
"UserTag": {
"description": "User tag",
"type": "string"
},
"FolderName": {
"description": "Folder name (DRAFT, INBOX, SENT, TRASH). Required only for Create.",
"type": "string"
},
"MessageTag": {
"description": "Message tag",
"type": "string"
},
"DmMessageId": {
"format": "int32",
"description": "DataMotion message ID",
"type": "integer"
},
"Status": {
"format": "int32",
"description": "Numeric value indicating status. 0=Successful, 10=GeneralFailure, 20=OuterRequestDataModelValidationFailed, 30=NoValidMessagesCollection, 40=InnerRequestDataModelValidationFailed, 50=CreateFieldValidationFailed, 60=UpdateFieldValidationFailed, 70=CreateUserTagDoesNotExist, 75=CreateCompanyIdAssociatedWithUserTagAndSessionKeyMismatch, 80=CreateEmailAssociatedWithUserTagNotInFromToCcOrBcc, 82=CreateTrashFolderInvalidInOldEmailAddressUseCase, 83=CreateInboxOrInboxTrashPassedAndNoRecipientEmailAddressesInMessageInOldEmailAddressUseCase, 87=CreateSentOrDraftsOrSentTrashPassedAndNoFromEmailAddressInMessageInOldEmailAddressUseCase, 89=CreateInboxTrashAndSentTrashAreOnlyValidInOldEmailAddressUseCase, 90=CreateEmailAssociatedWithUserTagIsSenderAndFolderIsNotDraftSentOrTrash, 100=CreateEmailAssociatedWithUserTagIsRecipientAndFolderIsNotInboxOrTrash, 110=CreateRecipientCreationNoRecipientAddresses, 112=CreateRecipientCreationCannotCreateUserWithBlankPassword, 114=CreateRecipientCreationEmailExceedsMaximumLength, 120=CreateRecipientCreationUnexpectedExceptionOccurred, 130=CreateSenderCreationNoFromAddress, 132=CreateSenderCreationCannotCreateUserWithBlankPassword, 134=CreateSenderCreationEmailExceedsMaximumLength, 140=CreateSenderCreationUnexpectedExceptionOccurred, 145=CreateSubjectExceedsMaximumLength, 150=CreateMessageMigrationExceeds32MB, 160=CreateWriteMigrationMessageUnexpectedExceptionOccurred, 170=MessageMigrationValidationCouldNotGetMigratedMessageData, 180=MessageMigrationValidationCouldNotGetMigratedMessageDataException, 200=MoveMessageUserTagNotAssociatedWithMessage, 205=MoveCompanyIdAssociatedWithUserTagAndSessionKeyMismatch, 210=MoveMessageSenderCannotMoveToFolderInbox, 220=MoveMessageSenderCannotMoveToFolderDraft, 230=MoveMessageRecipientCannotMoveToFolderSent, 240=MoveMessageRecipientCannotMoveToFolderDraft, 250=MoveMessageFolderSpecifiedIsNotInboxOrTrash, 260=MoveMessageFolderSpecifiedIsNotSentOrTrash, 270=MoveMessageDraftToSenderNoRecipients, 280=MoveMessageInvalidFolder, 290=MoveMessageUnexpectedExceptionOccurred, 300=UpdateMessageSenderCannotMoveToFolderInbox, 310=UpdateMessageSenderCannotMoveToFolderDraft, 320=UpdateMessageFolderSpecifiedIsNotSentOrTrash, 330=UpdateMessageRecipientCannotMoveToFolderSent, 340=UpdateMessageRecipientCannotMoveToFolderDraft, 350=UpdateMessageFolderSpecifiedIsNotInboxOrTrash, 360=UpdateMessageMoveUnexpectedExceptionOccurred, 370=UpdateMessageMoveInvalidFolder, 380=UpdateMessageCannotUpdateADraftMessageToBeRead, 390=UpdateMessageReadStatusUnexpectedExceptionOccurred, 400=UpdateMessageCreateDateUnexpectedExceptionOccurred, 410=UpdateMessageUserTagDoesNotExist, 415=UpdateCompanyIdAssociatedWithUserTagAndSessionKeyMismatch, 420=UpdateMessageUserTagNotAssociatedWithMessage, 430=UpdateMessageUserTagUnexpectedExceptionOccurred, 440=UpdateMessageDeleteUnexpectedExceptionOccurred, 450=UpdateMessageMigrationExceeds32MB, 460=UpdateEmailAssociatedWithUserTagIsSenderAndFolderIsNotDraftSentOrTrash, 470=UpdateRecipientCreationNoRecipientAddresses, 472=UpdateRecipientCreationCannotCreateUserWithBlankPassword, 474=UpdateRecipientCreationEmailExceedsMaximumLength, 480=UpdateRecipientCreationUnexpectedExceptionOccurred, 490=UpdateEmailAssociatedWithUserTagNotInFromToCcOrBcc, 500=UpdateEmailAssociatedWithUserTagIsRecipientAndFolderIsNotInboxOrTrash, 510=UpdateSenderCreationNoFromAddress, 512=UpdateSenderCreationCannotCreateUserWithBlankPassword, 514=UpdateSenderCreationEmailExceedsMaximumLength, 520=UpdateSenderCreationUnexpectedExceptionOccurred, 530=UpdateSubjectExceedsMaximumLength, 600=DeleteMessageMessageTagDoesNotExist, 605=DeleteCompanyIdAssociatedWithUserTagAndSessionKeyMismatch, 610=DeleteMessageUnexpectedExceptionOccurred",
"type": "integer"
},
"Details": {
"description": "Error or Action Details",
"type": "string"
},
"CreateDate": {
"description": "Message creation date (in \"YYYY-MM-DD hh:mm:ss[.nnn]\" format)",
"type": "string"
},
"ContentDataHash": {
"description": "Hash of ContentData to verify Create and Update methods. Algorithm specified by ChecksumAlgorithm request parameter.",
"type": "string"
}
}
}
}
}
}
400 Bad Request
The MigrateMessagesRequestData model is required in the request body. || The Messages field is required.
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 MigrateMessages method. || User is not a company admin.
Representations
Code samples
@ECHO OFF
curl -v -X POST "https://api.datamotion.com/SecureMail-Sandbox/Message/MigrateMessages"
-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/Message/MigrateMessages?" + 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/Message/MigrateMessages");
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/Message/MigrateMessages?" + $.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/Message/MigrateMessages";
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/Message/MigrateMessages');
$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/Message/MigrateMessages?%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/Message/MigrateMessages?%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/Message/MigrateMessages')
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