Overview

You can use this request to subscribe or unsubscribe a contact from a specific list. If a particular subscription already exists, the subscription will be updated.

  • To subscribe a contact, set the status to subscribed.
  • To unsubscribe a contact, set the status to unsubscribed.
  • To remove a contact’s subscription, set both the email and mobile status to an empty string.

The Method

API-Method
REST POSThttps://[Your URL]/api/2.0/list_subscriptions/:list_id
XML-RPCCalllist._subscriptions.ListSubscription

Your method must be structured as follows:

Parameters

Property TypeDescriptionDefaultRequiredRead Only
list_idintegerList identifieremptyyesno
contact_idintegerContact identifieremptyyesno
email_statusstringMapping email status Possible values:
subscribed
unsubscribed
confirmed
unconfirmed
forwarded
emptynono
mobile_statusstringMapping mobile status Possible values:
subscribed
unsubscribed
confirmed
unconfirmed
forwarded
emptynono

Responses

TypeDescription
booleanWhether or not the subscription was created.

Code Samples

PHP (using REST API):

$json = '
{
"list_id":4,
"contact_id":1,
"email_status":"unsubscribed"
}
';
$url = '(Your URL)/api/2.0/list_subscriptions/:list_id';
$method = 'POST';
$cSession = curl_init();
$headers = array();
$auth = base64_encode($username . ':' . $apikey);
$headers[] = 'Authorization: Basic ' . $auth;
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);
$headers[] = 'Content-Type: application/json';
curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($cSession);
curl_close($cSession);