Test mode: paid plans aren't on sale yet, so nothing is charged. Every plan's limits apply.

← Docs

Hooks

A realm can call an HTTPS endpoint of yours at five moments, one hook for each:

All five are signed and checked the same way. Most of this page describes the post-login hook.

Post-login

A realm can have one post-login hook: an HTTPS endpoint of yours that Nod calls just before each sign-in completes, after the person has proved who they are and before the app gets its code. The hook can refuse the sign-in, or add claims to the ID and access tokens. This is what Auth0 calls a post-login Action; Nod calls your endpoint rather than running your code.

Setting it

With the management API (realm:admin); the answer carries the signing secret, this once. Setting the hook again makes a new secret.

curl -X PUT "$ISSUER/api/v1/hooks/post-login" -H "Authorization: Bearer $T" \
  -H "Content-Type: application/json" -d '{"url": "https://hooks.acme.example/post-login"}'
# {"url": "https://hooks.acme.example/post-login", "fail_open": false, "secret": "…"}
curl "$ISSUER/api/v1/hooks/post-login" -H "Authorization: Bearer $T"      # realm:read; never the secret
curl -X DELETE "$ISSUER/api/v1/hooks/post-login" -H "Authorization: Bearer $T"

Or from the command line, which can also point at a hook on your own machine while you develop:

nod hook set acme https://hooks.acme.example/post-login [--fail-open]
nod hook set acme http://localhost:3000/post-login --insecure-dev      # development only
nod hook remove acme

The URL must be https to a public address. Nod checks the address again before every call, so a name that later resolves to a private address is refused, not called.

What Nod sends

A POST with a JSON body:

{
  "event": "post-login",
  "realm": "acme",
  "user": { "id": "01J…", "username": "alice", "email": "alice@acme.example", "email_verified": true,
            "given_name": "Alice", "family_name": "Lee",
            "user_metadata": { "theme": "dark" }, "app_metadata": { "plan": "pro" } },
  "client": { "id": "web", "name": "Acme web", "metadata": { "brand": "acme" } },
  "organization": "initech",
  "organization_details": { "id": "initech", "name": "Initech", "metadata": { "region": "eu" } },
  "acr": "urn:harpora:passkey"
}

Each call carries a signature header:

Nod-Signature: t=1764500000,v1=5f0c…

The same value is also sent as Harpora-Signature, the header's name before the rename, until 1 January 2027: a receiver that checks the old name keeps working, and should move to Nod-Signature.

v1 is the hex HMAC-SHA256 of <t>.<body>, keyed with the hook's secret. Verify it before trusting anything in the body, compare in constant time, and refuse a t more than a few minutes old so a captured call can't be replayed:

import { createHmac, timingSafeEqual } from "node:crypto";

function verify(secret, header, body) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const want = createHmac("sha256", secret).update(`${t}.${body}`).digest();
  const got = Buffer.from(v1 ?? "", "hex");
  return got.length === want.length && timingSafeEqual(got, want);
}

What the hook answers

HTTP 200 with JSON, within 3 seconds.

When the hook fails

Unreachable, slower than 3 seconds, a status other than 200, an answer that isn't JSON, or claims that break the rules: the sign-in is refused with access_denied. A broken hook shouldn't quietly let in people it would have stopped. If your hook only adds claims and you'd rather sign people in without them, set it to fail open ("fail_open": true, or --fail-open). Either way the failure is in the security log as hook.failed, with the reason; refusals are logged as hook.denied.

Nod doesn't follow redirects from the hook.

Pre-registration

Called when someone starts signing themselves up (the realm allows sign-up), before any account or passkey exists. Set it like the post-login hook, under its own name:

curl -X PUT "$ISSUER/api/v1/hooks/pre-registration" -H "Authorization: Bearer $T" \
  -H "Content-Type: application/json" -d '{"url": "https://hooks.acme.example/pre-registration"}'
nod hook set acme https://hooks.acme.example/pre-registration --trigger pre-registration

Nod sends, signed the same way:

{ "event": "pre-registration", "realm": "acme", "user": { "username": "alice", "display_name": "Alice" },
  "ip": "203.0.113.7" }

Answer {} to let the sign-up go ahead, or {"deny": "Sign up with your work email"} to refuse it: the page shows your text. Failures refuse the sign-up unless the hook fails open, and both are in the security log (hook.denied, hook.failed, with pre-registration: in the detail). Accounts an administrator creates, SCIM provisions, or that arrive through an outside provider don't pass through it.

Credentials exchange

Called before a token is issued to a machine client (client_credentials). By then the client has authenticated and has been granted the API and scopes it asked for: nobody without a working client secret, key or certificate can make Nod call your hook. This is Auth0's credentials-exchange Action.

curl -X PUT "$ISSUER/api/v1/hooks/credentials-exchange" -H "Authorization: Bearer $T" \
  -H "Content-Type: application/json" -d '{"url": "https://hooks.acme.example/m2m"}'
nod hook set acme https://hooks.acme.example/m2m --trigger credentials-exchange

Nod sends, signed the same way:

{ "event": "credentials-exchange", "realm": "acme", "client": { "id": "billing-worker", "name": "Billing worker" },
  "audience": "https://api.acme.example", "scope": "invoices:read", "ip": "203.0.113.7" }

Answer {} to issue the token as it is, {"claims": {"https://acme.example/tenant": "t1"}} to add claims to it (names are URLs, as for post-login, so no standard claim can be replaced), or {"deny": "over quota"} to refuse it: the client gets unauthorized_client with your text (RFC 6749 has no access_denied at the token endpoint). Failures refuse the token unless the hook fails open, and both are in the security log, with credentials-exchange: in the detail.

Post-change-password

Called after someone's password changes: from the account page, through a reset link, or by the management API. It is a notice. It's sent in the background once the change is done, the change stands whatever your hook answers, and nothing waits for it. Use it to tell the person by your own channels, or to end sessions your app keeps (a reset by email has already signed them out of everything at Nod).

nod hook set acme https://hooks.acme.example/password-changed --trigger post-change-password
{ "event": "post-change-password", "realm": "acme",
  "user": { "id": "01J…", "username": "alice", "email": "alice@example.com", "email_verified": true },
  "via": "reset", "ip": "203.0.113.7" }

via is account, reset or admin, and ip is empty for admin. A failed call is in the security log (hook.failed, post-change-password: in the detail) and is not retried.

Password migration

For moving from a system whose password hashes can't be exported (Okta, Amazon Cognito, Firebase Auth, a database of your own): people move as they sign in. When a password sign-in names a username the realm doesn't have, Nod asks your hook, which asks the old system:

nod realm set acme --passwords on
nod hook set acme https://migrate.acme.example/check --trigger password-migration
{ "event": "password-migration", "realm": "acme", "user": { "username": "dana" },
  "password": "what they typed", "ip": "203.0.113.7" }

Answer {"user": {"email": "dana@acme.example", "email_verified": true, "given_name": "Dana", "family_name": "D", "name": "Dana D"}} (every field optional) when the old system accepts the password: Nod makes the user with that username, keeps the password (as Argon2id, even if it's shorter than the realm's rules for new passwords) and signs them in. Anything else, a deny, an empty answer or a failure, is an ordinary wrong password.