Email Webhooks

WebHooks

WebHook is a mechanism of receiving notifications about certain events. To add a webhook go to "Account settings" → "API".

749

Specify a URL send notifications to and select events you would like to be notified about.

570

List of events triggering the webhook in the Email service:

Marked as spam
Email opened
Click-through
New subscriber
Email address deleted from the mailing list
Subscriber opted-out
Campaign status changed
When a webhook is triggered, data is sent to the specified URL:

Data type: JSON
Request type: POST
The data is sent every minute or when the event count reaches 100.

Main data format for a request:

[
{
"event": "event_name",
"timestamp": 1490954061,
"recipient": "[email protected]",
"sender": "[email protected]",
"subject": "hello world"
}
]

In a case when there are several events, they will be grouped in one or several requests

[
{
"timestamp": 1496827422,
"event": "delete",
"book_id": "490686",
"email": "[email protected]"
},
{
"timestamp": 1496827422,
"event": "delete",
"book_id": "490686",
"email": "[email protected]"
},
{
"timestamp": "1496827625",
"variables": [],
"email": "[email protected]",
"source": "address book",
"book_id": "490686",
"event": "new_emails"
}
]
Examples of requests for each event:

Marked as spam

[
{
"timestamp": 1496827422,
"event": "spam",
"task_id": 3668141,
"email": "[email protected]"
}
]

Email opened

[
{
"task_id": 3668141,
"timestamp": "1496827941",
"open_device": "Desktop",
"open_platform": "Windows",
"browser_ver": "11.0",
"browser_name": "Firefox",
"email": "[email protected]",
"event": "open"
}
]
Link clicked

[
{
"link_url": http://google.com,
"task_id": 3668141,
"timestamp": "1496828000",
"open_device": "Desktop",
"open_platform": "Linux",
"browser_ver": "58.0.3029.110",
"browser_name": "Chrome",
"link_id": 71741389,
"email": "[email protected]",
"event": "redirect"
}
]
Client opted-out

[
{
"task_id": "3668141",
"timestamp": "1496827872",
"from_all": 1,
"email": "[email protected]",
"reason": null,
"book_id": 490686,
"event": "unsubscribe",
"categories": ""
}
]
New subscriber

[
{
"timestamp": "1496827625",
"variables": [],
"email": "[email protected]",
"source": "address book",
"book_id": "490686",
"event": "new_emails"
},
{
"timestamp": "1496827625",
"variables": [],
"email": "[email protected]",
"source": "subscription form",
"book_id": "490686",
"event": "new_emails"
}
]
Removing from an email list

[
{
"timestamp": 1496827422,
"event": "delete",
"book_id": "490686",
"email": "[email protected]"
}
]
Changing email campaign status

[
{
"status": "approve",
"status_explain": "Approved and will be sent",
"task_id": 3668138,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
{
"status": "approve_part",
"status_explain": "Approved and will be sent by parts",
"task_id": 3668139,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
{
"status": "only_active",
"status_explain": "Will be sent only to active adresses",
"task_id": 3668140,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
{
"status": "confirm_addresses",
"status_explain": "Rejected: confirm the mailing list",
"task_id": 3668142,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
{
"status": "need_edit",
"status_explain": "Rejected: edit the email body",
"task_id": 3668143,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
{
"status": "rejected",
"status_explain": "Campaign rejected",
"task_id": 3668144,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
{
"status": "on_moderation",
"status_explain": "Campaign is on moderation",
"task_id": 3668145,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
{
"status": "sending",
"status_explain": "Campaign is in the sending queue",
"task_id": 3668146,
"timestamp": 1496827843,
"book_id": "490686",
"event": "task_status_update"
},
]

Example of the script that processes a webhook in PHP