Webhooks (deprecated)

Warning

This refers to a previous version of the API which is deprecated and may be removed in a future release. Ongoing development of webhooks should be using the latest API available here: Webhooks

Note

If you are looking forward to migrate to the new Webhooks API, you don’t need to worry: both APIs can be used at the same time. You’ll be notified by the legacy webhooks and the new webhooks. But don’t forget to remove the legacy url as soon as you get migrated your app to the new API!

This API allows you to create, access, and delete webhooks programmatically.

Supported webhooks, and their documentation, are listed below:

Webhook Name Documentation
bounce Tracking Failures, Bounces Parameters
deliver Tracking Deliveries, Deliveries Parameters
drop Tracking Failures, Drops Parameters
spam Tracking Spam Complaints, Spam Complaints Parameters
unsubscribe Tracking Unsubscribes, Unsubscribes Parameters
click Tracking Clicks, Clicks Parameters
open Tracking Opens, Opens Parameters
GET /domains/<domain>/webhooks

Returns a list of webhooks set for the specified domain.

Parameter Description
domain Name of the domain
GET /domains/<domain>/webhooks/<webhookname>

Returns details about a the webhook specified in the URL.

Parameter Description
domain Name of the domain
id Name of the webhook. (See above for supported webhooks)
POST /domains/<domain>/webhooks

Creates a new webhook.

Note

When adding a Click or Open webhook, ensure that you also have tracking enabled.

Parameter Description
domain Name of the domain
id Name of the webhook. (See above for supported webhooks)
url URL for the webhook event.
PUT /domains/<domain>/webhooks/<webhookname>

Updates an existing webhook.

Parameter Description
domain Name of the domain
id Name of the webhook. (See above for supported webhooks)
url URL for the webhook event.
DELETE /domains/<domain>/webhooks/<webhookname>

Deletes an existing webhook.

Note

Mailgun imposes a rate limit for the Webhook API endpoint. Users may issue no more than 300 requests per minute, per account. See the resultant rate limit response below.

Parameter Description
domain Name of the domain
id Name of the webhook. (See above for supported webhooks)

Webhooks Parameters

Opens Parameters

You can specify a webhook URL programmaticaly using the API described above or in the Webhooks tab of your Control Panel. When a user opens one of your emails, your URL will be called with the following parameters.

Parameter Name Description
event Event name (“opened”).
recipient Recipient who opened.
domain Domain that sent the original message.
ip IP address the event originated from.
country Two-letter country code (as specified by ISO3166) the event came from or ‘unknown’ if it couldn’t be determined.
region Two-letter or two-digit region code or ‘unknown’ if it couldn’t be determined.
city Name of the city the event came from or ‘unknown’ if it couldn’t be determined.
user-agent User agent string of the client triggered the event.
device-type Device type the email was opened on. Can be ‘desktop’, ‘mobile’, ‘tablet’, ‘other’ or ‘unknown’.
client-type Type of software the email was opened in, e.g. ‘browser’, ‘mobile browser’, ‘email client’.
client-name Name of the client software, e.g. ‘Thunderbird’, ‘Chrome’, ‘Firefox’.
client-os OS family running the client software, e.g. ‘Linux’, ‘Windows’, ‘OSX’.
campaign-id The id of campaign triggering the event.
campaign-name The name of campaign triggering the event.
tag Message tag, if message was tagged. See Tagging
mailing-list The address of mailing list the original message was sent to.
“custom variables” Your own custom JSON object included in the header (see Attaching Data to Messages).
timestamp Number of seconds passed since January 1, 1970
token Randomly generated string with length 50
signature String with hexadecimal digits generate by HMAC algorithm

Clicks Parameters

You can specify a webhook URL programmaticaly using the API described above or in the Webhooks tab of your Control Panel. Every time a user clicks on a link inside of your messages, your URL will be called with the following parameters:

