Passkin

Events and webhooks

Status: built (2026-10-05). Tests: apps/auth-broker/tests/webhooks.test.ts, packages/kit/tests/safe-fetch.test.ts.

A project can register endpoints — addresses on its own server. When something happens in the project, Passkin sends each interested endpoint a signed POST. It is how a developer's backend learns that someone signed up, was banned or had a session revoked without polling the Backend API.

What is sent

POST /hooks/passkin HTTP/1.1
Content-Type: application/json
User-Agent: Passkin-Webhooks/1
Passkin-Event-Id: evt_…
Passkin-Delivery-Id: whd_…
Passkin-Signature: t=1760000000,v1=9f2c…

{
  "id": "evt_…",
  "type": "user.created",
  "created_at": "2026-10-05T12:00:00.000Z",
  "project_id": "proj_…",
  "data": { "user": { "id": "usr_…", "email": "ada@example.com" }, "method": "passkey", "application": "pk_live_…", "platform": "web" }
}

The event id is the same on every attempt of a delivery: treat it as an idempotency key and ignore one you have already handled.

Event types

Type When
user.created A person signs in to the project for the first time
user.signed_in A person signs in again (data.method says how: passkey, password, google, github, email, passkin)
user.updated Metadata changed through the Backend API
user.banned, user.unbanned A ban or its lifting, from the dashboard or the Backend API; sessions end with a ban
user.deleted The user was removed from the project
user.disconnected (planned) the person disconnected the project in their Passkin ID
session.revoked One session was ended
email.bounced, email.complained An email Passkin sent for the project to data.email bounced for good, or was marked as spam (EMAIL.md, "Delivery"): Passkin stops mailing that address for a while, and your own mail to it will likely fail too. data.kind says which email (sign_in_code, invitation…)
application.created, .updated, .deleted An application of the project changed
project.updated The project's settings changed
oauth.client.created, oauth.grant.created, oauth.grant.revoked A client was registered by you or by itself; a person allowed a client (new, or wider); a grant was taken back (OAUTH.md)
connection.connected, connection.disconnected, connection.needs_reauth A person connected an account (or reconnected), took one back, or a provider stopped honouring one (VAULT.md); never a token
webhook.test You asked for a test; only the endpoint you tested receives it

An endpoint subscribes to a list of types, to a prefix such as user.*, or to * (the default: every event). audit.log — every activity entry as one stream for a SIEM, see AUDIT-LOGS.md — is not part of *; ask for it by name. New event types are added over time, so a receiver must ignore types it does not know.

Developing locally: passkin listen

Nothing to expose to the internet and no tunnel to run. While you build, the command line collects your project's events and posts them to your local server — signed exactly as a real delivery is, so the code that verifies signatures is the code you will ship:

passkin listen --forward-to http://localhost:3000/api/webhooks            # every event
passkin listen --forward-to http://localhost:3000/api/webhooks --events user.created,session.revoked
passkin listen --print                                                     # just look at them
# 14:02:11  user.created  → 200 (12 ms)

The first run makes a relay endpoint (shown in the dashboard with a passkin listen badge, with no address of its own) and prints its signing secret — put it in PASSKIN_WEBHOOK_SECRET for your local server. The secret is kept on your machine, readable by you alone (~/.config/passkin/relay.json), and the next run reuses the same endpoint; if the file is lost, a new one is made and the old one removed. --once collects what is waiting and exits. Press Ctrl-C to stop; the relay stays, and events that happen while you are away wait for the next run (for up to an hour).

A relay is for looking at events, not a queue: the delivery worker never sends from it, nothing is retried, and an event is marked handled once it has been forwarded — whatever your server answered, or if it was not running (the line says which). Fix the code and make the event happen again (the dashboard's Test on the endpoint sends a webhook.test). Underneath, GET …/webhooks/:wid/relay returns what waits and POST …/webhooks/:wid/relay/ack says which were handled; an endpoint is a relay when it was created with relay: true.

Verifying a request

The signature is an HMAC-SHA256 of "<t>.<raw body>" with the endpoint's secret (whsec_…, shown once when the endpoint is created or its secret rotated). Reject a request whose timestamp is more than five minutes old — that is what stops a captured request being replayed.

import { verifyWebhook } from "@passkin/kit"; // the same function Passkin tests with

const ok = verifyWebhook(process.env.PASSKIN_WEBHOOK_SECRET!, rawBody, req.headers["passkin-signature"]);

Verify against the raw body bytes, before any JSON parsing. Answer with any 2xx within ten seconds; anything else (or no answer) counts as a failure.

Delivery and retries

  • An event is queued at the moment it happens — one delivery per interested endpoint — and sent right away in the background. It never delays or fails the sign-in that caused it.
  • A failed delivery is tried again after 30 s, 2 min, 10 min, 1 h, 6 h, 24 h (seven attempts in all), then marked dead. A dead delivery can be replayed by hand.
  • An endpoint whose deliveries die 20 times in a row is switched off with a reason, and stays off until its owner switches it back on. A test works even on a switched-off endpoint, so you can find out whether it is fixed.
  • Retries need something to run them. After every event Passkin sends what is due; in addition, point a scheduler at POST /internal/cron/webhooks with Authorization: Bearer $CRON_SECRET once a minute (Vercel Cron on a plan that allows it, or any scheduler). Without CRON_SECRET the route does not exist.
  • Delivery is at least once, and order is not guaranteed. Use created_at and the event id.

Where requests may go

Passkin refuses to send events to anything but a public address: https only (plain http and this machine only in development), no credentials in the URL, no localhost, private networks, link-local or cloud-metadata addresses. The check is repeated on the address the connection is about to use, so a name that later resolves inward (DNS rebinding) is still refused, and redirects are never followed. This is the SSRF guard in @passkin/kit (safe-fetch.ts); the SSO metadata fetch will use it too.

Managing endpoints (Management API, signed in to the dashboard)

Method and path Does
GET /v1/manage/webhook-events The event types
GET /v1/manage/projects/:pid/webhooks List endpoints (never the secret)
POST /v1/manage/projects/:pid/webhooks {url, events?, description?} → the endpoint and its secret, once. Ten per project
PATCH …/webhooks/:wid {url?, events?, description?, enabled?}; enabling again clears the failure count
POST …/webhooks/:wid/rotate-secret A new secret, shown once; the old one stops working at once
DELETE …/webhooks/:wid Remove it and its history
POST …/webhooks/:wid/test Send webhook.test now; returns the delivery with what the server answered
GET …/webhooks/:wid/deliveries Recent deliveries: status, attempts, last status code or error, next attempt
POST …/webhooks/deliveries/:did/retry Replay a delivery from the start

Changes are written to the project's activity log (webhook.created, .updated, .secret_rotated, .deleted). Event payloads carry ids and the facts needed to act, not whole profiles; fetch the rest from the Backend API.

Not built yet

A CLI relay for local development (passkin listen forwarding events to localhost), per-endpoint rate caps, and pausing delivery during an incident. Each is in ROADMAP.md.

Ready to try it?

Create a project — the dashboard fills these snippets in with your own keys.

Open the dashboard