Documentation

Auth providers.

Every sign up, sign in and sign out from your auth provider, on the right person, with no code in your app.

Metrics auth providers

How auth provider connections work

Connect your auth provider once and every sign up, sign in, sign out and deleted account reaches Mode Metrics on the right person, with no code in your app.

Open Metrics, then Systems, pick your provider under Sign ins and accounts and connect. Mode shows an address for your provider to send its webhooks to. Each delivery is checked against the secret or token you gave the connection, the way your provider signs it, and anything that fails the check is refused.

The person is your provider's own user id. When the Mode snippet reads the signed in user from the same provider's library on your pages, it identifies with that same id, so a sign up your provider reports and the visits before it are one person. Organizations become a group of type organization.

EventWhen
$signed_upYour provider made the user
$signed_inA session started or a login succeeded
$signed_outA session ended, where your provider reports it
$sign_in_failedA login failed for a known user (Auth0)
$account_deletedThe user was deleted
$organization_createdAn organization was made, by its creator
$member_invitedSomeone was invited to an organization, by the person who invited
$member_joined, $member_removedA person joined or left an organization

Each event carries $source, naming the provider, and method where the provider says how the person signed in. The person gets auth_provider, email_verified and signed_up_at. Email addresses, names and phone numbers are never sent to Mode.

Nothing is counted twice. Every event is keyed by your provider's own id for the delivery, so a retry from your provider is stored once. When Mode can't pass a delivery on straight away it keeps it and sends it again within minutes, under the same key.
Metrics auth providers

Clerk

Clerk signs its webhooks, and Mode checks each one with the endpoint's signing secret.

  1. In Mode, connect Clerk with any name and copy the address. You add the secret in the last step.
  2. In the Clerk dashboard open Configure, then Webhooks, and add an endpoint with the address.
  3. Subscribe to the user, session, organization, organizationInvitation and organizationMembership events.
  4. Copy the endpoint's Signing Secret (whsec_...) and paste it into the connection as its signing secret.
Clerk eventMode event
user.created$signed_up
session.created$signed_in
session.ended, session.removed, session.revoked$signed_out
user.deleted$account_deleted
organization.created$organization_created
organizationInvitation.created$member_invited, when Clerk names who invited
organizationMembership.created, .deleted$member_joined, $member_removed
Metrics auth providers

Auth0

An Auth0 log stream sends every sign up, login and logout, with a token you give both Auth0 and Mode.

  1. In Mode, connect Auth0. Mode fills in a random token. Copy it and the address before you connect.
  2. In the Auth0 dashboard open Monitoring, then Streams, and create a Custom Webhook stream.
  3. Set Payload URL to the address and Authorization Token to Bearer followed by the token.
  4. Set Content Type to application/json and Content Format to JSON Array, then save.
Log typeMode event
ss$signed_up
s$signed_in
slo$signed_out
f, fp, fu, fcoa, fco, fcpro$sign_in_failed with reason
sdu$account_deleted

A login into an Auth0 organization puts the event in that organization's group.

Metrics auth providers

Supabase Auth

A database webhook on auth.users sends sign ups, sign ins and deletions, and never sits in the path of a sign in.

  1. In Mode, connect Supabase Auth. Mode fills in a random token. Copy it and the address before you connect.
  2. In the Supabase dashboard open Database, then Webhooks, and create a webhook on the auth schema's users table for Insert, Update and Delete.
  3. Pick HTTP Request, set the method to POST and the URL to the address.
  4. Add the header Authorization with Bearer followed by the token, then create it.
ChangeMode event
A row inserted$signed_up
last_sign_in_at changed$signed_in
The email confirmedemail_verified on the person
A row deleted$account_deleted

Auth Hooks

You can count sign ins from an HTTPS Custom Access Token hook instead, which also tells Mode the sign in method. Add the hook in Authentication, then Hooks, with the address, and paste the hook's secret (v1,whsec_...) into the connection as its auth hook secret. Mode answers the hook at once with your claims unchanged, so it never alters or slows a sign in. A refreshed token is not counted as a sign in. A Before User Created hook sends $signed_up the same way. Use the hooks or the database webhook for sign ins, not both.

Metrics auth providers

Firebase Authentication

