Webhooks
Receive real-time notifications about email events in your application. Configure webhooks to get instant updates about deliveries, opens, clicks, bounces, and more.
Supported Event Types
Instant notifications
Signed payloads
On this page
Overview
Webhooks allow your application to receive real-time notifications about email events. Instead of polling our API, we'll send HTTP POST requests to your specified endpoint whenever events occur.
Benefits
- • Real-time event notifications
- • Reduced API calls and improved performance
- • Automatic retry mechanism for failed deliveries
- • Secure payload signing for verification
Quick Start
Adding & Configuring Webhooks
1. Access Webhook Management
Navigate to your workspace settings to manage webhooks:
Workspaces → Workspace Settings → Manage WebhooksTo receive events from every workspace in your organization at one endpoint, use Settings → Global Email Webhook instead.
2. Create a New Webhook
In the webhook management interface, you can:
- • Click "Create Webhook" to add a new endpoint
- • Enter your webhook URL. It must use HTTPS, so events stay encrypted in transit. Webhooks created with an http:// URL before this was required keep working, but a new or changed URL must start with https://
- • Select specific event types or leave empty for all events
- • Choose the webhook format: Laneful (default), or Mailgun- or SendGrid-compatible for an easy migration (see Webhook Formats)
- • Copy the generated HMAC secret for signature verification. For webhooks created through the Organization API, the secret is in the
signing_secretfield of the create response and from Get a webhook's signing secret; other webhook responses leave it out - • Choose batch mode (on by default; events are sent as arrays) or disable it to receive one event per request
3. Webhook Configuration Options
Event Filtering
You can configure webhooks to receive specific event types:
- • All Events: Leave event types empty to receive all webhook events
- • Specific Events: Select only the event types you need (Delivery, Bounce, Open, Click, etc.). When you create a webhook through the Organization API,
event_typestakes the event values listed under Event Types (request,delivery,open,click,drop,spam_complaint,unsubscribe,bounce). Matching is exact, so any other value never matches an event - • Multiple Webhooks: Create different webhooks for different event types
4. Batch Mode Configuration
Payload Format Options
Configure how webhook events are delivered:
- • Batch Mode Enabled: Events are sent as an array for improved performance and reduced requests. Each request carries up to 1000 events (about 1 MB), and Laneful sends events as soon as they're ready instead of waiting to fill a batch, so a batch may hold a single event
- • Batch Mode Disabled: Each event is sent individually as a single object
- • Recommendation: Use batch mode for high-volume applications to reduce webhook calls
Webhook Structure
Payload Format
Webhook payload format depends on the batch_mode setting configured for your webhook. The examples on this page use the default Laneful format (see Webhook Formats for Mailgun and SendGrid):
Batch Mode: EnabledArray of Events
When batch mode is enabled, events are sent as an array for improved performance:
[
{
"id": "019844e3a1b27c3d8e4f5a6b7c8d9e0f",
"event": "delivery",
"email": "user@example.com",
"message_id": "H-0-019844e340027d728a7cfda632e14d0a-1234",
"lane_id": "5805dd85-ed8c-44db-91a7-1d53a41c86a5",
"tag": "newsletter-campaign",
"timestamp": 1753502407,
"metadata": {
"campaign_id": "camp_456",
"user_id": "user_123"
},
"mx_host": "gmail-smtp-in.l.google.com",
"queue_time_sec": 1
},
{
"id": "8f14e45f-ceea-4e7a-b1c2-6d3f9a0b2c71",
"event": "open",
"email": "user@example.com",
"message_id": "H-0-019844e340027d728a7cfda632e14d0a-1234",
"lane_id": "5805dd85-ed8c-44db-91a7-1d53a41c86a5",
"tag": "newsletter-campaign",
"timestamp": 1753502407,
"metadata": {
"campaign_id": "camp_456",
"user_id": "user_123"
},
"referer": "",
"client_name": "Chrome",
"client_os": "Windows",
"client_ip": "203.0.113.10",
"client_device": ""
}
]Batch Mode: DisabledSingle Event Object
When batch mode is disabled, each event is sent individually as a single object:
{
"id": "019844e3a1b27c3d8e4f5a6b7c8d9e0f",
"event": "delivery",
"email": "user@example.com",
"message_id": "H-0-019844e340027d728a7cfda632e14d0a-1234",
"lane_id": "5805dd85-ed8c-44db-91a7-1d53a41c86a5",
"tag": "newsletter-campaign",
"timestamp": 1753502407,
"metadata": {
"campaign_id": "camp_456",
"user_id": "user_123"
},
"mx_host": "gmail-smtp-in.l.google.com",
"queue_time_sec": 1
}Configuration
You can configure the batch mode setting when creating or editing webhooks in your dashboard: Workspaces → Workspace Settings → Manage Webhooks
Event Types
The event field indicates the type of email event. Click on any event type below to see its payload structure:
Build your endpoint to skip event values and fields it doesn't recognize, so it keeps working as Laneful adds new data.
Payload Fields
Fields included in every event:
| Field | Type | Description |
|---|---|---|
| id | string | Unique ID of the event. The same event keeps the same id on every retry and in batch and single mode; a message's delivery, open and click events have different IDs. Use it to discard duplicates. |
| event | string | One of the event values listed above. |
| string | Recipient address. | |
| message_id | string | Laneful message ID, the same value the send API returns in message_ids when return_message_ids is true. The delivered email's Message-ID header is <message_id@laneful-host>. Empty when a bounce or complaint can't be matched to a message. |
| lane_id | string | UUID of the lane that handled the message. Empty on request and drop events and when no lane was involved. |
| tag | string | The email's tag, or empty when none was set. Always empty on request events. |
| timestamp | integer | Unix time in seconds when the event was generated. |
| metadata | object | The webhook_data sent with the email, unchanged (string keys and values), on every event type. {} when none was sent. request events for emails sent over SMTP always carry {}. |
| mx_host | string or null | A mail exchanger (MX) host of the recipient's domain, when known. Not included in open, click and most unsubscribe events. |
Event-specific fields:
| Event | Fields |
|---|---|
| request | None. |
| delivery | queue_time_sec (integer): seconds from when Laneful accepted the email (or from its send_time, if scheduled) until delivery, including time spent on retries; relay (boolean): present, set to true, only when the message was delivered through a relay lane. |
| open | referer, client_name (browser or mail client name), client_os, client_ip, client_device (strings, possibly empty); is_machine (boolean, present only when true: the request most likely came from an automated proxy, such as a mail privacy proxy, rather than the recipient). |
| click | url (string), plus the same client fields as open. |
| drop | reason (string): suppressed, invalid X-Laneful-API header, SMTP loop or unknown. |
| spam_complaint | feedback_type (integer: 0 unspecified, 1 abuse, 2 auth_failure, 3 fraud, 4 not_spam, 5 other, 6 virus), feedback_type_text (the same value as a string), received_unix_timestamp (integer, Unix seconds). |
| unsubscribe | unsubscribe_group_id (integer): the unsubscribe group, or 0 for a global unsubscribe. |
| bounce | code and extended_code (strings, the SMTP reply and enhanced status codes), text (string, the server's reply), is_hard (boolean, true for a permanent failure), deliverability_issue (boolean, true when the cause is on the sending side, such as authentication, content or reputation, rather than the recipient address), classification (string: Unclassified, Invalid Address, Technical, Content, Reputation, Frequency/Volume, Mailbox Unavailable or Domain Throttled). |
Bounces, deferrals and final failures
- • Deferrals are reported too: each temporary delivery failure is sent as a
bouncewithis_hard: false, one per failed attempt, while Laneful keeps retrying for up to 72 hours (see Retry Policy). - • A permanent failure is a
bouncewithis_hard: true. A hard bounce withdeliverability_issue: falsenormally adds the address to the suppression list, and later sends to it producedropevents. - • When retries run out after 72 hours, the final event is a
bouncewithis_hard: true,code550andextended_code5.7.520. On relay lanes it is adropinstead. - • Bounces reported through relay lanes always have
is_hard: false.
Webhook Formats
Pick the payload format that fits your stack (transformation_type in the Organization API), including Mailgun- and SendGrid-compatible formats that make migrating existing webhook consumers easy. Batching and signing work the same way in all formats.
- • Laneful (
laneful, the default): the payloads shown on this page. - • Mailgun (
mailgun): each event is an object with anevent-datakey containingevent,id,timestamp,recipient,recipient-domain,recipient-provideranduser-variables(the email'swebhook_data). Request, delivery, bounce, drop and spam complaint events also carrydelivery-statuswithmx-host; bounces addmessage,code,enhanced-codeandbounce_type, and drops addmessage. Drops and hard bounces without a deliverability issue also carryreasonandseverity. Event names: request → accepted, delivery → delivered, bounce and drop → failed, open → opened, click → clicked, unsubscribe → unsubscribed, spam_complaint → complained. Mailgun-format events carry nomessage_idor clickurl. Requests are signed with theX-Webhook-Signatureheader rather than a Mailgunsignatureobject. - • SendGrid (
sendgrid): each event is a flat object withevent,email,timestamp,sg_message_id(the Lanefulmessage_id) andsg_event_id(the eventid). The email'swebhook_datakeys are added at the top level; on a name clash the Laneful field wins. Event names: delivery → delivered, drop → dropped, spam_complaint → spamreport; open, click, bounce and unsubscribe keep their names. Opens addip,useragentandsg_machine_open; clicks addurl,ipanduseragent; bounces addclassification,reason,statusandtype; drops addreason; unsubscribes addasm_group_id.requestevents arrive in the Laneful format. Requests are signed withX-Webhook-Signaturerather than SendGrid's signature headers.
Webhooks created in the dashboard use the format chosen in the form (Laneful by default).
Security
Webhook Signature Verification
All webhook payloads are signed with your webhook secret. Verify the signature to ensure the request is from Laneful.
- • Header:
X-Webhook-Signature - • Value: the HMAC-SHA256 of the raw request body, keyed with the webhook secret exactly as shown in the dashboard or returned by the Organization API, as 64 lowercase hex characters with no prefix
- • Signed bytes: the exact request body, in every format and in both batch and single mode. Compute the HMAC over the bytes you received, before parsing them; re-encoding parsed JSON (for example with
JSON.stringify(req.body)) produces different bytes and fails verification - • Pair the signature check with the event
id: skipping IDs you have already processed also protects you from replayed requests (signatures carry no timestamp)
const crypto = require('crypto');
// rawBody: the request body as a Buffer, before JSON parsing
function verifySignature(rawBody, signature, secret) {
if (!secret || typeof signature !== 'string' || !/^[0-9a-f]{64}$/i.test(signature)) {
return false;
}
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(rawBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature, 'hex'),
Buffer.from(expectedSignature, 'hex')
);
}Security Best Practices
- • Always verify webhook signatures
- • Use HTTPS endpoints only
- • Deduplicate on the event
idto handle retried or replayed events - • Store webhook secrets securely
- • Implement rate limiting on your webhook endpoints
Testing
Test Your Webhook
1. Use ngrok for local testing
# Install ngrok (https://ngrok.com/download), then # expose your local server ngrok http 3000 # Use the HTTPS forwarding URL that ngrok prints, plus your # endpoint path, in your webhook configuration, for example # https://<your-ngrok-subdomain>/webhooks/laneful
2. Send test events
In Manage Webhooks, open the webhook's History and Testing page and use the Test webhook section to send a sample event to your endpoint.
3. Monitor webhook activity
The same page shows a 24-hour activity timeline, hour by hour: deliveries that succeeded, recovered after errors or failed, with the error details.
Implement Your Webhook Endpoint
1. Create a webhook endpoint
Create an endpoint in your application to receive webhook events:
// Express.js example, using verifySignature from the Security section
const express = require('express');
const app = express();
// express.raw keeps req.body as the exact bytes Laneful signed. A batch can
// reach about 1 MB, above express.raw's 100 KB default limit
app.post(
'/webhooks/laneful',
express.raw({ type: 'application/json', limit: '2mb' }),
(req, res) => {
const signature = req.get('x-webhook-signature');
if (!verifySignature(req.body, signature, process.env.WEBHOOK_SECRET)) {
return res.status(401).send('Unauthorized');
}
// Parse only after the signature check passes.
// Batch mode sends an array; single mode sends one object.
const payload = JSON.parse(req.body.toString('utf8'));
const events = Array.isArray(payload) ? payload : [payload];
for (const event of events) {
// Skip event.id values you have already processed,
// then handle the event by event.event
}
res.status(200).send('OK');
}
);2. Configure webhook in dashboard
Use the webhook management interface to configure your endpoint:
Workspaces → Workspace Settings → Manage Webhooks → Create WebhookEnter your endpoint URL, select event types (optional), and save your webhook configuration.
Troubleshooting
Common Issues
Webhook not receiving events
- • Verify your webhook URL is accessible from the internet
- • Check that your endpoint returns a 2xx status code within 30 seconds
- • Ensure your server can handle POST requests
- • Configure the final URL: on a 301, 302 or 303 redirect the request is repeated as a GET without a body
- • Check the webhook's History and Testing page in the dashboard for error details
Signature verification failing
- • Ensure you're using the correct webhook secret
- • Verify the payload is being read as raw bytes
- • Check that the signature header is being read correctly
- • Use timing-safe comparison for signature validation
Duplicate events
- • Deduplicate on the event's
id, which stays the same when an event is retried - • Store processed event IDs to avoid reprocessing
- • Return 200 status even for duplicate events
Retry Mechanism
If your webhook endpoint returns a non-2xx status code (4xx included) or doesn't respond within 30 seconds, we'll retry the delivery with exponential backoff:
Times count from when the event was created. Each retry makes up to three quick attempts, and intervals vary by ±20% so retries don't arrive in bursts. After 24 hours an undelivered event is no longer retried; your webhook stays active and keeps receiving new events. In batch mode, the quick follow-ups resend the whole batch; later retries may group events into different batches.