Guide: Migrate your custom Rules to Auth0 Actions

Due to the deprecation of Auth0 Rules on Feb 25, 2022, users are required to migrate their custom Rules to the latest Auth0 Actions.

This post will guide you through this migration process.

Auth0 Rule to migrate

Name: Add user information to access token


function (user, context, callback) {
  // This rule adds the authenticated user's email address to the access token.

  var namespace = '';

  context.accessToken[namespace + 'email'] =;
  context.accessToken[namespace + 'email_verified'] = user.email_verified;

  return callback(null, user, context);

Create Auth0 custom Action

  1. Go to Actions → Flows → Login

  2. Go to the “Custom” tab and click “Create Action”

  3. Give the action a name

  4. Here’s how the Action version of the old Auth0 Rule looks like:

    exports.onExecutePostLogin = async (event, api) => {
      // This rule adds the authenticated user's email address to the access token.
      if (event.authorization) {
        const namespace = '';
        api.accessToken.setCustomClaim(`${namespace}/email_verified`, event.user.email_verified);
  5. You can click on the “Test” button before deploying

  6. After you’ve the deployed the Action, you want to drag it into the Login flow

  7. Make sure to click “Apply” in order to save the latest changes

  8. Now you can disable the old Rule, since the new Action that we created has already been deployed

Additional resources

You can take a look at the docs for more comprehensive code examples on the new Auth0 Actions:


Thanks for sharing it with the rest of community Nikolay!