Webhooks

When something happens, eMailPlane POSTs a signed JSON event to your https address: a reply arrives, a message is delivered or bounces, a draft waits for a person. Events carry ids and verdicts, never message content or an email address; fetch the details with your key.

Register an endpoint

curl -sS "$EMAILPLANE_API_URL/v1/webhooks" \
  -H "Authorization: Bearer $EMAILPLANE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://acme.example.com/hooks/email", "events": ["message.received", "message.bounced"]}'

Leave out events to get them all. The answer shows secret (whsec_...) this once and never again: keep it as EMAILPLANE_WEBHOOK_SECRET. To change a secret without changing the endpoint or delivery ids, use the rotation flow below. The address must be public https on port 443; an app has up to 10 endpoints. The key needs manage:webhooks.

What arrives

A POST with content-type: application/json, user-agent: eMailPlane-Webhooks/1 and the following headers:

HeaderWhat it is
x-ix-webhook-idThis delivery's id, also id in the body. The same on every retry and redrive: use it to drop duplicates
x-ix-webhook-timestampWhen this attempt was signed, in Unix seconds. Every retry is signed again
x-ix-webhook-signaturev1= and the hex HMAC-SHA256 of {timestamp}.{raw body}, keyed with your current secret
x-ix-webhook-signature-secondaryOptional: the same bytes signed with a prepared candidate, during its bounded overlap

The body has id, type, event_id (the same id the event stream uses), occurred_at, and the event's own fields.

Verify every delivery

  1. Use the raw body bytes, before any JSON parsing: parsed and re-written JSON will not match.
  2. Refuse a timestamp more than 5 minutes from your clock. This is your replay window; the snippets use 5 minutes. A retry is signed again, so a real delivery is never stale.
  3. Compare v1= + hex(HMAC-SHA256(secret, timestamp + "." + body)) with either signature in constant time. During rotation, retain your current and candidate keys until commit succeeds.
  4. Skip an x-ix-webhook-id you have already handled.
  5. Store the event, answer 2xx, then do the slow work.

Node 18 or later. This exact code is tested against our signer:

import { createHmac, timingSafeEqual } from 'node:crypto';

const TOLERANCE_SECONDS = 300; // the replay window: 5 minutes

// body: the raw request body (Buffer or string). headers: Node's req.headers or a Fetch Headers.
export function verifyWebhook(body, headers, secret, nowMs = Date.now()) {
  const get = (name) => String((typeof headers.get === 'function' ? headers.get(name) : headers[name]) ?? '');
  const timestamp = get('x-ix-webhook-timestamp');
  const signatures = [get('x-ix-webhook-signature'), get('x-ix-webhook-signature-secondary')];
  const keys = Array.isArray(secret) ? secret : [secret];
  if (keys.length < 1 || keys.length > 2 || keys.some(key => typeof key !== 'string' || !key)) return false;
  if (!/^\d{1,12}$/.test(timestamp)) return false;
  if (Math.abs(nowMs / 1000 - Number(timestamp)) > TOLERANCE_SECONDS) return false;
  return keys.some(key => {
    const expected = Buffer.from('v1=' + createHmac('sha256', key).update(`${timestamp}.`).update(body).digest('hex'));
    return signatures.some(signature => /^v1=[0-9a-f]{64}$/.test(signature)
      && timingSafeEqual(Buffer.from(signature), expected));
  });
}

With Express, take the body raw: app.post('/hooks/email', express.raw({ type: 'application/json' }), (req, res) => ...) and pass req.body. With Fetch (Next.js, Workers, Bun, Deno): verifyWebhook(Buffer.from(await request.arrayBuffer()), request.headers, secret).

Python 3.8 or later. Pass request.get_data() in Flask or request.body in Django, and request.headers:

import hashlib, hmac, time

TOLERANCE_SECONDS = 300  # the replay window: 5 minutes

def verify_webhook(body: bytes, headers, secret, now=None) -> bool:
    timestamp = headers.get("x-ix-webhook-timestamp", "")
    signatures = [headers.get("x-ix-webhook-signature", ""), headers.get("x-ix-webhook-signature-secondary", "")]
    keys = secret if isinstance(secret, list) else [secret]
    if not 1 <= len(keys) <= 2 or any(not isinstance(key, str) or not key for key in keys):
        return False
    if not (timestamp.isascii() and timestamp.isdigit() and len(timestamp) <= 12):
        return False
    if abs((time.time() if now is None else now) - int(timestamp)) > TOLERANCE_SECONDS:
        return False
    for key in keys:
        mac = hmac.new(key.encode(), timestamp.encode() + b"." + body, hashlib.sha256)
        expected = ("v1=" + mac.hexdigest()).encode()
        for signature in signatures:
            if len(signature) == 67 and signature.isascii() and hmac.compare_digest(signature.encode(), expected):
                return True
    return False

