Webhooks
Receive events as they happen, so your system always knows what became of each message. Verify every request with its signature.
How webhooks work
Register an HTTPS endpoint in the dashboard and choose the events it should receive. When something happens to a message, MigoSMTP sends a POST request with a JSON body to your endpoint.
Event types
Subscribe only to the events your system needs. Each event carries the message id, the recipient and a timestamp, so you can match it to the message you sent.
Example payload
Payloads are JSON sent with a POST request. The values here are examples only.
{
"event": "delivered",
"message_id": "msg_123",
"recipient": "[email protected]",
"timestamp": "2026-01-15T10:30:00Z"
}Verify the signature
Anyone who knows your URL could post to it, so check every request. Compute an HMAC of the raw request body with your signing secret and compare it with the value in the signature header using a constant-time comparison. Reject requests that do not match. The header name and algorithm are shown with your signing secret in the dashboard.
const crypto = require("crypto");
function valid(rawBody, received, secret) {
const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
const a = Buffer.from(expected), b = Buffer.from(received);
return a.length === b.length && crypto.timingSafeEqual(a, b);
}Respond quickly
Return a 2xx status as soon as you have stored the event, and do the real work afterwards in a queue. A slow or failing endpoint causes retries and can delay your other events.
Expect duplicates and gaps in order
Failed deliveries are retried, so the same event can arrive more than once, and events can arrive out of order. Use the message id and event type to make your handler idempotent, and use the event timestamp rather than arrival time.
Test before you rely on it
Point the endpoint at a request inspector or a tunnel to your development machine, send a test message, and confirm that you can verify the signature on real traffic.