Receive webhooks

Optional, recommended for production. Login works without it, but if the user signs out from Block-Auth (Identity, the extension or another device), your app won’t know.

Receive webhooks

Block-Auth calls your backend when a user signs out of your app from Block-Auth (signout) or unlinks your app (account.unlinked), so you can close their session too.

  1. In the Dashboard, open your application's Authentication settings. In the third URL field, shown as "When user fails to log in", type the path /blockauth/webhook (your domain is already filled in).
  2. Add the route. It checks the signature (headers X-BlockAuth-Timestamp and X-BlockAuth-Signature), checks that the apiKey is yours and ignores repeated jti:

Body

What your server receives (not code to copy)
{
  "event": "account.unlinked",
  "apiKey": "your_api_key",
  "address": "0x8f2a…c41d",
  "externalId": "42",
  "iat": 1762790400,
  "jti": "5c1e2b7a-…"
}
server.js · where you create your Express app
const seen = new Map()

app.post('/blockauth/webhook', express.raw({ type: '*/*' }), (req, res) => {
  let event
  try {
    event = blockauth.verifyWebhook(req.body, req.get('X-BlockAuth-Timestamp'), req.get('X-BlockAuth-Signature'))
  } catch {
    return res.status(401).end()
  }
  if (event.apiKey !== BLOCKAUTH_API_KEY || seen.has(event.jti)) return res.status(409).end()
  seen.set(event.jti, Date.now())

  endSessionsOf(event.address)
  if (event.event === 'account.unlinked') markUnlinked(event.externalId)
  res.json({ ok: true })
})

endSessionsOf, markUnlinked are yours: replace them with your app’s own functions (your database, your cache…).

endSessionsOf, markUnlinked and alreadyProcessed are yours: they depend on how your app stores sessions and users.