Create new webhook.

webhookCreate(string $title, array $options) : string
Input parametrs
  • title - list name
  • options - array of webhook parameters consisting of:
    • list_id - list ID that the webhook is based on
    • url - URL where requests are delivered to (optional)
    • secret_key - secret key that is passed in every webhook request you receive. It gives you the opportunity to verify that requests originated from us (optional)
    • events - array of events used to trigger the webhook (optional). Possible values are: contact.subscribe, contact.unsubscribe, contact.update, email.change, email.bounce, email.open, email.click
    • sources - array of sources used to trigger the webhook (optional). Possible values are: subscriber, admin, api
Information obtained
  • ID of the new webhook


This Example shows how to webhookCreate using the MGAPI.php class and do some basic error checking.
require_once 'inc/MGAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey

$api = new MGAPI($apikey);

$title = 'Test Webhook';

$options = array(
	'list_id' => $listId,
	'url' => 'http://www.example.com/webhook-listener/',
	'secret_key' =>	'secret',
	'events' => array(
		// 'email.change',
		// 'email.bounce',
	'sources' => array(
		// 'admin',

$retval = $api->webhookCreate($title, $options);

header("Content-Type: text/plain");
if ($api->errorCode) {
	echo "Unable to load webhookCreate()!\n";
	echo "\tCode={$api->errorCode}\n";
	echo "\tMsg={$api->errorMessage}\n";
} else {
	echo "New Webhook ID: {$retval}\n";

© 2010-2020 Mailigen. All rights reserved.