POST

mailing-lists/{mailingListId}/entries

Add a New Contact to a Contact List

Variable name

Validation rules

Description

email

required | email

Email address

first_name

nullable | string

First name

last_name

nullable | string

Last name

title

nullable | string

Title

phone_number

nullable | string

Phone number

active

nullable | boolean

Active

status

required | valid status*

Status of the entry

custom_fields

nullable | string

Custom fields

Valid statuses*:

  • Subscribed

  • Unsubscribed

  • Bounced

  • Removed

Request example:

  • mailing-lists/47/entries

{
"email": "[email protected]",
"status": "Subscribed"
}

Response example:

  • Status code: 200 OK

{
"success": true,
"data": {
"id": 4,
"mailing_list_id": 47,
"email": "[email protected]",
"first_name": null,
"last_name": null,
"title": null,
"phone_number": null,
"external_id": null,
"source": null,
"status": "Subscribed",
"active": null,
"opened_at": null,
"clicked_at": null,
"bounced_at": null,
"replied_at": null,
"unsubscribed_at": null,
"unsubscribe_reason_id": null,
"created_at": "2021-01-07 11:21:53",
"updated_at": "2021-01-07 11:21:53",
"sent_at": null,
"bounce_message": null,
"custom_attributes": []
}
}

Code example:

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '.../mailing-lists/47/entries', //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 =>'{
"email": "[email protected]",
"status": "Subscribed"
}',
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?