API Reference

Webhooks

Register an endpoint to receive delivery-status events from your workspace, so you can react to bounces, complaints, opens, and clicks in real time.

When an event fires, PristineSend POSTs the signed payload to each enabled endpoint subscribed to that event type. Failed deliveries are retried with exponential backoff; an endpoint that keeps failing is automatically disabled (re-enable it under Settings → Webhooks). The Events API exposes the same delivery history if you prefer to pull it.

Overview

Webhooks are HTTP POST requests sent to a URL you configure. They are triggered by delivery events from your PristineSend workspace. To set up a webhook endpoint, go to Settings → Webhooks in your dashboard and enter your endpoint URL.

Tip: During development, use ngrok or localtunnel to expose your local server to the internet.

Supported events

PristineSend pushes these event types. They are the same set you can filter on when reading the delivery log via the Events endpoint. A new endpoint subscribes to the first four; choose the rest under Settings → Webhooks, so an endpoint never receives an event type it did not ask for.

Event typeDescription
email.deliveredThe receiving mail server confirmed delivery.
email.bouncedThe email could not be delivered (hard or soft bounce).
email.complainedRecipient marked the email as spam.
email.failedThe send failed before delivery (e.g. the provider rejected the message).
email.openedRecipient opened the email. Gated by open tracking: fires normally under full; under essential the open is day-granular (the payload's opened_at is a date at midnight UTC); under off it NEVER fires. See Open-tracking modes below.
email.clickedRecipient clicked a tracked link. Fires under full and essential (clicks are full-fidelity in both); under off it NEVER fires.
email.skippedWe deliberately did not send the email. details.reason says why: suppressed (the address is on your do-not-send list), topic_opt_out (the contact left the email's topic), address_check (the address check found it risky, disposable or misspelt), recipient_cap or recipient_burst (the emails-per-contact limit). Campaign, automation and API emails alike.
email.heldAn API email is waiting for a quick security review. It is not sent yet. The event never says why.
email.releasedThe review was released and the email went on its way. Its own event follows as usual (delivered, bounced, or skipped if, say, the address was added to your do-not-send list meanwhile).
email.blockedThe review was blocked and the email was not sent. email.failed fires for it as well.
email.unsubscribedSomeone opted out. details.scope is all (every marketing email) or topic (one topic, in details.topic); details.source is link, one_click (the mailbox's own button), preference_page, provider, or reply (they asked by replying, and someone on your team unsubscribed them). data is the email they opted out from when we know it, else null. One event per opt-out that changed something: a second click on the same link sends nothing.
email.repliedSomeone replied to a campaign or automation email sent with Track replies on, and the reply was a real one, not an automatic answer. data is the email they replied to, with replied_at set; details.replied_at is when. Once per email: a second reply to the same email sends nothing. The reply's words are never in it: read the reply in the inbox it was forwarded to.
deal.createdA deal was made on your pipeline, by a person, the API, a connected AI, a reply or an automation. data is the deal as GET /v1/deals/{id} reads it when the event is delivered (null once the deal is deleted); details holds its stage_id, stage, source, contacts (how many), deal_id and actor (who made it, in words).
deal.stage_changedA deal moved to another stage, Won and Lost included. data is the deal as it is when the event is delivered; details holds from_stage_id, from_stage, to_stage_id, to_stage, to_kind (open, won or lost), lost_reason for a move to Lost, deal_id and actor, and because: stage_deleted when deleting a stage moved it.
signup.confirmedSomeone confirmed a signup by email and was added: a signup form's, a double opt-in signup the API took (POST /v1/contacts with double_opt_in), or someone who asked for news while booking a meeting on one of your booking pages. data is the contact as GET /v1/contacts/{id} reads it when the event is delivered (null once the contact is deleted); details holds signup_id (for an API signup, the id the call answered with), contact_id, source (form, api or booking), form_id (null for an API or booking signup), confirmed_at, and subscribed: false when an entry on your do-not-send list still holds the address, so the contact is kept but not emailed. When your plan's contact limit is reached, it comes once there is room.
booking.createdSomeone booked a meeting: on one of your booking pages, through Calendly or through Cal.com. data is the meeting as GET /v1/meetings/{id} reads it when the event is delivered (null once the meeting is deleted); details holds booking_id and provider (pages, calendly or calcom). A booking made before Calendly or Cal.com was connected sends nothing.
booking.rescheduledA meeting moved to a new time. data is the meeting at its new time, with rescheduled_from naming the old one (its id, when we saw it, and when it was); details holds booking_id, the new time's, and provider.
booking.canceledA meeting was cancelled, by the guest or by your team, a cancellation through the API included. data is the meeting as it is when the event is delivered; details holds booking_id, provider and canceled_by (guest or host).
Open-tracking modes affect which events you receive. Each message carries an open-tracking mode (full / essential / off), reported on every payload as data.open_tracking_mode. Under off, email.opened and email.clicked never fire — so don't treat their absence as "never opened". Under essential, email.opened still fires but its opened_at is a day-granular date (midnight UTC), and it fires once per message; email.clicked is unaffected. email.delivered, email.bounced, email.complained, and email.failed fire in every mode.

Payload format

All events share a common envelope: a unique id (prefixed evt_, stable across retries), the type, a created_at timestamp, and a data object. For an email.* event, data is the same email object returned by GET /v1/emails/:id (it is null for an event with no associated message, such as an opt-out from an automation email's link). For a deal.* event it is the deal, as the Deals API reads it when the event is delivered. details is null except on email.skipped (the reason), email.unsubscribed (who opted out, from what, and where), email.replied (when), the deal events (what changed, and who did it) and signup.confirmed (which signup, and where it came from). For signup.confirmed, data is the contact, as GET /v1/contacts/:id reads it when the event is delivered. For a booking.* event it is the meeting, as GET /v1/meetings/:id reads it when the event is delivered, and details names the booking, where it was booked and, for a cancellation, who cancelled it:

{
  "id": "evt_3f2a9c1e-7b4d-4a8e-9f1c-2d6b0e5a8c44",
  "type": "email.delivered",
  "created_at": "2026-05-16T12:34:56.000Z",
  "data": {
    "id": "a1b2c3d4-5e6f-4708-91a2-b3c4d5e6f708",
    "to": "recipient@example.com",
    "subject": "Your order has shipped!",
    "status": "delivered",
    "type": "transactional",
    "environment": "live",
    "sent_at": "2026-05-16T12:34:50.000Z",
    "delivered_at": "2026-05-16T12:34:56.000Z",
    "opened_at": null,
    "clicked_at": null,
    "bounced_at": null,
    "open_tracking_mode": "full",
    "error": null
  },
  "details": null
}

Verifying signatures

Every delivery is an HTTP POST with a JSON body and these headers:

HeaderValue
X-PristineSend-Signaturet=<unix>,v1=<hex> — the timestamp and signature (see below).
X-PristineSend-Event-IdThe event id (same as id in the body). Stable across retries — use it to dedupe.
X-PristineSend-Event-TypeThe event type, e.g. email.delivered.

The v1 signature is the hex HMAC-SHA256 of the string `${t}.${rawBody}` — the timestamp, a literal dot, and the exact raw request body — keyed by your endpoint's signing secret used verbatim: the entire whsec_… string, prefix included, is the HMAC key — don't strip the whsec_ prefix or base64-decode it. To verify a request:

  1. Read the X-PristineSend-Signature header and split out t and v1.
  2. Compute HMAC_SHA256(secret, `${t}.${rawBody}`) over the raw bytes you received — verify before JSON.parse, since re-serializing changes the bytes.
  3. Compare it to v1 with a constant-time check.
  4. Optionally reject the request if t is more than a few minutes old (replay protection).

Your endpoint's signing secret is shown when you create it and is retrievable any time from Settings → Webhooks. A worked example is below.

Example handler

A minimal Next.js App Router webhook handler that verifies the signature and dispatches on event type:

import { NextRequest, NextResponse } from "next/server"
import { createHmac, timingSafeEqual } from "node:crypto"

// Your endpoint's signing secret from Settings → Webhooks (starts with "whsec_").
const secret = process.env.PRISTINESEND_WEBHOOK_SECRET!

function verify(rawBody: string, header: string | null): boolean {
  if (!header) return false
  // Header form: "t=<unix>,v1=<hex>"
  const parts = Object.fromEntries(header.split(",").map((kv) => kv.split("=") as [string, string]))
  const t = parts.t
  const v1 = parts.v1
  if (!t || !v1) return false

  // Optional replay protection: reject signatures older than 5 minutes.
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false

  // The whole "whsec_…" string is the HMAC key; sign "<t>.<rawBody>".
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex")
  const a = Buffer.from(v1)
  const b = Buffer.from(expected)
  return a.length === b.length && timingSafeEqual(a, b)
}

export async function POST(req: NextRequest) {
  // Verify the RAW body before parsing — re-serializing would change the bytes.
  const rawBody = await req.text()
  if (!verify(rawBody, req.headers.get("X-PristineSend-Signature"))) {
    return NextResponse.json({ error: "Invalid signature" }, { status: 400 })
  }

  const event = JSON.parse(rawBody) as {
    id: string
    type: string
    data: unknown
    details: Record<string, unknown> | null
  }

  switch (event.type) {
    case "email.delivered":
      // mark contact as active
      break
    case "email.bounced":
      // mark contact as bounced
      break
    case "email.complained":
      // unsubscribe contact
      break
    case "email.skipped":
      // not sent; event.details.reason says why (e.g. recipient_cap: stop retrying today)
      break
    case "email.unsubscribed":
      // event.details.email opted out (scope "all", or one topic)
      break
    case "deal.stage_changed":
      // event.data is the deal; event.details.to_kind is "won" when it was won
      break
  }

  return NextResponse.json({ received: true })
}