int addWebhook( string api_key, object webhook_details );
API Key Access Level required: Full access
The key required to access the API. See Getting Started for more information.
An object of Webhook details. See remarks below for a description of the values in the
Returns the ID of the newly added Webhook on success.
Creating a new Webhook to receive events when Contacts are unsubscribed:
$webhook_details = array(
'object' => 'contact',
'event' => 'unsubscribed',
'list_id' => 123,
'url' => 'http://example.com/example.php'
$webhook = $api->invokeMethod('addWebhook', $webhook_details);
The following table shows the structure of the
||string||Yes||Object that the event applies to, either 'list' or 'contact'|
||string||Yes||The event against the object that will trigger this Webhook|
||int||No||0||The List that this Webhook applies to, or 0 to watch all Lists|
||string||Yes||The http/https URL of the receiving Webhook endpoint|
The following is a list of the possible event types and which object(s) they apply to:
||list||contact The object was created|
||list||contact The object was updated|
||list, contact||The object was removed|
||list||A large number of contacts in the list were changed or the list was cleared|
||contact||The contact was subscribed|
||contact||The contact was unsubscribed|
||contact||The contact was deactivated|
||contact||The contact was reactivated|
Note: When a contact is manually added and subscribed at the same time, both events will be sent.
This method may return the following error codes in addition to the standard error codes:
||Invalid Method Parameters||One or more parameters are invalid.|
||Duplicate Webhook details not allowed||A webhook with the exact remarks already exists|