How to add email to token?

I tried this but without success:

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

Hey there @kostiav13 welcome to the community!

The default template uses the namespace (domain) because the email claim is unfortunately generally restricted. 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 is passed in the authorization request.