Go. Read the body with io.ReadAll(r.Body), then call Verify(body, r.Header, secret, time.Now()):

package webhook

import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"net/http"
	"strconv"
	"time"
)

const tolerance = 5 * time.Minute // the replay window

func Verify(body []byte, h http.Header, secret string, now time.Time) bool {
	ts := h.Get("x-ix-webhook-timestamp")
	sec, err := strconv.ParseInt(ts, 10, 64)
	if err != nil || len(ts) > 12 {
		return false
	}
	if d := now.Sub(time.Unix(sec, 0)); d > tolerance || d < -tolerance {
		return false
	}
	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write([]byte(ts + "."))
	mac.Write(body)
	want := "v1=" + hex.EncodeToString(mac.Sum(nil))
	for _, name := range []string{"x-ix-webhook-signature", "x-ix-webhook-signature-secondary"} {
		sig := h.Get(name)
		if len(sig) == len(want) && hmac.Equal([]byte(sig), []byte(want)) { return true }
	}
	return false
}

Rotate an endpoint secret

Rotation preparation is off by default. Your box operator first applies migration 194 and upgrades every dispatcher, then turns rotation on in the server's runtime settings. The integration descriptor reports webhook.rotation.prepare_enabled; support alone does not mean it is enabled. No setting grants additional API authority.

  1. With the endpoint's app-wide manage:webhooks key, POST an empty body to /v1/webhooks/:id/secret-rotations with a fresh Idempotency-Key header (1–255 characters). The no-store answer includes rotation_id, expires_at and secret. Store the candidate securely; never paste it into logs or a support receipt.
  2. For up to 24 hours the primary signature still uses your current key, and the secondary signature uses the candidate. Install the verifier above with both keys (Node/Python accept [current, candidate]; in Go accept Verify(..., current, ...) || Verify(..., candidate, ...)). Existing single-primary consumers keep working while you prepare.
  3. Once the candidate is installed, POST an empty body to /v1/webhooks/:id/secret-rotations/:rotation_id/commit. This makes it the primary key and stops old-key signing. Keep only the new key after the response or a repeated commit confirms committed. A cancelled or expired candidate cannot be committed.

DELETE /v1/webhooks/:id/secret-rotations/:rotation_id to cancel a pending candidate. Uncommitted expiry cancels candidate signing automatically and keeps the current key; it never switches to a secret whose response you may have lost. A different preparation while one is pending returns 409. Retrying the same preparation key within its 24-hour replay window recovers the same candidate only while that exact rotation is still pending and unexpired; another live app-wide key for the same app may recover it. After that replay window the same key may create a fresh preparation, so first read the endpoint's non-secret rotation state. Ordinary endpoint reads never reveal either key. Disabled/foreign endpoints and unauthorized credentials cannot recover secrets.

Commit or cancellation is safe to repeat for that same terminal rotation ID. Once another rotation supersedes it, a stale ID is a conflict, never a command against the new rotation. While rotation is off, these three key routes answer 404 like any unknown path and are left out of /v1/openapi.json: a pending candidate cannot be recovered, committed or cancelled with a key, expires on its own and keeps the current key. Already-promoted signing is unchanged. If an old key is compromised, install and commit the candidate promptly; merely preparing does not revoke the current key.

Already signed or in-flight requests cannot be recalled. After commit, reject old-key requests; a failed delivery retries using the current generation with the same delivery id. Pausing does not extend the overlap. New signing state is read when each attempt starts, rather than when a batch is claimed.

An old dispatcher binary does not understand promoted generations and is not a safe rollback after rotation has been used. Pause/drain webhook dispatch and restore a rotation-aware runtime; never resume an older signer that could use a retired key. The dashboard’s Apps page also provides owned webhook history, pause/resume, failed redelivery and explicit signing-key preparation/commit/cancel. Only a signed-in owner or operator with existing app credential-management authority can use that bridge; setup grants and app keys cannot. Browser preparation retains its request only in memory for an exact retry after a lost response. After refreshing, use a candidate you already saved or cancel and prepare again. The current key is unchanged until commit. MCP webhook_rotation_prepare saves the candidate in a private customer-local EMAILPLANE_KEY_DIR file and returns only its path; retain the idempotency key, install the candidate, then call webhook_rotation_commit with installed: true, or webhook_rotation_cancel. These tools do not enable preparation or change rollout prerequisites. Actual served-consumer and customer cutover evidence remains required.

