Update the Specified Email

You can use this request to update the properties of an email. Use the Email's ID to specify which email to update, and submit an array of the properties that need to be changed.


The Method

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

Your method must be structured as follows:

UpdateEmail(integer $id, \struct | array $properties) : int

Parameters

Required Parameters

You must include the following parameters in the request:

PropertyTypeDescriptionRequired
$idintegerThe ID of the email to update.yes
$properties\structarrayThe properties of the email to update.yes

Properties

PropertyTypeDescriptionDefaultRead Only
approval_emailstringEmailemptyno
approval_namestringNameemptyno
approval_requiredstringApproval required
Possible values:
yes
no
nono
attachmentsstringAttachmentsemptyno
campaign_namestringCampaignemptyno
character_setstringCharacter setutf-8no
embeded_imagesstringEmbed images
Possible values:
yes
no
nono
encodingstringEncoding
Possible values:
7bit
8bit
binary
quoted-printable
base64
8bitno
filter_idstringFilter identifieremptyno
from_emailstringFrom emailemptyno
from_namestringFrom nameemptyno
html_fetch_urlstringFetch HTML URLemptyno
html_fetch_whenstringFetch HTML when
Possible values:
now
confirm
send
nowno
html_originalstringOriginal HTMLemptyno
include_analyticsstringGoogle analytics
Possible values:
yes
no
nono
inline_cssstringConvert CSS to inline styles
Possible values:
yes
no
yesno
insert_unsubscribe_linkstringInsert unsubscribe footer
Possible values:
yes
no
nono
is_copy_text_autostringCopy text from HTML
Possible values:
yes
no
yesno
is_html_fetch_from_urlstringFetch HTML from URL
Possible values:
yes
no
nono
is_scheduledstringScheduled
Possible Values:
yes
no
nono
is_text_fetch_from_urlstringFetch text from URL
Possible values:
yes
no
nono
list_idsstringList identifiersemptyno
prioritystringPriority
Possible values:
low
medium
high
mediumno
reply_emailstringReply emailemptyno
scheduled_previous_message_idintegerPrevious scheduled message identifier0no
scheduled_recurrencestringSchedule recurrance
Possible values:
once
weekdays
daily
weekly
monthly
yearly
onceno
send_scheduled_dateintegerSchedule date0no

Responses

TypeDescription
integerThe ID of the updated email.

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. Initialize JSON script

This example is updating the subject of a specified email. You can replace subject with any property that you want to update.

We use JSON to enclose the variables at the top of the API request (above the URL section).

$json = '

{

"subject":"New subject"

}

';

 

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';

3. Method

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

$method = ‘PUT’;

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

The first line uses the $url to get your specified url
The second line returns the string (text) of the return value.
The third line tells the server not to include the header in the ouput.
The fourth line calls the $method specified above, which is to ‘PUT’ (update) the data from the server.

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 »