Help / Account

Webhooks

Send new subscribers, unsubscribes, clicks and sends to Zapier, Make, n8n or your own code.

Adding a webhook

A webhook sends an address of yours a message each time something happens in MailStamp, like a new subscriber or a click. Zapier, Make, n8n and your own code can then act on it: add the subscriber to your CRM, post in Slack, start a workflow.

  1. Get an address to send to. In Zapier, start a Zap with Webhooks by Zapier and Catch Hook; in Make, a Custom webhook; in n8n, a Webhook node set to POST.
  2. On the Webhooks page, click New, paste the address and pick the events. With more than one newsletter, you can pick one, or keep all of them.
  3. Copy the signing secret: it's shown once. Your code uses it to check that a message came from MailStamp.
  4. On the webhook's page, click Send test. Zapier and Make learn the message's fields from it.
A webhook's page: its address, the events it gets, Send test, and its recent messages, each delivered.
A webhook and its messages

An account has up to 10 webhooks. Webhooks need a paid plan. The address has to start with https://, and can't point at a private network. You can also manage webhooks from the API and AI assistants.

Events

EventWhen
Contact subscribed
contact.subscribed
A contact becomes active: a signup, once they confirm if the newsletter asks, or a contact added by hand or through the API. Imports don't send it.
Contact unsubscribed
contact.unsubscribed
Through an email's unsubscribe link, their mail app's button, the email provider or by hand.
Contact bounced
contact.bounced
An email to them bounced for good, so they're stopped.
Contact complained
contact.complained
They marked an email as spam, so they're stopped.
Contact updated
contact.updated
Their first name, fields or tags changed, by hand, through the API, on their preferences page or when they signed up again.
Campaign sent
campaign.sent
All of a campaign's emails went out.
Link clicked
link.clicked
A contact clicked a link in a campaign: once per link and contact.

The test button sends webhook.test, with a made-up contact, jane@example.com.

What a message looks like

Each message is a POST with a JSON body: the event's id, its type, when it happened and its data. Contact events carry the contact and their newsletter. contact.updated adds what changed and the tags added or removed, contact.unsubscribed how they left, link.clicked the link and the campaign, and campaign.sent the campaign and how many it went to.

contact.subscribed
{
  "id": "6650f1c2e9b1d4a012345678",
  "type": "contact.subscribed",
  "createdAt": "2026-12-01T10:00:00.000Z",
  "data": {
    "contact": {
      "id": "6650f1c2e9b1d4a087654321",
      "email": "jane@example.com",
      "firstName": "Jane",
      "status": "active",
      "tags": ["vip"],
      "fields": { "company": "Example Inc." },
      "source": "website",
      "subscribedAt": "2026-12-01T10:00:00.000Z"
    },
    "newsletter": { "id": "6650f1c2e9b1d4a011223344", "name": "Weekly notes", "slug": "weekly-notes" }
  }
}

A message can arrive twice, after a retry: its id stays the same, so you can skip one you already handled.

Checking signatures

Every message is signed with its webhook's secret. The x-mailstamp-signature header is sha256= followed by the HMAC-SHA256 of the x-mailstamp-timestamp header, a dot and the body. Refuse a message whose signature doesn't match, or whose timestamp is more than 5 minutes away from your clock.

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

// body: the request's body exactly as it arrived, before it's read as JSON.
function isFromMailStamp(headers, body, secret) {
  const timestamp = headers["x-mailstamp-timestamp"];
  const signature = headers["x-mailstamp-signature"] ?? "";
  const expected = "sha256=" + crypto.createHmac("sha256", secret).update(`${timestamp}.${body}`).digest("hex");
  const isRecent = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300;
  return isRecent && signature.length === expected.length
    && crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}

If your secret leaks, click Replace secret on the webhook's page: the old one stops working at once.

Retries and the log

Your address has 10 seconds to answer with a 2xx status. Anything else, a redirect included, is tried again later, 5 more times over about 12 hours. If messages keep failing for 24 hours with no success, MailStamp switches the webhook off and lets you know. Fix the address, send a test, then switch it back on.

A webhook an API key or a connected app set up is switched off too when you revoke the key or disconnect the app, and you get a notification.

Each webhook's page lists the messages of the last 30 days, with what was sent and the answer each got.