POST

mailing-lists

Create a new "Contacts" list for the API-key holder account

Variable name

Validation rules

Description

name

required | string

Name of the mailing list

detail

present | nullable | string

Description of the mailing list

email_addresses

nullable | string

A comma-separated list of email addresses as a string

Request example:

{
"name": "Name of the mailing list",
"detail": "Description of the mailing list",
"email_addresses": "[email protected], [email protected]"
}

Response example:

  • Status code: 200 OK

{
"success": true,
"data": {
"id": 200,
"organization_id": 1,
"name": "Name of the mailing list",
"detail": "Description of the mailing list",
"created_at": "2021-01-07 10:46:33",
"updated_at": "2021-01-07 10:46:33",
"used_default_columns": [
"email"
],
"used_custom_columns": [],
"entry_number": 0,
"upload_in_progress": false,
"subscribed_entry_number": 0,
"custom_fields": [],
"unsubscribed": 0,
"bounced": 0
}
}

  • Status code: 422 Unprocessable Entity

{
"errors": {
"name": [
"The name field is required."
],
"detail": [
"The detail field must be present."
]
}
}

Code example:

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '.../mailing-lists', //replace ... with the whole API url
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"name": "New list",
"detail": "Detail of new list"
}',
CURLOPT_HTTPHEADER => array(
'x-api-key: YOUR-API-KEY', //replace with your generated API key
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Did this answer your question?