Webhooks Documentation

Receive real-time notifications when email events occur. Build reactive applications that respond instantly to delivery, opens, clicks, and more.

Real-Time
Instant notifications when events occur
Secure
Signature verification for authenticity
Reliable
Automatic retries with exponential backoff

How Webhooks Work

1

Event Occurs

An email is sent, delivered, opened, or bounced.

2

We Notify You

CalimaticMail sends a POST request to your endpoint.

3

You Verify

Validate the signature to ensure authenticity.

4

You Process

Handle the event in your application.

Webhook Payload

{
  "id": "evt_1234567890",
  "type": "email.delivered",
  "timestamp": "2024-12-15T10:30:00Z",
  "data": {
    "messageId": "msg_abc123",
    "from": "[email protected]",
    "to": "[email protected]",
    "subject": "Welcome to our platform!",
    "deliveredAt": "2024-12-15T10:30:00Z",
    "metadata": {
      "campaignId": "welcome-series-1"
    }
  }
}

Payload Fields

idUnique identifier for this event
typeThe type of event that occurred
timestampISO 8601 timestamp of the event
dataEvent-specific data payload

Available Events

Email Events

email.sentEmail was successfully sent to the recipient server
email.deliveredEmail was delivered to the recipient inbox
email.openedRecipient opened the email
email.clickedRecipient clicked a link in the email
email.bouncedEmail bounced (hard or soft bounce)
email.complainedRecipient marked the email as spam

Inbox Events

message.receivedNew email received in a mailbox
message.readMessage was marked as read
message.deletedMessage was moved to trash

User Events

user.createdNew user was created in your organization
user.updatedUser details were updated
user.deletedUser was removed from the organization

Signature Verification

Every webhook request includes a signature in the X-Calimatic-Signature header. Always verify this signature to ensure the request came from CalimaticMail.

Included Headers

X-Calimatic-Signature
X-Calimatic-Timestamp
X-Calimatic-Event-Type

Verification Example (Node.js)

import crypto from 'crypto';

function verifyWebhookSignature(
  payload: string,
  signature: string,
  secret: string
): boolean {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}

// In your webhook handler:
app.post('/webhooks/calimatic', (req, res) => {
  const signature = req.headers['x-calimatic-signature'];
  const isValid = verifyWebhookSignature(
    JSON.stringify(req.body),
    signature,
    process.env.WEBHOOK_SECRET
  );

  if (!isValid) {
    return res.status(401).send('Invalid signature');
  }

  // Process the webhook...
  res.status(200).send('OK');
});

Retry Policy

If your endpoint returns a non-2xx status code or times out, we'll automatically retry the webhook with exponential backoff. After 6 failed attempts, the webhook will be marked as failed.

AttemptDelay
Attempt 1Immediate
Attempt 21 minute
Attempt 35 minutes
Attempt 430 minutes
Attempt 52 hours
Attempt 68 hours

Successful Response

Return a 2xx status code within 30 seconds to acknowledge receipt.

Timeout

Requests timeout after 30 seconds. Process asynchronously for long operations.

Failed Webhook

After 6 retries, check the webhook logs in your dashboard to investigate.

Best Practices

Respond Quickly

Return a 200 response immediately, then process the webhook asynchronously. This prevents timeouts and unnecessary retries.

Handle Duplicates

Use the event ID for idempotency. The same event may be delivered multiple times due to retries or network issues.

Verify Signatures

Always validate the webhook signature before processing. Never trust the payload without verification.

Use HTTPS

Always use HTTPS endpoints. We do not send webhooks to HTTP endpoints for security reasons.

Ready to Get Started?

Configure your webhook endpoints from the dashboard and start receiving real-time email event notifications.