Parameter Name Description
event Event name (“clicked”).
recipient Recipient who clicked.
domain Domain that sent the original message.
ip IP address the event originated from.
country Two-letter country code (as specified by ISO3166) the event came from or ‘unknown’ if it couldn’t be determined.
region Two-letter or two-digit region code or ‘unknown’ if it couldn’t be determined.
city Name of the city the event came from or ‘unknown’ if it couldn’t be determined.
user-agent User agent string of the client triggered the event.
device-type Device type the link was clicked on. Can be ‘desktop’, ‘mobile’, ‘tablet’, ‘other’ or ‘unknown’.
client-type Type of software the link was opened in, e.g. ‘browser’, ‘mobile browser’, ‘email client’.
client-name Name of the client software, e.g. ‘Thunderbird’, ‘Chrome’, ‘Firefox’.
client-os OS family running the client software, e.g. ‘Linux’, ‘Windows’, ‘OSX’.
campaign-id The id of campaign triggering the event.
campaign-name The name of campaign triggering the event.
tag Message tag, if it was tagged. See Tagging.
url The URL that was clicked.
mailing-list The address of mailing list the original message was sent to.
“custom variables” Your own custom JSON object included in the header (see Attaching Data to Messages).
timestamp Number of seconds passed since January 1, 1970
token Randomly generated string with length 50
signature String with hexadecimal digits generate by HMAC algorithm

Unsubscribes Parameters

You can specify a webhook URL programmaticaly using the API described above or in the Webhooks tab of your Control Panel. When a user unsubscribes, Mailgun will invoke the webhook with the following parameters:

Parameter Name Description
event Event name (“unsubscribed”).
recipient Recipient who unsubscribed.
domain Domain that sent the original message.
ip IP address the event originated from.
country Two-letter country code (as specified by ISO3166) the event came from or ‘unknown’ if it couldn’t be determined.
region Two-letter or two-digit region code or ‘unknown’ if it couldn’t be determined.
city Name of the city the event came from or ‘unknown’ if it couldn’t be determined.
user-agent User agent string of the client triggered the event.
device-type Device type the person unsubscribed on. Can be ‘desktop’, ‘mobile’, ‘tablet’, ‘other’ or ‘unknown’.
client-type Type of software the unsubscribe link was clicked in, e.g. ‘browser’, ‘mobile browser’, ‘email client’.
client-name Name of the client software, e.g. ‘Thunderbird’, ‘Chrome’, ‘Firefox’.
client-os OS family running the client software, e.g. ‘Linux’, ‘Windows’, ‘OSX’.
campaign-id The id of the campaign that recipient has unsubscribed from.
campaign-name The name of campaign triggering the event.
tag Message tag, if it was tagged. See Tagging.
mailing-list The address of mailing list the original message was sent to.
“custom variables” Your own custom JSON object included in the header (see Attaching Data to Messages).
timestamp Number of seconds passed since January 1, 1970
token Randomly generated string with length 50
signature String with hexadecimal digits generate by HMAC algorithm

Spam Complaints Parameters

You can specify a webhook URL programmaticaly using the API described above or in the Webhooks tab in the Control Panel. When a user reports one of your emails as spam, Mailgun will invoke the webhook with the following parameters:

Parameter Name Description
event Event name (“complained”).
recipient Recipient who clicked spam.
domain Domain that sent the original message.
message-headers String list of all MIME headers of the original message dumped to a JSON string (order of headers preserved).
campaign-id The id of campaign triggering the event.
campaign-name The name of campaign triggering the event.
tag Message tag, if it was tagged. See Tagging.
mailing-list The address of mailing list the original message was sent to.
“custom variables” Your own custom JSON object included in the header (see Attaching Data to Messages).
timestamp Number of seconds passed since January 1, 1970
token Randomly generated string with length 50
signature String with hexadecimal digits generate by HMAC algorithm
attachment-x attached file (‘x’ stands for number of the attachment). Attachments are included if the recipient ESP includes them in the bounce message. They are handled as file uploads, encoded as multipart/form-data.

Bounces Parameters

You can specify a webhook URL programmaticaly using the API described above or in the Webhooks tab of your Control Panel. If you do, every time a message experiences a hard bounce, your URL will be invoked with the following parameters:

Parameter Name Description
event Event name (“bounced”).
recipient Recipient who could not be reached.
domain Domain that sent the original message.
message-headers String list of all MIME headers of the original message dumped to a JSON string (order of headers preserved).
code SMTP bounce error code in form (X.X.X).
error SMTP bounce error string.
notification Detailed reason for bouncing (optional).
campaign-id The id of campaign triggering the event.
campaign-name The name of campaign triggering the event.
tag Message tag, if it was tagged. See Tagging.
mailing-list The address of mailing list the original message was sent to.
“custom variables” Your own custom JSON object included in the header (see Attaching Data to Messages).
timestamp Number of seconds passed since January 1, 1970
token Randomly generated string with length 50
signature String with hexadecimal digits generate by HMAC algorithm
attachment-x attached file (‘x’ stands for number of the attachment). Attachments are included if the recipient ESP includes them in the bounce message. They are handled as file uploads, encoded as multipart/form-data.

