Guides

Webhooks

Receive signed events for every email, with automatic retries.

Webhooks send an HTTPS POST to your endpoint whenever something happens to an email.

Add an endpoint

Create an endpoint in the dashboard or with POST /webhooks, then choose the events it should receive.

Events

EventWhen
email.sentAccepted by Amazon SES.
email.deliveredDelivered to the recipient mail server.
email.bouncedRejected by the recipient.
email.complainedMarked as spam.
email.openedOpened, when open tracking is on.
email.clickedA link was clicked, when click tracking is on.
email.failedCould not be sent.
email.delivery_delayedDelivery is delayed and still retrying.
email.receivedA message arrived on an inbound route.
domain.updatedA domain changed verification status.
contact.created, contact.updated, contact.deletedA contact changed.

Verify the signature

Every request carries three headers: nusend-id, nusend-timestamp and nusend-signature. The signature is a hex HMAC-SHA256 of id.timestamp.body using your endpoint secret. Always verify it, and reject old timestamps.

Node.js
import crypto from "node:crypto";

export function verifyWebhook(rawBody: string, headers: Record<string, string>, secret: string): boolean {
  const id = headers["nusend-id"];
  const timestamp = headers["nusend-timestamp"];
  const signature = headers["nusend-signature"];
  if (!id || !timestamp || !signature) return false;

  // Reject events older than 5 minutes
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;

  const expected = crypto
    .createHmac("sha256", secret)
    .update(`${id}.${timestamp}.${rawBody}`)
    .digest("hex");

  const a = Buffer.from(signature);
  const b = Buffer.from(expected);
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

Retries

  • Respond with any 2xx status within 10 seconds to acknowledge an event.
  • Anything else is retried with exponential backoff for up to about 24 hours.
  • An endpoint that keeps failing is disabled and the team owner is notified.
  • Every attempt is logged. You can replay a delivery from the dashboard.

Events can arrive more than once. Use the nusend-id header to ignore duplicates.