PostHog
Cohort webhooks
Fire a webhook the moment someone enters or leaves a cohort.
AuthorPriya Raghavan
PublishedJul 2026
LicenseMIT
Installs168
Why it exists
Lifecycle tools want to know when a user becomes "activated" or goes dormant, and polling the cohort API from a cron job is the duct tape everyone ships. This mod turns cohort membership changes into signed webhooks with retries and a dead-letter queue.
What it does
- Webhook per cohort enter and exit event
- HMAC-signed payloads with replay protection
- Retries with backoff and a dead-letter queue
The spec
These acceptance criteria were written with the person who requested the mod, then locked in as its tests. The mod has to pass them on every new release train before it rides along.
- A user flapping in and out of a cohort produces ordered, deduplicated events
- A receiver outage never loses events, they drain from the queue
mods/cohort-webhooks/tests/ordering.spec.ts
test("flapping membership stays ordered", async () => {
await cohort.add(user); await cohort.remove(user); await cohort.add(user)
const events = await receiver.drain()
expect(events.map(e => e.type)).toEqual(["enter", "exit", "enter"])
})