Drops Parameters

In the Webhooks tab or programmaticaly using the API described above, you can specify a URL to be notified every time a message is dropped. There are a few reasons why Mailgun needs to stop attempting to deliver messages and drop them. The most common reason is that Mailgun received a Hard bounce or repeatedly received Soft bounces and continuing attempting to deliver may hurt your reputation with the receiving ESP. Also, if the address is on one of the ‘do not send lists’ because that recipient had previously bounced, unsubscribed, or complained of spam, we will not attempt delivery and drop the message. If one of these events occur we will POST the following parameters to your URL:

Parameter Name Description
event Event name (“dropped”).
recipient Intended recipient.
domain Domain that sent the original message.
message-headers String list of all MIME headers of the original message dumped to a JSON string (order of headers preserved).
reason Reason for failure. Can be one either “hardfail” or “old”. See below.
code ESP response code, e.g. if the message was blocked as a spam (optional).
description Detailed explanation of why the messages was dropped
“custom variables” Your own custom JSON object included in the header (see Attaching Data to Messages).
timestamp Number of seconds passed since January 1, 1970
token Randomly generated string with length 50
signature String with hexadecimal digits generate by HMAC algorithm
attachment-x attached file (‘x’ stands for number of the attachment). Attachments are included if the recipient ESP includes them in the bounce message. They are handled as file uploads, encoded as multipart/form-data.
  • old indicates that Mailgun tried to deliver the message unsuccessfully for more than 8 hours.
  • hardfail not delivering to an address that previously bounced, unsubscribed, or complained.

Deliveries Parameters

In the Webhooks tab or programmaticaly using the API described above, you can specify a URL to be notified every time a message is delivered. If the message is successfully delivered to the intended recipient, we will POST the following parameters to your URL:

Parameter Name Description
event Event name (“delivered”).
recipient Intended recipient.
domain Domain that sent the original message.
message-headers String list of all MIME headers dumped to a JSON string (order of headers preserved).
Message-Id String id of the original message delivered to the recipient.
“custom variables” Your own custom JSON object included in the header of the original message (see Attaching Data to Messages).
timestamp Number of seconds passed since January 1, 1970
token Randomly generated string with length 50
signature String with hexadecimal digits generate by HMAC algorithm

Examples

Return a list of webhooks set for the specified domain.

curl -s --user 'api:YOUR_API_KEY' -G \
    https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

public class MGSample {

    // ...

    public static JsonNode getWebhooks() throws UnirestException {

        HttpResponse <JsonNode> request = Unirest.get("https://api.mailgun.net/v3/domains/" + YOUR_DOMAIN_NAME + "/webhooks")
            .basicAuth("api", API_KEY)
            .asJson();

        return request.getBody();
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$domain = 'YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->get("domains/$domain/webhooks");
def get_bounces():
    return requests.get(
        "https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks",
        auth=("api", "YOUR_API_KEY"))
def get_webhooks
  RestClient.get "https://api:YOUR_API_KEY"\
                 "@api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks"
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class GetWebhooksChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (GetWebhooks ().Content.ToString ());
    }

    public static IRestResponse GetWebhooks ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.AddParameter ("domain", "YOUR_DOMAIN_NAME", ParameterType.UrlSegment);
        request.Resource = "domains/{domain}/webhooks";
        return client.Execute (request);
    }

}
import (
    "context"
    "github.com/mailgun/mailgun-go/v3"
    "time"
)

func ListWebhooks(domain, apiKey string) (map[string]string, error) {
    mg := mailgun.NewMailgun(domain, apiKey)

    ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
    defer cancel()

    return mg.ListWebhooks(ctx)
}
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({ apiKey: "YOUR_API_KEY", domain: DOMAIN });

mailgun.get(`/domain/${DOMAIN}/webhooks`, function (error, body) {
  console.log(body);
});

Sample response:

{
  "webhooks": {
    "open": {
      "url": "http://postbin.heroku.com/860bcd65"
    },
    "click": {
      "url": "http://postbin.heroku.com/860bcd65"
    }
  }
}

