SpecinboxDocs
← Dashboard

Webhooks

Events, signatures and verifying deliveries.

Register an endpoint in the dashboard (Webhooks) for message.received, inbox.expired and/or quota.threshold. We only ever call public HTTPS URLs, retry a failing endpoint with backoff for 24 hours, and sign every delivery so you can trust it came from us.

The signature header

Every delivery carries Tempmail-Signature: t=<unix seconds>,v1=<hex>, where v1 is HMAC-SHA256(secret, `${t}.${raw body}`) — the timestamp, a literal dot, then the exact bytes you received (parse JSON only after you've verified). Reject anything more than 300 seconds old.

Tempmail-Signature: t=1763374927,v1=5b3f...a2e9

Verifying a delivery

Node.js (Express)
import crypto from "node:crypto";

function verifyWebhook(secret, header, rawBody, toleranceSeconds = 300) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const t = Number(parts.t);
  const v1 = parts.v1;
  if (!t || !v1) throw new Error("Malformed Tempmail-Signature header");
  if (Math.abs(Date.now() / 1000 - t) > toleranceSeconds) {
    throw new Error("Signature timestamp outside tolerance");
  }
  const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const ok = expected.length === v1.length && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
  if (!ok) throw new Error("Signature mismatch");
}

// rawBody must be the exact bytes Express received — express.raw(), not express.json().
app.post("/hooks/tempmail", express.raw({ type: "application/json" }), (req, res) => {
  verifyWebhook(process.env.TEMPMAIL_WEBHOOK_SECRET, req.header("Tempmail-Signature"), req.body);
  const event = JSON.parse(req.body);
  if (event.type === "message.received") {
    // ... handle the new message
  }
  res.sendStatus(200);
});
Python (Flask)
import hashlib
import hmac
import time

def verify_webhook(secret: str, header: str, raw_body: bytes, tolerance_seconds: int = 300) -> None:
    parts = dict(p.split("=", 1) for p in header.split(","))
    t = int(parts["t"])
    v1 = parts["v1"]
    if abs(time.time() - t) > tolerance_seconds:
        raise ValueError("Signature timestamp outside tolerance")
    signed_payload = f"{t}.".encode() + raw_body
    expected = hmac.new(secret.encode(), signed_payload, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, v1):
        raise ValueError("Signature mismatch")

@app.post("/hooks/tempmail")
def tempmail_webhook():
    # request.get_data() is the exact bytes Flask received, before any JSON parsing.
    verify_webhook(WEBHOOK_SECRET, request.headers["Tempmail-Signature"], request.get_data())
    event = request.get_json()
    if event["type"] == "message.received":
        ...  # handle the new message
    return "", 200

Event body

{
  "id": "evt_31a9f2c8",
  "object": "event",
  "type": "message.received",
  "created": "2026-11-17T10:42:09Z",
  "livemode": true,
  "data": {
    "inbox": {
      "id": "inb_7Qx2",
      "address": "[email protected]"
    },
    "message": {
      "id": "msg_9KdA",
      "from": "Acme <[email protected]>",
      "subject": "Your code",
      "received_at": "2026-11-17T10:42:09Z",
      "size": 4210
    }
  }
}

Return any 2xx quickly (we read at most a few seconds of response); anything else is treated as a failure and retried.