Webhooks
Instead of checking for mail, let herbmail tell your agent. Add an endpoint under Developer access on your address page (or on your kbve.com account), pick the events, and copy the signing secret; it is shown once.
Events
Section titled “Events”| Event | When |
|---|---|
mail.message.received |
Mail lands in your inbox |
mail.message.sent |
A reply you or your agent sent was accepted for delivery |
mail.message.failed |
A reply could not be delivered |
ping |
You pressed Send test |
Payload
Section titled “Payload”Each delivery is a POST with a JSON body:
{ "id": "event id", "type": "mail.message.received", "created_at": "2026-11-19T12:00:00Z", "data": { "message_id": "…", "thread_id": "…", "subject": "Saturday raid times", "received_at": "…", "sent_at": null }}Retries
Section titled “Retries”The body never carries the message itself: fetch it with GET /mail/threads/:thread_id and read reply_text. Answer with any 2xx within five seconds. Anything else is retried after 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours; an endpoint that fails 50 times in a row is switched off until you save it again.
Verifying a signature
Section titled “Verifying a signature”Every request carries x-kbve-event, x-kbve-delivery, x-kbve-timestamp and x-kbve-signature: sha256=<hex>, the HMAC-SHA256 of "<timestamp>.<raw body>" under your secret. Check it against the raw body, before parsing, and refuse a timestamp more than five minutes off:
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verify(secret, headers, rawBody) { const ts = Number(headers['x-kbve-timestamp']); if (!Number.isFinite(ts) || Math.abs(Date.now() / 1000 - ts) > 300) return false; const want = 'sha256=' + createHmac('sha256', secret).update(`${ts}.${rawBody}`).digest('hex'); const got = headers['x-kbve-signature'] ?? ''; return got.length === want.length && timingSafeEqual(Buffer.from(got), Buffer.from(want));}import hashlib, hmac, time
def verify(secret: str, headers: dict, raw_body: bytes) -> bool: ts = int(headers.get("x-kbve-timestamp", "0")) if abs(time.time() - ts) > 300: return False want = "sha256=" + hmac.new(secret.encode(), f"{ts}.".encode() + raw_body, hashlib.sha256).hexdigest() return hmac.compare_digest(want, headers.get("x-kbve-signature", ""))A known answer to test against
Section titled “A known answer to test against”With the secret whsec_x, the timestamp 1800000000 and the raw body {"a":1}, the signature is:
sha256=f20d18d08da09ed70c7d90a4cc6242e6c8fd59c4145ce0c03a09fb20e01ef470If your function returns that, it agrees with herbmail’s (skip the five-minute check for this one; the timestamp is in the future).
Trying it out
Section titled “Trying it out”- Open webhook.site and copy your unique URL.
- Add it as an endpoint on your address page and copy the secret.
- Press Send test. A
pingevent arrives within a few seconds, with the headers above. - Send yourself a message. A
mail.message.receivedevent follows it.
When you are done, delete the endpoint: anything it receives is public on that site.