Return a webhook for a specific event for the defined domain.

curl -s --user 'api:YOUR_API_KEY' -G \
    https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

public class MGSample {

    // ...

    public static JsonNode getWebhookEvent() throws UnirestException {

        HttpResponse <JsonNode> request = Unirest.get("https://api.mailgun.net/v3/domains/" + YOUR_DOMAIN_NAME + "/webhooks/click")
            .basicAuth("api", API_KEY)
            .asJson();

        return request.getBody();
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$domain = 'YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->get("$domain/webhooks/click");
def get_domain():
    return requests.get(
        "https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click",
        auth=("api", "YOUR_API_KEY"))
def get_domain
  RestClient.get "https://api:YOUR_API_KEY"\
                 "@api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click"\
                 {|response, request, result| response }
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class GetWebhookChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (GetWebhook ().Content.ToString ());
    }

    public static IRestResponse GetWebhook ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.AddParameter ("domain", "YOUR_DOMAIN_NAME", ParameterType.UrlSegment);
        request.Resource = "/domains/{domain}/webhooks/click";
        return client.Execute (request);
    }

}
import (
    "context"
    "github.com/mailgun/mailgun-go/v3"
    "time"
)

func GetWebhook(domain, apiKey string) (string, error) {
    mg := mailgun.NewMailgun(domain, apiKey)

    ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
    defer cancel()

    return mg.GetWebhook(ctx, "clicked")
}
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({ apiKey: "YOUR_API_KEY", domain: DOMAIN });

mailgun.get(`/domain/${DOMAIN}/webhooks/click`, function (error, body) {
  console.log(body);
});

Sample response:

{
  "webhook": {
    "url": "http://google.com"
  }
}

Create a new webhook.

curl -s --user 'api:YOUR_API_KEY' \
   https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks \
   -F id='click' \
   -F url='http://bin.example.com/8de4a9c4'
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

public class MGSample {

    // ...

    public static JsonNode addWebhook() throws UnirestException {

        HttpResponse <JsonNode> request = Unirest.post("https://api.mailgun.net/v3/domains/" + YOUR_DOMAIN_NAME + "/webhooks")
            .basicAuth("api", API_KEY)
            .field("id","click")
            .field("url", "http://bin.example.com/8de4a9c4")
            .asJson();

        return request.getBody();
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$domain = 'YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->post("domains/$domain/webhooks", array(
    'id'  => 'click',
    'url' => 'http://bin.example.com/8de4a9c4'
));
def add_webhook():
    return requests.post(
        "https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks",
        auth=("api", "YOUR_API_KEY"),
        data={'id':'click', 'url':'http://bin.example.com/8de4a9c4'})
def add_webhook
  RestClient.post("https://api:YOUR_API_KEY"\
                  "@api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks",
                  :id => 'click',
                  :url => 'http://bin.example.com/8de4a9c4')
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class AddWebhookChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (AddWebhook ().Content.ToString ());
    }

    public static IRestResponse AddWebhook ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3/");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "domains/YOUR_DOMAIN_NAME/webhooks";
        request.AddParameter ("id", "click");
        request.AddParameter ("url", "http://bin.example.com/8de4a9c4");
        request.Method = Method.POST;
        return client.Execute (request);
    }

}
import (
    "context"
    "github.com/mailgun/mailgun-go/v3"
    "time"
)

func CreateWebhook(domain, apiKey string) error {
    mg := mailgun.NewMailgun(domain, apiKey)

    ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
    defer cancel()

    return mg.CreateWebhook(ctx, "clicked", []string{"https://your_domain.com/v1/clicked"})
}
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({ apiKey: "YOUR_API_KEY", domain: DOMAIN });

mailgun.post(`/domain/${DOMAIN}/webhooks`, {"id": 'click', "url": 'http://bin.example.com/8de4a9c4'}, function (error, body) {
  console.log(body);
});

Sample response:

{
  "message": "Webhook has been created",
  "webhook": {
    "url": "http://bin.mailgun.net/8de4a9c4"
  }
}

Update an existing webhook.

curl -s --user 'api:YOUR_API_KEY' -X PUT \
    https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click \
    -F url='http://google.com'
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

public class MGSample {

    // ...

