Passkin

Hooks: your server, asked in the middle of a sign-up or sign-in

Status: built (2026-10-05). Tests: apps/auth-broker/tests/hooks.test.ts, apps/auth-broker/tests/native.test.ts, packages/server/tests/hooks.test.ts, packages/cli/tests/cli.test.ts.

Webhooks tell you what happened. A hook is asked before it happens. At the moment someone signs up or signs in, Passkin sends your server a signed request and waits — at most the timeout you set — for allow or deny, and, if you like, for claims to put in their tokens. It is how you say only people on our customer list, not from this country, this person is suspended in our billing system, or put the plan and tenant in the token, without Passkin running anyone's code. (Auth0's Rules and Hooks reach end-of-life on 2026-11-18; Actions that run your code in Passkin's process are a different product with a different risk. This is the safer half of the same capability, and it is the half most teams use.)

Event Asked Can
signup.before once, for a person new to this project, before their account is made allow, deny, put metadata on the new person
signin.before on every sign-in, a new person's first included — hosted pages, native sign-in, and silent re-sign-in allow, deny, add claims to the tokens of this sign-in

One hook per event per project. Dashboard → Hooks, …/projects/:pid/hooks, or hooks in passkin.config.json.

The request

POST to your address, Content-Type: application/json, with

Passkin-Signature: t=1760000000,v1=<hex HMAC-SHA-256 of "t.body" with the hook's secret>
Passkin-Hook-Event: signin.before
Passkin-Hook-Id: hk_…
{
  "event": "signin.before", "id": "hkevt_…", "created_at": "2026-10-05T12:00:00Z",
  "project": { "id": "prj_…" },
  "user": { "id": null, "email": "mona@acme.com", "email_verified": true, "name": "Mona Haddad", "first_name": "Mona", "last_name": "Haddad",
            "public_metadata": {}, "private_metadata": {} },
  "context": { "method": "google", "application": "pk_…", "platform": "web", "ip": "203.0.113.9", "user_agent": "…", "country": "US" }
}

user.id is null for someone who is signing up: they do not exist yet. For everyone else it is their id, with the metadata you put there. email_verified is always true — the person has already proven the address. country is from the platform's geo header behind a trusted proxy, and null when not known. A request made by the dashboard's Test has "test": true and a made-up person.

Verify the signature before trusting anything, and reject requests older than five minutes. With the SDK:

import { createHookReceiver } from "@passkin/nextjs/hooks"; // or "@passkin/server": plain Request/Response, WebCrypto only

const hook = createHookReceiver({ secret: process.env.PASSKIN_HOOK_SECRET! });

// POST /passkin/hooks
export const POST = hook.handle(async (event) => {
  if (!event.user.email.endsWith("@acme.com")) return hook.deny("Only Acme staff can sign up.");
  return hook.allow({ claims: { id_token: { plan: await planOf(event.user.email) } } });
});

The answer

200 with JSON; anything else is a failure.

{ "action": "allow",
  "claims":   { "id_token": { "plan": "pro" }, "access_token": { "plan": "pro", "features": ["a", "b"] } },
  "metadata": { "public": { "plan": "trial" }, "private": { "crm_id": "c-1" } } }
{ "action": "deny", "message": "Sorry, that address is not on our customer list." }
  • deny — nothing is made. The person sees message (control characters stripped, escaped, 200 characters at most) or "This sign-in was not allowed." The refusal is in the audit log as hook.denied with the event, the address and the message. For a native app it is an invalid_grant with the same words.
  • claims — for the ID token and/or the access token of this sign-in. They are kept with the session, so a refresh carries them and the hook is not asked again at refresh (a changed plan shows at the next sign-in; use short sessions, or webhooks plus your own API, when that is too slow). They are checked like claim templates — a valid name, none of Passkin's own (sub, iss, aud, exp, sid, azp, scope, org_*, act, email, …), at most 25 and 2 KB per token — but they are literal: nothing in your answer is ever rendered, so a string that looks like {{ user.private_metadata.x }} stays that string. Where a template and a hook set the same name, the hook wins. A third party's tokens (OAuth) never carry them.
  • metadata — only on signup.before: put on the new person's record (public and private), at most 50 keys and 8 KB each. Ignored on signin.before, so a handler that answers both the same way is fine.
  • An answer that is not an answer is a failure, never half applied: not JSON, no action, a claim with a bad or reserved name, too many or too large. You find out in the dashboard (the last call's result is on the hook) and not as a person with someone else's claim in their token.

When your server is down

Every login would otherwise wait on it. So:

  • Timeout — timeout_ms, 200 to 5000 (default 3000). Passkin stops waiting then.
  • on_failure — what a failure (no answer, an error, a bad answer, a timeout) does: deny (the default — turn the person away, with "Signing in is temporarily unavailable") or allow (let them in without the check). Choose by which is worse for you: a stranger in, or everyone out.
  • A breaker — after five failures within a minute the hook is skipped for thirty seconds and on_failure applies at once, so a dead server costs one timeout in five, not one per login. The dashboard shows skipped.
  • Failures are logged as hook.failed in the audit log (denials as hook.denied).

What Passkin guarantees about the call

  • Public hosts, https, no redirects. The address is checked when you save it and again at send time on the addresses the connection is about to use (a name that later points inward is still refused); the answer is read up to 64 KB. (Plain http to this machine is allowed in development only.)
  • Signed and fresh, with the hook's own secret (hsk_…), shown once and stored encrypted; rotate it any time.
  • Before anything is made. A denial leaves no user, no link, no session — and happens after the person has proven who they are and agreed to a consent screen, never before.
  • It cannot weaken Passkin's own rules. Bans, allow and block lists, sign-up mode, single-sign-on enforcement and the Shield run first and cannot be overridden by an allow.

Management API

GET|POST …/projects/:pid/hooks, GET|PATCH|DELETE …/hooks/:hid, POST …/hooks/:hid/rotate-secret, POST …/hooks/:hid/test.

  • POST — { event, url, timeout_ms?, on_failure? } → the hook and its secret (once). PATCH — { url?, timeout_ms?, on_failure?, enabled? }.
  • Test calls your real server with a sample request and returns { ok, status, ms, action, message, claims, metadata } or { ok: false, error }. Nothing is applied, nobody is refused, the breaker is untouched; the result is shown as the hook's last call. Ten tests a minute.
  • Audited as hook.created, hook.updated, hook.deleted, hook.secret_rotated, hook.tested.

In passkin.config.json (PLATFORM-API.md):

{ "hooks": [ { "event": "signup.before", "url": "https://api.example.com/passkin/hooks", "timeout_ms": 2000, "on_failure": "deny" } ] }

matched by event; the signing secret of a hook the file creates is printed once.

Not built

A hook at token refresh (claims are fixed at sign-in); a hook at password change, MFA enrolment or organization events; hooks that call out and wait for a person (an approval); a visual flow editor; Auth0-style sandboxed code that Passkin itself runs (deliberately: a hosted code runtime is a security and support surface of its own, and your server already can do everything it would); a library of ready-made hooks. The hook payload's country needs a trusted proxy that sets a geo header.

Ready to try it?

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

Open the dashboard