Create a new mailing.
Post
/API/Rest/Mailings/Create
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. |
EditMailing
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
Success: plus the mailing ID of the newly created mailing.
Mailing created successfully:1193
Create a mailing.
using System;
using System.Net.Http;
using System.Text;
string url = "https://example.com/API/Rest/Mailings/Create";
string message = "{\"accountName\":\"acme\",\"login\":\"ApiUser\",\"password\":\"YOUR_PASSWORD\",\"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\"}";
// Reuse HttpClient for multiple requests in production code.
using (var client = new HttpClient())
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
{
request.Content = new StringContent(message, Encoding.UTF8, "application/json");
using (HttpResponseMessage response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
# encoding: utf-8
require 'rest-client'
require 'json'
url = 'https://example.com/API/Rest/Mailings/Create'
args = {'accountName'=>'acme', 'login'=>'ApiUser',
'password'=>'YOUR_PASSWORD', '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 = "https://example.com/API/Rest/Mailings/Create"
args = {'accountName':'acme','login':'ApiUser','password':'YOUR_PASSWORD','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 --request POST --header "Content-Type: application/json" --data '{"accountName":"acme","login":"ApiUser", "password":"YOUR_PASSWORD", "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"}' "https://example.com/API/Rest/Mailings/Create"