Delivery Events
After you submit an email message to Email API via the /send
endpoint, the
message is queued for delivery within MailChannels' extensive cloud
infrastructure. When something happens to your message, Email API can send you
a webhook callback allowing you to track message delivery attempts and failures
(i.e. bounces), user interactions such as opens and clicks, and more.
Webhook Management
Webhooks are managed via the /webhook
endpoint. The HTTP request method
specifies whether you are creating, retrieving, or removing a webhook:
POST
: Create a webhook to receive delivery eventsGET
: Retrieve an existing webhook configurationDELETE
: Remove an existing webhook configuration
Creating a Webhook
To create a webhook that will receive delivery events from Email API, send a
POST
request to /webhook
specifying the URL at which you wish to receive
webhook requests from Email API:
curl -X POST 'https://api.mailchannels.net/tx/v1/webhook?endpoint=YOUR_ENDPOINT_URL' \
-H 'X-Api-Key: YOUR_API_KEY'
Replace YOUR_ENDPOINT_URL
with your webhook receiver URL and YOUR_API_KEY
with your MailChannels API key.
Event Notification Format
Once configured, MailChannels will send batched event notifications to your webhook in the following format:
[
{
"email": "sender@example.com",
"customer_handle": "abc123",
"timestamp": 1625097600,
"event": "processed",
"request_id": "wBLWrCnK0Z965pf-cgxhNg8bo5s="
},
{
"email": "sender@example.com",
"customer_handle": "abc123",
"timestamp": 162509800,
"event": "delivered",
"request_id": "wBLWrCnK0Z965pf-cgxhNg8bo5s="
}
]
See the Appendix below for a JSON schema definition.
Event Fields
email
: Sender email addresscustomer_handle
: the account ID that you can find in the upper-right corner of the MailChannels Consoletimestamp
: Unix timestamp of the eventevent
: Event type, such asdelivered
orhard-bounced
(see Supported Event Types below)request_id
: A unique identifier generated to track the original HTTP request
The
customer_handle
is set so that you can have a single webhook receiver that receives webhooks for multiple MailChannels accounts. For instance, if your account ID isexampleuser
then thecustomer_handle
field will be set toexampleuser
for webhooks related to emails sent by that MailChannels account.
To improve your webhook security, we highly recommend verifying that the customer_handle
value matches your account ID.
To find your account ID, go to the upper-right corner of the MailChannels Console
Event fields may vary depending on the event type. For details, see Supported Event Types below.
Retrieving Webhook Configuration
To view your current webhook configuration:
curl -X GET 'https://api.mailchannels.net/tx/v1/webhook' \
-H 'X-Api-Key: YOUR_API_KEY'
Deleting a Webhook
To stop receiving event notifications:
curl -X DELETE 'https://api.mailchannels.net/tx/v1/webhook' \
-H 'X-Api-Key: YOUR_API_KEY'
Supported Event Types
Event Type | Description |
---|---|
processed | System received and began processing email for delivery |
delivered | Recipient's server accepted the email |
dropped | System encountered an error when processing the email |
unsubscribed | Recipient clicked the unsubscribe link in the email |
hard-bounced | Recipient's server rejected the email |
open* | Recipient opened the email |
click* | Recipient clicked a link in the email |
complained* | Recipient filed a spam complaint about the email |
open
and click
events require tracking to be enabled, which is not available in our free tier.
complained
is reserved for future use.
Hard-bounced Event
We monitor email traffic and deliver a hard-bounced event for each message with unreachable recipients, adding those recipients to your suppression list. Such recipients can be retrieved via the GET /suppression-list endpoint.
However, in certain cases, we are unable to deliver a hard-bounced event:
- Some SMTP servers do not specify which recipients are rejected. If only some recipients reject the message and we can't identify them, no hard-bounce event will be delivered.
- If the recipient's SMTP server rejects the message before we begin sending the message content, we cannot associate the failure with your account, so no hard-bounced event will be delivered.
Fields for hard-bounced events
email
: Sender email address.customer_handle
: Your account ID.timestamp
: Unix timestamp of the event.event
: The type of event,hard-bounced
in this case.recipients
: List of recipient email addresses that reject the message.status
: The final SMTP status code received during the delivery attempt. This is usually the code that causes the bounce. This may be a successful (2xx) code if the message is delivered to some recipients but rejected by others.reason
(optional): A human-readable explanation of why the message bounces. This may be blank if the message is rejected by some recipients but delivered to others.request_id
(optional): A unique identifier generated to track the original HTTP request. This will be blank if the message is sent via SMTP instead of the API, or if it bounces before headers are processed.smtp_id
(optional): A unique identifier used to track the message, matching theMessage-Id
header. This will be blank if the message bounces before headers are processed.