REST Email Marketing API Documentation

MAILINGS — CREATE

Create a new mailing.

HTTP VERB

Post

URL

/API/Rest/Mailings

ARGUMENTS

The fields for the mailing are listed below. Most are optional, meaning the values will be read from the topic or global settings. Both the textBody and the htmlBody are optional, but at least one should be provided. The audience of the mailing will be any subscribed recipients for the topic, unless a segment is specified. Alternatively, the audience can be specified with the Audience API call.

mailingTitle The title for you to identify this mailing. Must be unique and 25 characters or less.
textBody (Optional) The text portion of the content.
htmlBody (Optional) The HTML portion of the content.
charsetId (Optional) The character set for this content.
delimiterStart (Optional) The delimiter to mark the start of a mail merge section. Use [-, [[, or {{
delimiterEnd (Optional) The delimiter to mark the end of a mail merge section. Use -], ]], or }}
headerFrom (Optional) The from address for the email. Use just an email address or an email address with a name, like "Example Sales"<sales@email.com>
subject The subject of the email message.
bodyLanguageId (Optional) The language ID for the content.
replyTo (Optional) The reply-to header in the email. Must be a valid email address. Can be something like DoNotReply@example.com, although this is not recommended. Can use mail merge tags to make the reply dynamic.
additionalHeaders (Optional) String dictionary. Additional headers to add to the message.
priority (Optional) An integer between 1 and 9 of the priority of this mailing compared with other mail sent from this customer. 1 is highest, 9 is lowest, 5 is default.
trackedLinks (Optional) String array. The specific links from the email that you want tracked. Overrides the trackAllLinks option. Every link listed must appear someplace in the message.
trackAllLinks (Optional) Boolean. Track all links found in the content?
recipientLoggingLevel (Optional) What level of logs to keep. (A)ll, (E)rrors, or (N)one.
unsubscribeTopic The topic to use to record unsubscribes.
detectOpens (Optional) Boolean. Add an invisible image to the HTML section to allow for tracking of opens?
virtualIpGroup (Optional) What IP group to use if you have configured multiple IP addresses.
segmentName (Optional) The name of a segment to use for determining the audience.

Required permission

EditMailing

ERRORS

No Permission
Mailing title cannot be missing
Mailing title is too long. Please limit to 25 characters or less
No content provided
Invalid Unsubscribe topic
Mailing title currently in use
Invalid segment name
Provide both Charset ID and Body Language ID or neither
Invalid CharsetId
Invalid BodyLanguageId
Invalid DelimiterStart. Recommend [- Alternatively {{ or [[
Invalid DelimiterEnd. Recommend -] Alternatively }} or ]]
Mismatched delimiters. Use [- -], {{ }}, or [[ ]]
Invalid Header From value and no default defined. Must be a valid email address, optionally with a user name
Invalid Reply To value and no default defined. Must be a valid email address, optionally with a user name
Invalid Header From value. Must be a valid email address, optionally with a user name
Invalid Reply To value. Must be a valid email address, optionally with a user name
The subject cannot be blank
Invalid priority value. 1 is highest, 9 is lowest
Invalid RecipientLoggingLevel. Allowed values are (A)ll, (E)rrors, or (N)one
Invalid VirtualIpGroup value
Additional headers cannot be blank for the key or the value
Database error
Unknown error

RETURNS

Success: plus the mailing ID of the newly created mailing.
Mailing created successfully:1193

EXAMPLE

Create a mailing.

string message = "{'accountName':'acme','login':'ApiUser', 'password':'sdve4t3gfd', 'mailingTitle':'CreateTest1', 'textBody':'This is the text portion', 'htmlBody':'This is the <b>HTML</b>', 'charsetId':'1252', 'subject':'This is the subject', 'bodyLanguageId':'1033', 'trackAllLinks':true, 'unsubscribeTopic':'Example Mailings'}";
string url = "http://example.com/api/rest/Mailings/Create";
								
try
{
	System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
	request.Method = "POST";
	request.ContentType = "application/json";
	request.ContentLength = message.Length;
	using (Stream webStream = request.GetRequestStream())
		using (StreamWriter requestWriter = new StreamWriter(webStream, System.Text.Encoding.ASCII))
			requestWriter.Write(message);
								
	System.Net.WebResponse webResponse = request.GetResponse();
	using (Stream webStream = webResponse.GetResponseStream())
		using (StreamReader responseReader = new StreamReader(webStream))
			Console.Out.WriteLine(responseReader.ReadToEnd());
}
catch (Exception e)
{
	System.Diagnostics.Debug.Fail(e.Message);
}
							
# encoding: utf-8
require 'rest-client'
require 'json'
							
url = 'http://www.acme.com/api/rest/Mailings/Create'
args = {'accountName'=>'acme', 'login'=>'ApiUser', 
'password'=>'sdf3w4tw', 'mailingTitle'=>'CreateTest1','textBody'=>'This is the text portion','htmlBody'=>'This is the <b>HTML</b>','charsetId'=>'1252','subject'=>'This is the subject','bodyLanguageId'=>'1033','trackAllLinks'=>true, 'unsubscribeTopic'=>'Example Mailings'}
response = RestClient.post(url, args.to_json, :content_type => "application/json;charset=utf-8")
puts response	
							
import requests

url = "http://www.example.com/api/rest/Mailings/Create";
args = {'accountName':'acme','login':'ApiUser','password':'abd64gfd67e','mailingTitle':'CreateTest1','textBody':'This is the text portion','htmlBody':'This is the <b>HTML</b>','charsetId':'1252','subject':'This is the subject','bodyLanguageId':'1033','trackAllLinks':true,'unsubscribeTopic':'Example Mailings'}
headers = {'Content-Type': 'application/json'}
resp = requests.post(url, json=args, headers=headers)
if resp.status_code == 200:
	print resp.text
						

curl -X POST -H "Content-Type: application/json" -d "{'accountName':'acme','login':'ApiUser','password':'abd64gfd67e', 'mailingTitle':'CreateTest1','textBody':'This is the text portion','htmlBody':'This is the <b>HTML</b>', 'charsetId':'1252','subject':'This is the subject','bodyLanguageId':'1033','trackAllLinks':True, 'unsubscribeTopic':'Example Mailings'}" http://example.com/api/rest/Mailings/Create

Share this: