Skip to navigation

WebHook

View as Markdown

🇬🇧 English

Overview

BizMail automatically pushes real-time email delivery events to your webhook URL configured in the BizMail Portal.

When an email changes status (delivered, bounced, dropped), BizMail sends an HTTP POST request to your endpoint with a JSON payload describing the event.


Configuration

Configure your webhook URL and which events to receive in the BizMail Portal under your account settings. You can register separate webhook URLs per event type.


Events

EventDescription
deliveredEmail was successfully delivered to the recipient’s inbox
bouncedEmail bounced — can be hard bounce (invalid address) or soft bounce (temporary server rejection)
droppedEmail was dropped by the server

Payload Structure

BizMail sends different payload shapes depending on the event type.


Event: delivered

Triggered when an email is successfully delivered.

{
"event": "delivered",
"id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn",
"recipient": "user@example.com",
"time": 1713100000,
"mxHostname": "mx.example.com",
"response": "250 OK"
}
FieldTypeDescription
eventstringAlways delivered
idstringmessage_id of the original email
recipientstringRecipient email address
timeintegerDelivery timestamp (Unix ms)
mxHostnamestringMX server that accepted the email
responsestringSMTP response from the receiving server

Event: bounced

Triggered when an email bounces. Includes a category field to distinguish hard and soft bounce.

{
"event": "bounce",
"id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn",
"to": "user@example.com",
"time": 1713100000,
"response": "550 5.1.1 The email account does not exist",
"category": "hard_bounce",
"user": "",
"seq": "",
"returnPath": ""
}
FieldTypeDescription
eventstringAlways bounce
idstringmessage_id of the original email
tostringRecipient email address
timeintegerEvent timestamp (Unix ms)
responsestringSMTP error response
categorystringhard_bounce (permanent, e.g. invalid address) or soft_bounce (temporary, e.g. mailbox full)
userstringReserved
seqstringReserved
returnPathstringReturn path header

Category values:

ValueTrigger conditionDescription
hard_bounceREJECTEDPermanent failure — invalid address or domain
soft_bounceDEFERREDTemporary failure — server busy or mailbox full

Event: dropped

Triggered when an email is dropped (suppressed before sending).

{
"action": "drop",
"id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn",
"recipient": "user@example.com",
"reason": "Suppressed address",
"user": "",
"seq": ""
}
FieldTypeDescription
actionstringAlways drop
idstringmessage_id of the original email
recipientstringRecipient email address
reasonstringReason the email was dropped
userstringReserved
seqstringReserved

Webhook Request Details

BizMail sends events as HTTP POST requests to your configured URL.

Headers:

Content-Type: application/json

Your endpoint must respond with HTTP 2xx to acknowledge receipt. If your endpoint does not respond or returns a non-2xx status, BizMail may retry the delivery.


Example Receiver (PHP)

$payload = file_get_contents('php://input');
$data = json_decode($payload, true);
switch ($data['event'] ?? $data['action'] ?? '') {
case 'delivered':
// handle delivered
break;
case 'bounce':
$category = $data['category']; // hard_bounce or soft_bounce
// handle bounce
break;
case 'drop':
// handle dropped
break;
}
http_response_code(200);

Example Receiver (Node.js / Express)

app.post('/webhook/bizmail', (req, res) => {
const data = req.body;
const event = data.event || data.action;
switch (event) {
case 'delivered':
// handle delivered
break;
case 'bounce':
const category = data.category; // hard_bounce or soft_bounce
// handle bounce
break;
case 'drop':
// handle dropped
break;
}
res.sendStatus(200);
});


🇻🇳 Tiếng Việt

Tổng quan

BizMail tự động đẩy các sự kiện tracking email theo thời gian thực đến webhook URL được cấu hình trong BizMail Portal.

Khi email thay đổi trạng thái (delivered, bounced, dropped), BizMail gửi HTTP POST request đến endpoint của bạn kèm JSON payload mô tả sự kiện.


Cấu hình

Cấu hình webhook URL và các sự kiện cần nhận trong BizMail Portal tại phần cài đặt tài khoản. Bạn có thể đăng ký webhook URL riêng cho từng loại sự kiện.


Các sự kiện

Sự kiệnMô tả
deliveredEmail đã được gửi thành công vào hộp thư của người nhận
bouncedEmail bị bounce — có thể là hard bounce (địa chỉ không tồn tại) hoặc soft bounce (server từ chối tạm thời)
droppedEmail bị hủy trước khi gửi

Cấu trúc Payload

BizMail gửi payload có cấu trúc khác nhau tùy theo loại sự kiện.


Sự kiện: delivered

Kích hoạt khi email được gửi thành công.

{
"event": "delivered",
"id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn",
"recipient": "user@example.com",
"time": 1713100000,
"mxHostname": "mx.example.com",
"response": "250 OK"
}
TrườngKiểuMô tả
eventstringLuôn là delivered
idstringmessage_id của email gốc
recipientstringĐịa chỉ email người nhận
timeintegerTimestamp gửi thành công (Unix ms)
mxHostnamestringMX server đã nhận email
responsestringPhản hồi SMTP từ server nhận

Sự kiện: bounced

Kích hoạt khi email bị bounce. Có trường category phân biệt hard/soft bounce.

{
"event": "bounce",
"id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn",
"to": "user@example.com",
"time": 1713100000,
"response": "550 5.1.1 The email account does not exist",
"category": "hard_bounce",
"user": "",
"seq": "",
"returnPath": ""
}
TrườngKiểuMô tả
eventstringLuôn là bounce
idstringmessage_id của email gốc
tostringĐịa chỉ email người nhận
timeintegerTimestamp sự kiện (Unix ms)
responsestringThông báo lỗi SMTP
categorystringhard_bounce (lỗi vĩnh viễn) hoặc soft_bounce (lỗi tạm thời)
userstringDự phòng
seqstringDự phòng
returnPathstringHeader return path

Giá trị category:

Giá trịĐiều kiệnMô tả
hard_bounceREJECTEDLỗi vĩnh viễn — địa chỉ hoặc domain không tồn tại
soft_bounceDEFERREDLỗi tạm thời — server bận hoặc hộp thư đầy

Sự kiện: dropped

Kích hoạt khi email bị hủy (bị chặn trước khi gửi).

{
"action": "drop",
"id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn",
"recipient": "user@example.com",
"reason": "Suppressed address",
"user": "",
"seq": ""
}
TrườngKiểuMô tả
actionstringLuôn là drop
idstringmessage_id của email gốc
recipientstringĐịa chỉ email người nhận
reasonstringLý do email bị hủy
userstringDự phòng
seqstringDự phòng

Chi tiết Webhook Request

BizMail gửi sự kiện qua HTTP POST đến URL đã cấu hình.

Headers:

Content-Type: application/json

Endpoint của bạn phải trả về HTTP 2xx để xác nhận nhận được. Nếu không phản hồi hoặc trả về non-2xx, BizMail có thể thử gửi lại.


Ví dụ nhận webhook (PHP)

$payload = file_get_contents('php://input');
$data = json_decode($payload, true);
switch ($data['event'] ?? $data['action'] ?? '') {
case 'delivered':
// xử lý delivered
break;
case 'bounce':
$category = $data['category']; // hard_bounce hoặc soft_bounce
// xử lý bounce
break;
case 'drop':
// xử lý dropped
break;
}
http_response_code(200);

Ví dụ nhận webhook (Node.js / Express)

app.post('/webhook/bizmail', (req, res) => {
const data = req.body;
const event = data.event || data.action;
switch (event) {
case 'delivered':
// xử lý delivered
break;
case 'bounce':
const category = data.category; // hard_bounce hoặc soft_bounce
// xử lý bounce
break;
case 'drop':
// xử lý dropped
break;
}
res.sendStatus(200);
});

Request

This endpoint expects a multipart form.

Response headers

x-powered-bystringOptional
etagstringOptional
front-end-httpsstringOptional
strict-transport-securitystringOptional

Response

OK
codeinteger
statusstring
message_idstringformat: "email"

Errors

400
Bad Request Error