# How to add email to token?

**URL:** <https://community.auth0.com/t/how-to-add-email-to-token/138686>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [July 11, 2024, 9:37pm UTC](https://community.auth0.com/t/how-to-add-email-to-token/138686 "2024-07-11T21:37:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kostiav13](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kostiav13/32/61729_2.png) [@kostiav13](https://community.auth0.com/u/kostiav13)\
**Post date:** [July 11, 2024, 9:37pm UTC](https://community.auth0.com/t/how-to-add-email-to-token/138686/1 "2024-07-11T21:37:15Z")

</div>

I tried this but without success:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.authorization) {
  api.accessToken.setCustomClaim("email", event.user.email);
  }
};

```

i need email:email

the default template works, but it outputs with a domain and I can’t remove it  
I’ve been scrolling through a lot of topics and none of them are working solutions

 ![Безымянный](https://global.discourse-cdn.com/auth0/original/3X/4/d/4d53fface0cf211466cb535abdc19714b7a3d739.png)

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 11, 2024, 10:50pm UTC](https://community.auth0.com/t/how-to-add-email-to-token/138686/4 "2024-07-11T22:50:16Z")

</div>

Hey there @kostiav13 welcome to the community!

> [@kostiav13](#):
>
> the default template works, but it outputs with a domain and I can’t remove it  
> I’ve been scrolling through a lot of topics and none of them are working solutions

The default template uses the namespace (domain) because the `email` claim is unfortunately [generally restricted](https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims#non-restricted-claims). Is there a reason in particular you are looking to add the email to access tokens? Typically this exists in a user’s ID token and is added to tokens when the `email` [scope](https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes#standard-claims) is passed in the authorization request.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [July 25, 2024, 10:50pm UTC](https://community.auth0.com/t/how-to-add-email-to-token/138686/5 "2024-07-25T22:50:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
