Create a New Subscription List

You can use this request to create a new subscription list. Subscription lists are used to send email campaigns to groups of contacts. A contact will have a subscription status on a list, denoting whether or not the contact should receive messages when a campaign is sent to that list.


The Method

API Method
RESTPOSThttp://[Your URL]/api/2.0/lists
XML-RPCCalllists.CreateList
Your URL is the address of your Everlytic install.

Your method must be structured as follows:

CreateList(\struct | array $properties) : int

Parameters

PropertyTypeDescriptionRequired
$properties\structarrayAn array of the properties of the list you need to create.yes

Properties

PropertyTypeDescriptionDefaultRequiredRead Only
list_group_idintegerList group identifier.0nono
namestringName of the list.emptyyesno
public_namestringPublic name of the list.emptynono
owner_namestringName of the list owner.emptynono
owner_emailstringEmail address for the list owner.emptyyesno
owner_reply_emailstringThe list owner's reply address.emptynono
company_namestringNameemptynono
company_addressstringAddressemptynono
company_citystringCityemptynono
company_statestringStateemptynono
company_countrystringCountryemptynono
company_postal_codestringPostal codeemptynono
company_telephonestringTelephone numberemptynono
company_mobilestringMobile numberemptynono
company_faxstringFax numberemptynono
company_emailstringEmail addressemptynono
company_urlstringURLemptynono
notify_owner_on_list_subscribestringNotify owner on list subscribe
Possible values:
yes
no
nonono
notify_owner_on_list_unsubscribestringNotify owner on list unsubscribe
Possible values:
yes
no
nonono
ask_for_unsubscribe_reasonstringAsk for reason on list unsubscribe
Possible Values:
yes
no
nonono
send_unsubscribe_confirmationstringConfirmation message sent on unsubscribe
Possible values:
yes
no
nonono
redirect_url_on_unsubscribestringCustom unsubscribe URLemptynono

Responses

TypeDescription
integerThe ID of the created list.

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

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

$json = '

{

"name":"This is the name of the list",

"owner_email":"michael@everlytic.com"

}

';

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

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

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 output.

The fourth line calls the $method specified above, which is to ‘POST’ (create) the data from the server.

The fifth line specifies which data to create in the server from the JSON code defined above already.

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 »