Retries, pausing and failed deliveries

A 2xx answer within 30 seconds is success. Anything else is tried again: another status, a timeout, a refused connection. A redirect is followed up to 3 times, https only, and each new address is checked again. A delivery gets 10 attempts. The waits between them are 30 s, 1 min, 2 min, 4 min, 8 min, 16 min, 32 min, 1 h 4 min, 2 h 8 min, so the last attempt comes about 4 hours 16 minutes after the first. Then the delivery is failed and stays in the dead-letter queue until you send it again. Delivery is at least once: drop duplicates by x-ix-webhook-id.

CallWhat it does
GET /v1/webhooks/:idOne endpoint: its events, whether it is paused, and how many deliveries are pending or failed
GET /v1/webhooks/:id/deliveriesIts last 100 deliveries: state (pending, delivered, failed, cancelled), attempts, last HTTP status and reason, next attempt
GET /v1/webhooks/dlqThe dead-letter queue: the last 100 failed deliveries across your endpoints
POST /v1/webhooks/dlq/:id/redriveSend one failed delivery again, due now, with 10 fresh attempts and the same id. 409 if it has not failed
POST /v1/webhooks/:id/pauseHold deliveries, for a deploy or an outage. Events are still recorded, and nothing is lost
POST /v1/webhooks/:id/resumeSend what was held on the next pass. A delivery waiting between retries keeps its wait
DELETE /v1/webhooks/:idRemove the endpoint; its pending deliveries are cancelled

Events

Each event is recorded once, then sent to your webhooks and to the event stream, GET /v1/events/stream (Server-Sent Events, kept for 7 days; reconnect with Last-Event-ID and nothing is missed). So every event below is on the stream too, with the webhook's event_id as its id. A webhook gets every event it subscribed to; on the stream a key sees what its scopes allow: received mail and its conversations (messages, threads, waits, terms) with read:inbox; the fate of sent mail (message.delivered, .bounced, .complained, recipient.*) with send or read:analytics; drafts with any of those three; domain events with admin; authority.changed and app.disconnected with any of the four scopes the stream accepts (read:inbox, send, read:analytics or admin). A key with none of those four cannot open the stream.

EventWhen
message.receivedMail arrived for your app
message.matchedReceived mail matched one of your inbound rules, with the message, thread and rule ids and the route. It goes to the webhook the rule names, or to your subscribed webhooks when the rule names none
message.human_repliedA person answered from their own mailbox
message.scheduledA paced send was scheduled, updated, released, expired or cancelled; includes its phase and expected time, without message content
message.deliveredThe recipient's server accepted your message
message.bouncedYour message bounced
message.complainedThe recipient reported it as spam
recipient.bounced, recipient.complained, recipient.unsubscribedA person hard-bounced, complained or unsubscribed. We already stop your mail to them (sign-in mail still reaches someone who unsubscribed or complained); update your own records
draft.created, draft.approved, draft.rejected, draft.expiredA send held for a person's decision, and the decision
draft.withdrawnThe program that wrote a pending draft took it back before anyone decided (ids only, never content)
wait.resolvedA wait (POST /v1/waits) ended
thread.owner_changedA conversation changed hands: a person answered it, or it was handed to a person or back
thread.markedA triage mark was set or cleared
conversation.contract_proposed, conversation.budget_tripped, conversation.expired, conversation.circuit_resetA conversation's agreed terms were proposed, ran out of budget, expired or were reset
domain.verified, domain.verification_gave_upA domain's DNS check passed, or 72 hours of checking ended
domain.registration_expiringA verified domain's registration ends in 30 days, and again at 7, with its end date and the days left. Renew it with your registrar or mail to that domain stops
domain.nameservers_changedA verified domain moved to other nameservers, with the old and new ones. Re-check its email records there, then verify the domain again
authority.changedWhat a key may do changed: a key was revoked, an inbox burned, an agent paused or resumed, or a policy changed. It names the change, the key or inbox it applies to and a revision number; it never grants anything
account.clearedOne of your account's servers can now email anyone, with that server's id
app.disconnectedThe app was disconnected. Sent to every endpoint it had, even a paused one or one that did not subscribe

message.received:

