Skip to main content
WEBHOOK
When you use SendPost API to send an email, SendPost generates webhook events throughout the email lifecycle. Each webhook event contains an event object and an emailMessage object. The emailMessage object remains the same across all events for a given email, allowing you to correlate events using the messageID. For a detailed explanation of the email lifecycle and what each event type means, see Understanding Webhook Event Lifecycle.

Complete Webhook Payload Structure

Every webhook payload sent by SendPost follows this structure:

Event Object Fields

The event object contains information about the specific webhook event that occurred.

Event Types

Every event generated as SendPost webhook will have a type field in the event object:

Event Metadata Fields

The eventMetadata object contains event-specific information. Different fields are populated depending on the event type.

userAgent Object Fields

The userAgent object provides parsed browser/email client information:

os Object Fields

The os object provides parsed operating system information:

device Object Fields

The device object provides parsed hardware device information:

geo Object Fields

The geo object provides geographic location information based on IP geolocation:
Geographic data is derived from IP address lookups and may not always be 100% accurate. The precision depends on the IP geolocation database and the nature of the recipient’s network connection.

Email Message Object Fields

The emailMessage object contains information about the original email that was sent. This object remains identical across all webhook events for the same email.

from Object Fields

The from object contains sender information:

to Array Item Fields

Each item in the to array represents a recipient:

headers Object

The headers object is a key-value store for custom headers:
Custom headers you send with your email are preserved and returned in all webhook events. This allows you to track emails throughout their lifecycle using your own identifiers.

groups Array

The groups array contains classification tags:

SMTP Code and Description in Webhook Events

SMTP codes and descriptions provide detailed information about email delivery status. These fields are available in specific webhook events to help you understand delivery outcomes.

Availability by Event Type

Common SMTP Codes

Example: Delivered Event with SMTP Code

Example: HardBounced Event with SMTP Code

SMTP codes and descriptions are available in both the top-level event object and within event.eventMetadata. Both locations contain the same values for consistency and ease of access.

Example: Opened Event with Full Metadata


Example: Clicked Event with URL


Custom Headers in Webhook Payloads

Any custom headers you include in your email request are preserved and included in all webhook event payloads. This allows you to track campaigns, add custom identifiers, or pass metadata through the entire email lifecycle.

How Headers are Preserved

  • Included in All Events: Custom headers sent in your email request are included in the emailMessage.headers object in all webhook events (Processed, Dropped, Delivered, Opened, Clicked, Bounced, Unsubscribed, Spam).
  • Same Across Lifecycle: The headers remain the same across all events for a given email message, allowing you to correlate events using your custom identifiers.
  • Original Format: Headers are returned exactly as you sent them in your email request.

Example: Email Request with Custom Headers

Example: Webhook Payload with Preserved Headers

Use Cases for Custom Headers

Campaign Tracking:
Order/Transaction Tracking:
Customer Segmentation:
Custom headers are included in every webhook event for the email, allowing you to filter and process webhooks based on your custom identifiers or metadata.

Body

application/json
event
object
emailMessage
object

Response

200

Return a 200 status to indicate that the data was received successfully