Skip to content

Create domain webhooks (v4)

Request

Create webhook URLs for multiple event types in a single operation. This v4 endpoint allows associating one URL with multiple webhook event types.

Security
basicAuth
Path
domainstringrequired

The domain name to create webhooks for

Bodyapplication/x-www-form-urlencodedrequired
urlstringrequired

The webhook URL that will receive POST requests

event_typesstringrequired

Event types. Use multiple times to specify multiple event types.

Enum ValueDescription
accepted

The accepted event occurs when Mailgun accepts a message for delivery.

clicked

The clicked event occurs when a recipient clicks a link in the email. This requires click tracking to be enabled for the domain.

opened

The opened event occurs when a recipient opens the email. This requires open tracking to be enabled for the domain.

unsubscribed

The unsubscribed event occurs when a recipient unsubscribes using an unsubscribe mechanism in your email (for example, a list-unsubscribe link).

delivered

The delivered event occurs when an email is successfully delivered to the recipient's mail server.

permanent_fail

The permanent_fail event occurs when an email cannot be delivered due to a permanent error.

temporary_fail

The temporary_fail event occurs when an email cannot be delivered due to a temporary error.

complained

The complained event occurs when a recipient marks your email as spam or their email provider registers a spam complaint.

curl -i -X POST \
  -u '<username>:<password>' \
  'https://api.mailgun.net/v4/domains/{domain}/webhooks' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d url=string \
  -d event_types=accepted

Responses

A 200 response

Bodyapplication/json
webhooksobject(github.com-mailgun-domains-httpapi-WebhooksResponse)required

List of webhooks

Response
{ "webhooks": { "accepted": {}, "delivered": {}, "clicked": {}, "permanent_fail": {} } }