    public static JsonNode updateWebhook() throws UnirestException {

        HttpResponse <JsonNode> request = Unirest.put("https://api.mailgun.net/v3/domains/" + YOUR_DOMAIN_NAME + "/webhooks/click")
            .basicAuth("api", API_KEY)
            .field("url", "http://google.com")
            .asJson();

        return request.getBody();
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$listAddress = 'YOUR_DOMAIN_NAME';
$memberAddress = 'bob@example.com';

# Issue the call to the client.
$result = $mgClient->put("$domain/webhooks/click", array(
    'url' => 'http://google.com'
));
def update_member():
    return requests.put(
        ("https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click"),
        auth=('api', 'YOUR_API_KEY'),
        data={'url': 'http://google.com'})
def update_member
  RestClient.put("https://api:YOUR_API_KEY" \
                 "@api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click" \
                 "/bar@example.com",
                 :url => 'http://google.com')
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class UpdateWebhookChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (UpdateWebhook ().Content.ToString ());
    }

    public static IRestResponse UpdateWebhook ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "/domains/YOUR_DOMAIN_NAME/webhooks/click";
        request.AddParameter ("url", "http://google.com");
        request.Method = Method.PUT;
        return client.Execute (request);
    }

}
import (
    "context"
    "github.com/mailgun/mailgun-go/v3"
    "time"
)

func UpdateWebhook(domain, apiKey string) error {
    mg := mailgun.NewMailgun(domain, apiKey)

    ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
    defer cancel()

    return mg.UpdateWebhook(ctx, "clicked", []string{"https://your_domain.com/clicked"})
}
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({ apiKey: "YOUR_API_KEY", domain: DOMAIN });

mailgun.put(`/domain/${DOMAIN}/webhooks/click`, {"url": 'http://google.com'}, function (error, body) {
  console.log(body);
});

Sample response:

{
  "message": "Webhook has been updated",
  "webhook": {
    "url": "http://google.com"
  }
}

Delete a webhook.

curl -s --user 'api:YOUR_API_KEY' -X DELETE \
    https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

public class MGSample {

    // ...

    public static JsonNode deleteWebhook() throws UnirestException {

        HttpResponse <JsonNode> request = Unirest.delete("https://api.mailgun.net/v3/domains/" + YOUR_DOMAIN_NAME + "/webhooks/click")
            .basicAuth("api", API_KEY)
            .asJson();

        return request.getBody();
    }
}
# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('YOUR_API_KEY');
$domain = 'YOUR_DOMAIN_NAME';

# Issue the call to the client.
$result = $mgClient->delete("$domain/webhooks/click");
def delete_domain():
    return requests.delete(
        "https://api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click",
        auth=("api", "YOUR_API_KEY"))
def delete_domain
  RestClient.delete "https://api:YOUR_API_KEY"\
  "@api.mailgun.net/v3/domains/YOUR_DOMAIN_NAME/webhooks/click"
end
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;

public class DeleteWebhookChunk
{

    public static void Main (string[] args)
    {
        Console.WriteLine (DeleteWebhook ().Content.ToString ());
    }

    public static IRestResponse DeleteWebhook ()
    {
        RestClient client = new RestClient ();
        client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
        client.Authenticator =
            new HttpBasicAuthenticator ("api",
                                        "YOUR_API_KEY");
        RestRequest request = new RestRequest ();
        request.Resource = "/domains/{name}/webhooks/click";
        request.AddUrlSegment ("name", "YOUR_DOMAIN_NAME");
        request.Method = Method.DELETE;
        return client.Execute (request);
    }

}
import (
    "context"
    "github.com/mailgun/mailgun-go/v3"
    "time"
)

func DeleteWebhook(domain, apiKey string) error {
    mg := mailgun.NewMailgun(domain, apiKey)

    ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
    defer cancel()

    return mg.DeleteWebhook(ctx, "clicked")
}
var DOMAIN = 'YOUR_DOMAIN_NAME';
var mailgun = require('mailgun-js')({ apiKey: "YOUR_API_KEY", domain: DOMAIN });

mailgun.delete(`/domain/${DOMAIN}/webhooks/click`, function (error, body) {
  console.log(body);
});

Sample response:

{
  "message": "Webhook has been deleted",
  "webhook": {
    "url": "http://postbin.heroku.com/860bcd65"
  }
}

Rate Limit Response:

{
        "retry-seconds": 60,
}