# Rule to add user email to access token?

**URL:** <https://community.auth0.com/t/rule-to-add-user-email-to-access-token/68248>\
**Category:** Get Help\
**Created:** [August 19, 2021, 2:43pm UTC](https://community.auth0.com/t/rule-to-add-user-email-to-access-token/68248 "2021-08-19T14:43:01Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![nikolay](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nikolay/32/13374_2.png) [@nikolay](https://community.auth0.com/u/nikolay)\
**Post date:** [September 1, 2021, 10:55am UTC](https://community.auth0.com/t/rule-to-add-user-email-to-access-token/68248/10 "2021-09-01T10:55:44Z")

</div>

For the people who want to migrate their Auth0 Rules, due to the deprecation on **Feb 25, 2022** , here’s how the Auth0 Action version would look like:

```auto
exports.onExecutePostLogin = async (event, api) => {
  // This rule adds the authenticated user's email address to the access token.
  if (event.authorization) {
    const namespace = 'https://MY_DOMAIN_DOT_COM';
    api.accessToken.setCustomClaim(`${namespace}/claims/email`, event.user.email);
  }
};

```

Detailed migration guide can be found here:

> [@Guide: Migrate your custom Rules to Auth0 Actions](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915):
>
> Due to the future deprecation of Auth0 Rules, 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 Script: function (user, context, callback) { // This rule adds the authenticated user's email address to the access token. var namespace = 'https://mydomain.com/'; context.accessToken[namespace + 'email'] = user.email; context.accessToken[…

---

_[View the full topic](https://community.auth0.com/t/rule-to-add-user-email-to-access-token/68248)._
