Skip to content

Webhooks

Subscribe to real-time event notifications. TopMail sends HTTP POST requests to your endpoint whenever subscribed events occur, with HMAC signature verification for security.

Event Types

EventDescription
contact.createdA new contact was created
contact.updatedA contact was updated
contact.subscribedA contact subscribed to a list
contact.unsubscribedA contact unsubscribed from a list
campaign.sentA campaign started sending
campaign.completedA campaign finished sending
email.sentAn individual email was sent
email.deliveredAn email was delivered
email.openedAn email was opened
email.clickedA link in an email was clicked
email.bouncedAn email bounced
email.complainedA recipient marked an email as spam
flow.triggeredA flow automation was triggered
flow.completedA flow automation completed
form.submittedA form was submitted
conversion.createdA conversion was tracked
list.member_addedA contact was added to a list
list.member_removedA contact was removed from a list

Subscribe to Events

POST
/webhooks/triggers

Create a webhook subscription for a specific event type

NameTypeRequiredDescription
targetUrlstringRequiredThe URL that will receive webhook POST requests
eventstringRequiredThe event type to subscribe to (see event types above)
curl -X POST https://api.topmail.so/api/v1/webhooks/triggers \
-H "Authorization: Bearer tm_live_abc123" \
-H "Content-Type: application/json" \
-d '{
"targetUrl": "https://yourapp.com/webhooks/topmail",
"event": "email.delivered"
}'
{
"data": {
"id": "webhook-uuid-12345",
"event": "email.delivered",
"targetUrl": "https://yourapp.com/webhooks/topmail",
"createdAt": "2025-01-15T08:30:00.000Z"
}
}

Unsubscribe

DELETE
/webhooks/triggers?id=:webhookId

Remove a webhook subscription

NameTypeRequiredDescription
idstringRequiredThe webhook subscription ID (query parameter)
curl -X DELETE "https://api.topmail.so/api/v1/webhooks/triggers?id=webhook-uuid-12345" \
-H "Authorization: Bearer tm_live_abc123"
{
"data": {
"success": true
}
}

Test Webhook

POST
/webhooks/:id/test

Send a test event to verify your webhook endpoint is working

NameTypeRequiredDescription
idstringRequiredThe webhook subscription ID (URL parameter)
curl -X POST https://api.topmail.so/api/v1/webhooks/webhook-uuid-12345/test \
-H "Authorization: Bearer tm_live_abc123"
{
"data": {
"success": true,
"status_code": 200,
"response_time_ms": 145
}
}

Signature Verification

Every webhook request includes a signature in the X-TopMail-Signature header. You should verify this signature to ensure the request is authentic and has not been tampered with.

Headers

HeaderDescription
X-TopMail-SignatureHMAC-SHA256 signature: t=<timestamp>,v1=<hash>
X-TopMail-EventThe event type (e.g., email.delivered)
X-TopMail-Delivery-IdUnique delivery ID for deduplication
X-TopMail-Webhook-IdYour webhook subscription ID

Verification Example

# The signature is computed as:
# HMAC-SHA256(secret, "<timestamp>.<json_body>")
#
# Parse the X-TopMail-Signature header:
# t=1705312200,v1=a1b2c3d4e5f6...
#
# Verify: recompute the HMAC and compare with v1 value

Webhook Payload Format

Webhook payloads are JSON objects with three fields:event (the event type),timestamp (ISO 8601), and data (event-specific payload).

Developer Docs - TopMail