Nilovon Connect
SDK

Webhooks

Receive real-time delivery notifications via webhooks.

Webhooks push delivery events to your server as they happen — no polling needed.

Register a webhook

const webhook = await connect.webhook.create({
  url: "https://yourapp.com/webhooks/connect",
  secret: "whsec_your-secret-here",
  events: ["message.sent", "message.delivered", "message.failed", "message.bounced"],
  description: "Production webhook",
});

Available events

EventFired when
message.sentMessage handed off to the provider
message.deliveredMessage confirmed delivered
message.failedDelivery attempt failed
message.bouncedRecipient address bounced
message.rejectedMessage rejected by the provider

Verify signatures

Every webhook request includes an X-Webhook-Signature header with an HMAC-SHA256 signature. Always verify it before processing the payload:

webhook-handler.ts
import crypto from "node:crypto";

function verifyWebhookSignature(
  body: string,
  signature: string,
  secret: string,
): boolean {
  const expected = `sha256=${crypto
    .createHmac("sha256", secret)
    .update(body)
    .digest("hex")}`;
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected),
  );
}

Webhook payload

{
  "type": "message.delivered",
  "timestamp": "2025-01-15T10:30:00.000Z",
  "data": {
    "id": "msg_...",
    "channelType": "email",
    "to": "user@example.com",
    "status": "delivered"
  }
}

Test a webhook

Send a test event to verify your endpoint is working:

await connect.webhook.test({ id: "wh_..." });

This sends a webhook.test event to the webhook URL with a signed payload.

List webhook events

Inspect the delivery log for a specific webhook:

const { items } = await connect.webhook.listEvents({
  webhookId: "wh_...",
  limit: 20,
  offset: 0,
});

Each event includes status, attempts, responseStatus, and responseBody so you can debug failures.

Manage webhooks

// Update
await connect.webhook.update({
  id: "wh_...",
  events: ["message.delivered", "message.failed"],
});

// Disable
await connect.webhook.delete({ id: "wh_..." });

On this page