Add or Update User Metadata in Post-Login Actions

Overview

This article provides instructions for updating user_metadata within a Post-Login Action.

Applies To
  • Post-Login Actions
Solution

User metadata can be saved within the Actions flow by using the api.user.setUserMetadata(name, value) trigger.  This trigger updates the event object that propagates through the pipeline, making the update visible to subsequent Actions.

 

It is also possible to instantiate the ManagementClient in an Action to save user metadata. This method makes a PATCH call to /v2/users/{id} to update app_metadata fields in a user's profile.

If multiple actions modify user_metadata or app_metadata all requested changes are collected and persisted as a single transaction at the end of the flow. Calling ManagementClient directly will not make the changes visible in subsequent Actions within the same login transaction. The updated user metadata will not appear updated while the Actions are running for that transaction.

 

NOTE: The trigger api.user.setAppMetadata(name, value) can be used for app_metadata.

 

Recommended content

No recommended content found...