Tokenmaildocs
Dashboard

DocsTokenmail

Webhooks

Get an HTTPS POST when mail arrives instead of polling. An endpoint gets only the events it lists, so name them with --event (repeat it):

$ tokenmail webhooks add https://example.com/mail --event message.received --name prod   # prints the signing secret once
$ tokenmail webhooks test wh_…          # send a ping now
$ tokenmail webhooks update wh_… --event message.received --event domain.verified   # or --url, --name, --disable, --enable
$ tokenmail webhooks deliveries wh_…    # attempts and results, 30 days
$ tokenmail webhooks list · rotate wh_… · rm wh_…

Events: message.received, message.received.spam, message.received.blocked, message.received.unauthenticated, message.sent, message.delivered, message.bounced, message.complained, message.rejected and domain.verified (see events). Over the API (POST /v1/webhooks with {url, events, name?}), inboxes limits an endpoint to some inboxes.

Every body has {"id", "type", "created_at", …} plus inbox_id, message and thread; objects are as their GET returns them.

Answer 2xx within 10 seconds. Otherwise it retries, up to 8 attempts over about 3 hours. Delivery is at least once and unordered: deduplicate on id. Headers: froog-event, froog-delivery (the event id), froog-attempt, froog-webhook. A disabled endpoint gets nothing.

Every request carries froog-signature: t=<unix time>,v1=<hex>, where v1 is HMAC-SHA256 of "<t>.<raw body>" with your signing secret. Check it, and reject old timestamps:

// Node.js
const crypto = require('crypto');
function verify(rawBody, header, secret) {
  const { t, v1 } = Object.fromEntries(header.split(',').map(p => p.split('=')));
  const want = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
  return Math.abs(Date.now() / 1000 - Number(t)) < 300 &&
    crypto.timingSafeEqual(Buffer.from(want), Buffer.from(v1));
}

Endpoints must be HTTPS on port 443 or 8443 at a public address; redirects aren't followed. Up to 10 per account.