Skip to content

Create a domain webhook

Request

Create a list of webhook URLs you'd like to receive Mailgun's POST requests containing event information.

Security
basicAuth
Path
domainstringrequired

The domain name to create the webhook for

Bodymultipart/form-datarequired
idstringrequired

Webhook type to create.

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.

urlstringrequired

url(s) for webhooks to be sent to. Use multiple times to associate more than one url. Maximum of 3 urls for a given webhook type.

curl -i -X POST \
  -u '<username>:<password>' \
  'https://api.mailgun.net/v3/domains/{domain}/webhooks' \
  -H 'Content-Type: multipart/form-data' \
  -F id=accepted \
  -F url=string

Responses

A 200 response

Bodyapplication/json
messagestringrequired

A message indicating success

webhookobject(github.com-mailgun-domains-httpapi-WebhookResponse)required

Webhook details

Response
{ "message": "Webhook has been created", "webhook": { "urls": [] } }