Webhooks

Verify incoming webhook payloads from Lystica and handle events in real-time.

Event types

contact.created

Triggered when a new contact is added

contact.updated

Triggered when contact data is modified

email.delivered

Triggered when an email is delivered

email.bounced

Triggered when an email bounces

Verifying signatures

Use the Webhooks class with your signing secret to verify that incoming requests are from Lystica. Pass the raw body, signature header, and timestamp header.

import { Webhooks } from "lystica-cloud";

const webhooks = new Webhooks("whsec_your_signing_secret");

// In your webhook handler (e.g. Express):
app.post("/webhooks/lystica", async (req, res) => {
  try {
    const event = await webhooks.verify(
      req.body,                             // raw body string
      req.headers["x-lystica-signature"],   // signature header
      req.headers["x-lystica-timestamp"],    // timestamp header
    );

    switch (event.type) {
      case "contact.created":
        console.log("New contact:", event.data);
        break;
      case "email.delivered":
        console.log("Email delivered:", event.data);
        break;
    }

    res.status(200).send("ok");
  } catch (err) {
    res.status(400).send("Invalid signature");
  }
});

We use cookies

We use cookies to enhance your experience, analyze site usage, and assist in our marketing efforts. You can manage your preferences or learn more in our Cookie Policy.