{
  "id": "0b6f2c1e-4a8d-4f6e-9a51-3c2d7e9f1a20",
  "type": "message.received",
  "event_id": "48213",
  "occurred_at": "2026-11-11T01:14:03.512Z",
  "message_id": "5f1d3a9e-2c47-4b8a-9e6d-1a2b3c4d5e6f",
  "thread_id": "a3e9b0c2-7d14-4f5a-8b6c-9d0e1f2a3b4c",
  "route": "agent",
  "inbox_ids": ["c7d8e9f0-1a2b-4c3d-8e4f-5a6b7c8d9e0f"],
  "sender": { "trust_tier": 2, "tier": "verified", "flags": [], "auth": {
    "dkim": [{ "result": "pass", "aligned": true }],
    "spf": { "result": "pass", "aligned": true, "asserted_by": "edge" },
    "dmarc": { "result": "pass", "policy": "reject" } } },
  "screening": { "trust_tier": 2, "automated": false, "reply_needed": null,
    "needs_human": null, "withheld_reason": null, "source": "rule" }
}

route is the part of your address before the @ that the mail came to. Read the message with GET /v1/inbound/:message_id.

screening.withheld_reason set means the content is kept from agents. request_policy means the sender's domain publishes that it never asks for what this message asks, and request_policy_unchecked means the message asks and that policy could not be read. That hold is checked again on a backoff (5 minutes, doubling to 6 hours, for up to 7 days): the content is released once the policy reads and allows the ask, and the reason becomes request_policy if it forbids it. GET /v1/inbound/:message_id also answers before_read: one plain line to show before the body, with its kind (agent_verified, agent_revoked, agent_unconfirmed, spoofed, no_ai_label_confirmed or no_ai_label_unconfirmed). It is null for mail that arrived before this check existed. See Verify an eMailPlane agent.

message.delivered, message.bounced and message.complained share one shape; recipient.* events use it too:

{
  "id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
  "type": "message.bounced",
  "event_id": "48214",
  "occurred_at": "2026-11-11T01:15:42.000Z",
  "message_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "thread_id": null,
  "lifecycle_event_id": "90311",
  "reason_code": "dsn_5.1.1",
  "smtp_code": 550,
  "enhanced_status": "5.1.1"
}

reason_code names the report behind the event, for example dsn_5.1.1 from a bounce report or arf_abuse from a spam complaint. smtp_code and enhanced_status are null when the report had none. message_id is the id that POST /v1/emails returned.

Debug a missing email

H="Authorization: Bearer $EMAILPLANE_API_KEY"
curl -sS "$EMAILPLANE_API_URL/v1/emails/$ID" -H "$H"                    # 1
curl -sS "$EMAILPLANE_API_URL/v1/events?message_id=$ID" -H "$H"         # 2
curl -sS "$EMAILPLANE_API_URL/v1/suppressions/check" -H "$H" \
  -H "Content-Type: application/json" -d '{"address": "customer@example.com"}'   # 3
curl -sS "$EMAILPLANE_API_URL/v1/webhooks/$HOOK/deliveries" -H "$H"
curl -sS "$EMAILPLANE_API_URL/v1/webhooks/dlq" -H "$H"
curl -sS -X POST "$EMAILPLANE_API_URL/v1/webhooks/dlq/$DELIVERY/redrive" -H "$H"   # 4
  1. Where it is now: state, and progress says in words where the message is (on your server, handed on, retrying, delivered, bounced, not sent) and what happens next.
  2. Every step it took, with the smtp_code, enhanced_status and the recipient's mail domain for each step.
  3. Will this person's mail be refused? "suppressed": true means the person bounced, complained or unsubscribed. A send to them is refused, and trying again never helps.
  4. The event happened but your app never heard: a delivery's last_reason says why. delivered: it worked. http_<status>: your endpoint answered that status. network: no connection, or no answer in 30 seconds. bad_redirect: an unreadable Location. too_many_redirects: more than 3. blocked:dns_failure or blocked:dns_empty: the name did not resolve. blocked:proxy_refused: our outbound proxy could not connect to you. blocked:scheme_not_https, blocked:port_not_443, blocked:userinfo_in_url, blocked:no_host, blocked:denied_range, blocked:not_globally_routable or blocked:unparseable_address: the URL, or a redirect, is not a public https address on port 443. Fix it, then redrive. If nothing is listed, check the endpoint subscribed to that event and is not paused (GET /v1/webhooks/:id).

Waiting for a reply instead? GET /v1/inbound lists what arrived, newest first, and the event stream shows each message.received as it lands.

Back to Developers