Firebase has no webhooks, so a short Cloud Function forwards each sign up, sign in and deletion, signed with a secret you give both the function and Mode.

  1. In Mode, connect Firebase Authentication. Mode fills in a random secret. Copy it and the address before you connect.
  2. Add the function below to your Firebase functions, set MODE_AUTH_URL to the address and MODE_AUTH_SECRET to the secret, and deploy.
  3. In Authentication, then Settings, then Blocking functions, pick modeBeforeCreate for Before account creation and modeBeforeSignIn for Before sign in.
javascript
const { beforeUserCreated, beforeUserSignedIn } = require('firebase-functions/v2/identity')
const functions = require('firebase-functions/v1')
const crypto = require('crypto')

// Sends one event to Mode, signed by Standard Webhooks. Never blocks a sign in.
async function send(type, user, id, at, method) {
  const key = Buffer.from(process.env.MODE_AUTH_SECRET.replace('whsec_', ''), 'base64')
  const created = user.metadata && user.metadata.creationTime
  const body = JSON.stringify({
    id, type, method, time: new Date(at).toISOString(), tenantId: user.tenantId,
    user: { uid: user.uid, emailVerified: !!user.emailVerified,
            creationTime: created ? new Date(created).toISOString() : undefined }
  })
  const ts = String(Math.floor(Date.now() / 1000))
  const sig = crypto.createHmac('sha256', key).update(`${id}.${ts}.${body}`).digest('base64')
  try {
    await fetch(process.env.MODE_AUTH_URL, {
      method: 'POST', body, signal: AbortSignal.timeout(3000),
      headers: { 'content-type': 'application/json', 'webhook-id': id,
                 'webhook-timestamp': ts, 'webhook-signature': `v1,${sig}` }
    })
  } catch (e) {}
}

exports.modeBeforeCreate = beforeUserCreated(e =>
  send('user.created', e.data, e.eventId, e.timestamp, e.additionalUserInfo && e.additionalUserInfo.providerId))
exports.modeBeforeSignIn = beforeUserSignedIn(e =>
  send('user.signed_in', e.data, e.eventId, e.timestamp, e.additionalUserInfo && e.additionalUserInfo.providerId))
exports.modeUserDeleted = functions.auth.user().onDelete((user, ctx) =>
  send('user.deleted', user, ctx.eventId, ctx.timestamp))

The function returns nothing, so Firebase lets every sign up and sign in through unchanged. Firebase reports no sign outs.

Metrics auth providers

WorkOS

WorkOS signs its webhooks, and Mode checks each one with the endpoint's secret.

  1. In Mode, connect WorkOS with any name and copy the address. You add the secret in the last step.
  2. In the WorkOS dashboard open Webhooks and create an endpoint with the address.
  3. Pick the user, session, organization, invitation and organization_membership events.
  4. Copy the endpoint's secret and paste it into the connection as its webhook secret.
WorkOS eventMode event
user.created$signed_up
session.created$signed_in, in its organization
session.revoked$signed_out
user.deleted$account_deleted
invitation.created$member_invited
organization_membership.created, .deleted$member_joined, $member_removed
organization.created, .updatedThe organization's name on its group
Metrics auth providers

Deliveries and status

Each connection shows its last deliveries, the person each one landed on and whether anything waits to be read again.

A delivery Mode can't pass on yet is kept for up to 30 days and read again within the hour, under the same ids, and the connection shows failing with the reason. Read them again does it straight away. A delivery that fails the signature check is answered 400, which your provider's own delivery log shows. Check that the address and the secret are the ones on the connection.

API and MCP

Auth providers are connected systems, so the same tools and routes connect and manage them. An agent uses connect_system with system set to clerk, auth0, supabase, firebase or workos, then connected_systems, set_system, system_deliveries, system_kept, replay_system and disconnect_system. Over HTTP the routes are under /v1/metrics/systems, as Connected systems lists. They take an MCP key with read and write access from Metrics, Setup, MCP server, or an org or personal key with Metrics MCP access. A Metrics secret key from Metrics, Setup, Keys is refused.

shell
curl -X POST https://app.gotmode.com/v1/metrics/systems \
  -H "Authorization: Bearer YOUR_MCP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"system": "clerk", "name": "clerk", "credentials": {"signing_secret": "whsec_..."}}'

Let AI run your marketing.

Mode Agent does the daily work. You approve the spend.

Get early access