Create a New Email Campaign

Email campaigns are used to send email messages to a list of contacts. Creating and sending the campaign are two different actions.

Creating the campaign puts it in the 'composing' state, giving you the opportunity to add and remove lists, and tweak the campaign parameters.

Once you're done tweaking, you can trigger the sending of the campaign by creating a Send Email Action for the specific email.


The Method

API Method
RESTPOSThttp://[Your URL]/api/2.0/emails
XML-RPCCallemails.CreateEmail
Your URL is the address of your Everlytic install.

Your method must be structured as follows:

CreateEmail(\struct | array $properties) : int

Parameters

Required Parameters

You must include the properties of the email you want to create.

PropertyTypeDescriptionRequired
$property\structarrayThe properties of the email you need to create. See the table below for a full list of options.Yes

Properties

PropertyTypeDescriptionDefaultRequiredRead Only
campaign_namestringCampaignemptynono
subjectstringSubjectemptyyesno
from_emailstringFrom Emailemptyyesno
from_namestringFrom Nameemptynono
reply_emailstringReply Emailemptynono
html_originalstringOriginal HTMLemptynono
text_originalstringOriginal Textemptynono
is_html_fetch_from_urlstringFetch HTML from URL
Possible values:
yes
no
nonono
html_fetch_urlstringFetch HTML URLemptynono
html_fetch_whenstringFetch HTML when
Possible values:
now
confirm
send
nownono
is_text_fetch_from_urlstringFetch text from URL
Possible values:
yes
no
nonono
text_fetch_urlstringFetch text URLemptynono
text_fetch_whenstringFetch text when
Possible values:
now
confirm
send
nownono
is_copy_text_autostringCopy text from HTML
Possible values:
yes
no
yesnono
attachmentsstringAttachmentsemptynono
list_idsstringList identifiersemptynono
filter_idintegerFilter identifieremptynono
template_idintegerTemplate identifieremptynono
is_scheduledstringScheduled
Possible values:
yes
no
nonono
send_scheduled_dateintegerSchedule date0nono
scheduled_recurrencestringSchedule recurrance
Possible values:
once
weekdays
daily
weekly
monthly
yearly
oncenono
scheduled_previous_message_idintegerPrevious scheduled message identifier0nono
approval_requiredstringApproval required
Possible values:
yes
no
nonono
approval_namestringNameemptynono
approval_emailstringEmailemptynono
inline_cssstringConvert CSS to inline styles
Possible values:
yes
no
yesnono
embeded_imagesstringEmbed images
Possible Values:
yes
no
nonono
track_linksstringTrack link clicks
Possible values:
yes
no
yesnono
track_readsstringTrack opens
Possible values:
yes
no
yesnono
unsubscribe_typestringUnsubscribe footer type
Possible Values:
none
standard
extra
nonenono
insert_unsubscribe_linkstringInsert unsubscribe footer
Possible values:
yes
no
nonono
include_analyticsstringGoogle analytics
Possible values:
yes
no
nonono
prioritystringPriority
Possible values:
low
medium
high
mediumnono
character_setstringCharacter setUTF-8nono
encodingstringEncoding
Possible values:
7bit
8bit
binary
quoted-printable
base64
8bitnono
import_idintegerThe ID of a contacts import (Requires the list_ids property to be set)emptynono

Responses

TypeDescription
integerThe ID of the created email.
StringError message if you have chosen a filter, but not set the list ID.

Code Samples

PHP (using REST API)

Tutorial

The rest of this document describes the example above, step-by-step.

In our Getting Started section we covered the four important components of an API request; URL, method, headers, and body.

RequestStructure

Let's analyse the code sample above to determine where each line fits into this outline.

1. JSON

We use JSON to enclose the variables at the top of the API request (above the URL section). The File query allows you to add attachments to your email campaign.

$json = '

{
"files":
[
{"filename":"test.csv",
"content":"base64 data here"
}]

"subject":"subject",

"from_email":"michael@everlytic.com",

"is_html_fetch_from_url":"yes",

"html_fetch_url":"http://www.google.com",

"list_ids":"1"

}

';

2. Load the Everlytic API

The following line of code tells the server which API URL to access for the request:

$url = '(Your URL)/api/2.0/emails';

Your URL is the URL of your Everlytic installation.

3. Method

In this line of code, you tell the API which REST function to use:

$method = 'POST';

4. cURL

cURL is a tool for sending and receiving files from a web server. This line of code initialises the cURL session.

$cSession = curl_init();

5. Initiate the Headers

This section of the code opens the headers section and passes the authentication (including your API key).

$headers = array();

$auth = base64_encode($username . ':' . $apikey);

$headers[] = 'Authorization: Basic ' . $auth;

6. Set various cURL options for the session

These lines of code tell the server that we're using cURL to transfer data.

curl_setopt($cSession, CURLOPT_URL, $url);

curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);

curl_setopt($cSession, CURLOPT_HEADER, false);

curl_setopt($cSession, CURLOPT_CUSTOMREQUEST,

strtoupper($method));

curl_setopt($cSession, CURLOPT_POSTFIELDS, $json);

7. Tell the server to read the variables from the JSON string

$headers[] = 'Content-Type: application/json';

curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);

8. Output the API response

$result = curl_exec($cSession);

9. Close the cURL session

curl_close($cSession);

 

Translate »