Skip to content
Developer platform · Events

Receive signed email events

Webhooks are delivered at least once. Verify before parsing, deduplicate by event ID, and return a 2xx response within five seconds.

Endpoint verification handshake

Before saving an endpoint, Omnero Mail sends webhook.endpoint_verification. Parse the JSON and return { "challenge": payload.data.challenge } with HTTP 2xx within five seconds. Redirects, timeouts, non-2xx responses, invalid JSON, or a different challenge reject creation. The handshake proves control of a working handler; its signature cannot be trusted yet because the secret is only revealed after successful creation.

                        const payload = JSON.parse(rawBody);
if (payload.type === 'webhook.endpoint_verification') {
  return Response.json({ challenge: payload.data.challenge });
}
                      

Verify HMAC-SHA256 over the raw bytes

For every operational event, read the three Omnero-Webhook headers before parsing. Build id + "." + timestamp + "." + rawBody, calculate HMAC-SHA256 with your whsec_ secret, and compare v1=<hex> in constant time. Reject missing headers, timestamps more than five minutes from your clock, malformed hex, or signature mismatch. Never recreate the body with JSON.stringify: even equivalent JSON produces different bytes.

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

const id = request.headers.get('omnero-webhook-id')!;
const timestamp = request.headers.get('omnero-webhook-timestamp')!;
const supplied = request.headers.get('omnero-webhook-signature')!;
const age = Math.abs(Date.now() / 1000 - Number(timestamp));
if (!Number.isFinite(age) || age > 300) throw new Error('stale webhook');

const expected = createHmac('sha256', process.env.OMNERO_WEBHOOK_SECRET!)
  .update(`${id}.${timestamp}.${rawBody}`)
  .digest('hex');
const received = supplied.startsWith('v1=') ? supplied.slice(3) : '';
const valid = /^[a-f0-9]{64}$/.test(received) && timingSafeEqual(
  Buffer.from(received, 'hex'), Buffer.from(expected, 'hex')
);
if (!valid) throw new Error('invalid webhook signature');
                      

Delivery envelope and headers

Operational requests use Content-Type: application/json and User-Agent: Omnero-Webhooks/1.0. The JSON envelope contains id, type, apiVersion, occurredAt, and data. data always includes the canonical object type and resource id plus event-specific fields; consumers must ignore unknown fields and event types for forward compatibility.

  • Omnero-Webhook-Id — stable event ID and deduplication key
  • Omnero-Webhook-Timestamp — Unix seconds used in replay protection
  • Omnero-Webhook-Signature — v1=<64 lowercase hex HMAC>

Keep the signing secret safe

Omnero Mail generates a random whsec_ secret and shows it only once, when the endpoint is created. Store it in your own secret manager and rotate the endpoint if it leaks. The event body is not encrypted at the application level: HTTPS protects it in transit and the HMAC signature proves who sent it and that it was not altered. Your handler verifies the signature; there is nothing to decrypt.

Event catalog

Subscribe to individual types or * for every supported type. Message lifecycle events are message.received, message.queued, message.sent, message.delivered, message.bounced, message.failed, message.updated, and message.deleted. Permanent deletion in Webmail and automatic Trash expiry emit message.deleted with mailboxIds. Resource events are mailbox.created, mailbox.updated, mailbox.suspended, mailbox.deleted, and domain.health_changed. Deleting a mailbox emits mailbox.deleted once; it does not emit message.deleted for each of its messages.

Design for at-least-once delivery

Only parse and process the event after signature verification. In one durable transaction, store the event ID under a unique constraint and enqueue or apply your side effect. Repeated delivery keeps the same ID and is safe to acknowledge. Return 2xx after durable acceptance—not merely after reading the request.

  • No global ordering guarantee
  • Five-second response deadline
  • Automatic retries and dead-letter retention
  • Manual replay from the integration activity view

Retries, terminal failures, and endpoint health

Any timeout, unsafe URL resolution, redirect, network failure, or non-2xx response counts as a failed attempt. Omnero Mail records the failure and schedules retries with exponential backoff and jitter: 30–60, 60–120, 120–240, then 240–480 seconds. The cooldown is durable and duplicate records cannot bypass it. A fifth failed HTTP attempt becomes dead; its queue record remains unacknowledged for redrive to the 14-day dead-letter queue. SQS allows five receives; crashes or concurrent duplicate receives can exhaust that budget with fewer HTTP attempts. Manual replay starts a new delivery cycle. Ten consecutive endpoint failures disable the endpoint; a successful delivery resets the consecutive-failure counter.

Request a replay safely

POST /v1/webhook-deliveries/{deliveryId}/replay requires an Idempotency-Key with 8–255 characters. Persist the key with your operation and reuse it for retries for 24 hours. Repeating the same key returns the original response with Idempotent-Replayed: true and preserves later delivery progress. Another target with the same key returns 409; a new intentional replay needs a new key. An earlier attempt still in progress cannot overwrite the new replay. The event ID stays stable for receiver deduplication.

                        await omnero.webhooks.replay(deliveryId, {
  idempotencyKey: replayOperation.key,
});
                      

Recover after downtime

Use GET /v1/events?limit=25&cursor=<nextCursor> with messages:read to reconcile canonical history. Process items, checkpoint nextCursor only after durable acceptance, and continue until it is null. Webhooks optimize latency; the events endpoint restores completeness without assuming global delivery order.

Exercise the pipeline with sandbox events

From Dashboard → Integrations, choose a sandbox application and an event type. Omnero Mail creates a synthetic canonical event marked demo: true, sends it only to that application’s subscribed endpoints, and applies the same HMAC, retry, activity, and replay behavior as an operational delivery.

Next step

Create the first mailbox at no cost.

Start freeLog in