Syntax
int unsubscribeContact( string api_key, int list_id, string address );
API Key Access Level required: Standard access
Parameters
api_key
(string)A key for accessing the API. See Getting Started for more information.
list_id
(int)This List to unsubscribe the address from. Valid values are:
- a List ID - Unsubscribe all Contacts in the List who have the specified address. The Contacts will also be added to the Unsubscriber List.
0
- Add the address to the Unsubscriber List (does not unsubscribe any Contacts).
address
(string)The email address or mobile phone to unsubscribe.
Return Value
Returns the List ID on success.
Examples
The first example code unsubscribes all Contacts with the Email bob@example.com from the List 1234567.
PHP
$email_address = 'bob@example.com';
$api = new Api($url, 'YOURAPIKEY');
$api->invokeMethod('unsubscribeContact', $list_id, $email_address);
JSON Request
"id": 1,
"method": "unsubscribeContact",
"params": [
"YOURAPIKEY",
1234567,
"bob@example.com"
]
}
JSON Response
"id": 1,
"result": 1234567,
"error": null
}
The second example code adds the mobile number to the Unsubscriber List (does not unsubscribe any Contacts).
PHP
$address = '0422111333';
$api = new Api($url, 'YOURAPIKEY');
$api->invokeMethod('unsubscribeContact', 0, $address);
JSON Request
"id": 1,
"method": "unsubscribeContact",
"params": [
"YOURAPIKEY",
0,
"0422111333"
]
}
JSON Response
"id": 1,
"result": 0,
"error": null
}
Remarks
By default, a Contact which has been added to the Unsubscriber List is not reuploaded.
The method will trigger associated Unsubscribe Campaign Events or Autoresponders for each contact successfully unsubscribed.
Use unsubscribeContactById to unsubscribe a specific Contact.
Error Codes
This method may return the following error code in addition to the standard error codes:
Code | Error | Description |
---|---|---|
303 |
Unable to Load List | list_id is not a valid List |