How to Add organization_id in Metadata With Actions

Overview

This article explains how to access the user’s organization details in a post-login trigger after accepting an invitation to the organization, and clarifies why a post-login trigger should be used instead of a post-user-registration trigger.

Applies To

  • Organizations
  • Actions

Solution

The event object within the post-user-registration action does not contain the organization details, so the post-login action should be used.

Here is an example for adding the organization_id in app_metadata:

if (event.organization) {
  api.user.setAppMetadata(“organization_id”, event.organization.id);
}