pex

Connect Auth0

Push your Auth0 users to Apex with a post-login Action. Auth0's user_id becomes your internal_user_id.

Post-login Action

Auth0 Actions run server-side after every login (including the first one after signup), so a single Action covers both new and returning users.

// Auth0 → Actions → Login → "Send identity to Apex"
exports.onExecutePostLogin = async (event) => {
  await fetch("https://app.apex.inc/api/v1/events", {
    method: "POST",
    headers: {
      "content-type": "application/json",
      "x-api-key": event.secrets.APEX_API_KEY, // apex_sk_...
    },
    body: JSON.stringify({
      events: [
        {
          type: event.stats.logins_count === 1 ? "user_signed_up" : "user_identified",
          email: event.user.email,
          data: {
            userId: event.user.user_id,
            name: event.user.name,
            // Auth0 exposes the social/profile photo as `picture`. Mapping it
            // to the canonical `avatar_url` attribute gives you end-user
            // photos across Apex with no extra work.
            avatar_url: event.user.picture,
          },
        },
      ],
    }),
  }).catch(() => {}); // never block login on Apex
};

Info

event.stats.logins_count === 1 lets you distinguish a brand-new signup from a returning login, so your Apex journeys can branch on it. Either way the user_id is the stable key Apex reconciles on.

Wire it up

  1. Create a workspace API key (apex_sk_…) in Settings → API keys.
  2. In Auth0, add it under Actions → Library → (your action) → Secrets as APEX_API_KEY.
  3. Add the Action to your Login flow and deploy.
  4. Log in as a test user — they should appear in Customers, identified.

Warning

Keep the .catch(() => {}). An Apex outage must never break your Auth0 login flow — identity delivery is best-effort.