Overview

With this request, you can subscribe or unsubscribe contacts in bulk. The parameters must be passed to the server in an array.

The Method

APIMethodEndpoint
RESTGEThttps://[Your URL]/api/2.0/list_subscriptions/:list_id/bulk
XML-RPCCalllist._subscriptions.BulkListSubscription

Your method must be structured as follows:

Parameters

Property TypeDescriptionRequired
$list_idintegerThe ID of the list to add the contacts to.yes
$subscriptionsarrayAn array of the list subscriptions to create.yes

Properties

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

Responses

TypeDescription
arrayAn array of the subscription results.
Possible results:
True if the creation was successful.
An error message if the creation failed.

Code Samples

PHP (using REST API):

$json = '
{
"subscriptions":{
"1":{
"list_id":4,
"contact_id":1,
"email_status":"subscribed"
},
"2":{
"list_id":4,
"contact_id":2,
"email_status":"subscribed"
}
}
}
';
$url = '(Your URL)/api/2.0/list_subscriptions/:list_id/bulk';
$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);