Trigger for Just-in-Time Membership


When using the Organizations feature, this article explains whether there is there an Action trigger that a user has been added to an organization through just-in-time membership.


There is currently no extensibility point for Organization membership.


This is not something supported currently “out of the box”, but a Post-Login action can be made to achieve this.

  • If the Just-In-Time members will be logging in for the first time, a check of the user’s “event.stats.logins_count === 1”, can indicate it is the user’s first login. If a first login is detected, perform an additional check if the user has an Organization assigned by inspecting the event.organization object:

Provided that the user’s first login will be carried out in the context of an Organization, if both conditions are fulfilled this can be considered a “just-in-time membership” event and used to trigger additional business logic.

  • Alternatively, if a first time login is not necessarily aligned with the user’s organization membership, a custom flag could be stored in the user’s app_metadata, to indicate whether the membership process had been triggered for the user yet.
  • If this custom flag flag was absent, check the user’s organization details are present in the event.organization object. If the user has an organization set, then this can be considered a “Just In Time membership” event.
  • After any additional business logic has been triggered, add the custom flag to the app_metadata via the Action’s api, e.g.:

if (event.user.app_metadata.JIT_membership_processed) { return; //exit early, already processed } else { if (event.organization) { //Not processed yet and current login is in Organization context - begin JIT processing here and mark user as processed if successful using custom app_metadata flag api.user.setAppMetadata("JIT_membership_processed", true) } }

This can be used to indicate the process does not need to be repeated on future logins for that user. Please see the below link for more information on managing metadata with Actions